コード例 #1
0
  void selected(Object treeNode) {
    if (treeNode == null) {
      pathText.setText(""); // $NON-NLS-1$
    } else {
      IModelTransferNode node = ((ITreeNode) treeNode).getElement();

      pathText.setText(node.getName());
    }
  }
コード例 #2
0
    @Override
    public void checkStateChanged(CheckStateChangedEvent event) {
      ITreeNode node = (ITreeNode) event.getElement();
      IModelTransferNode model = node.getElement();

      // apply the check state to the model
      if (event.getChecked()) {
        config.addModelToTransfer(model.getPrimaryResourceURI());
      } else {
        config.removeModelToTransfer(model);
      }

      // propagate the check state to other occurrences of the same model
      for (ITreeNode next : nodes.get(model)) {
        event.getCheckable().setChecked(next, event.getChecked());
      }
    }
コード例 #3
0
      void createChildren() {
        Collection<IModelTransferNode> dependencies = element.getDependencies();
        Collection<IModelTransferNode> dependents = element.getDependents();

        if (!dependencies.isEmpty() || !dependents.isEmpty()) {
          children = Lists.newArrayListWithCapacity(dependencies.size() + dependents.size());

          // the recommendation for importing dependencies vs. dependents is
          // reversed for export as for import. We suggest to export dependencies
          // of an exported model (those that it references) and import dependents
          // of an imported model (those that reference it)
          for (IModelTransferNode next : isImport ? dependents : dependencies) {
            children.add(new TreeNode(this, next, isImport));
          }

          for (IModelTransferNode next : isImport ? dependencies : dependents) {
            // don't show a model as both a dependent and a
            // dependency if it both references and is
            // referenced by the other
            if (isImport ? !dependents.contains(next) : !dependencies.contains(next)) {
              children.add(new TreeNode(this, next, false));
            }
          }

          // initialize check state of new children from configuration
          Display.getCurrent()
              .asyncExec(
                  new Runnable() {

                    @Override
                    public void run() {
                      if (config != null) {
                        Collection<IModelTransferNode> imported = config.getModelsToTransfer();
                        ICheckable checkable = (ICheckable) viewer;
                        for (ITreeNode next : children) {
                          if (imported.contains(next.getElement())) {
                            checkable.setChecked(next, true);
                          }
                        }
                      }
                    }
                  });
        }
      }
コード例 #4
0
    @Override
    public boolean hasChildren(Object element) {
      IModelTransferNode importNode = ((TreeNode) element).getElement();

      return !(importNode.getDependencies().isEmpty() && importNode.getDependents().isEmpty());
    }