示例#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);
  }
示例#2
0
  /**
   * Constructs a <code>ElementEditor</code> using the given model.
   *
   * @param theParent the parent container
   * @param theModel the editor's model
   * @throws IllegalArgumentException if any of the parameters are <code>null</code>
   */
  public ElementEditor(Composite theParent, ElementEditorModel theModel) {
    super(theParent, ElementSymbol.class, theModel);
    controller = new ViewController();
    model = theModel;
    model.addModelListener(controller);

    // set the viewer on the CriteriaStrategy
    strategy = ElementViewerFactory.getCriteriaStrategy(viewer);
    strategy.setTreeViewer(viewer);
  }
示例#3
0
  /** Displays the appropriate UI for the current model state. */
  void displayElementSymbol() {
    CoreArgCheck.isNotNull(viewer);

    StructuredSelection selection = StructuredSelection.EMPTY;

    if (model.getElementSymbol() != null) {
      strategy.setTreeViewer(viewer); // make sure this viewer is set before using strategy
      Object node = strategy.getNode(model.getElementSymbol());

      if (node != null) {
        selection = new StructuredSelection(node);
      }

      if (!selection.equals(viewer.getSelection())) {
        viewer.setSelection(selection);
      }
    }
  }