Exemplo n.º 1
0
  /** Handler for tree selection. */
  void handleTreeSelection() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    ElementSymbol element = null;

    if (!selection.isEmpty()) {
      ICriteriaStrategy strategy = ElementViewerFactory.getCriteriaStrategy(viewer);
      strategy.setTreeViewer(viewer); // make sure this viewer is set before using strategy

      if (strategy.isValid(selection.getFirstElement())) {
        Object eObj = selection.getFirstElement();
        if (eObj instanceof ElementSymbol) {
          element = ((ElementSymbol) eObj);
        } else {
          element = new ElementSymbol(strategy.getRuntimeFullName(eObj), true);

          // the viewer model contains EObjects. so the objects in the selection will
          // be EObjects. since the EObject is used later on in the QueryCriteriaStrategy.getNode()
          // method. save it here.
          element.setMetadataID(eObj);
        }
      }
    }

    model.selectElementSymbol(element);
  }