예제 #1
0
  private void initializeCheckedNodes() {
    final Collection<IModelTransferNode> initialSet = importConfig.getModelsToTransfer();
    final ITreeContentProvider contents = (ITreeContentProvider) modelsTree.getContentProvider();
    final ICheckable checkable = (ICheckable) modelsTree;

    final Set<IModelTransferNode> visited = Sets.newHashSet();
    final Queue<Object> queue =
        new java.util.ArrayDeque<Object>(Arrays.asList(contents.getElements(importConfig)));

    for (Object next = queue.poll(); next != null; next = queue.poll()) {
      ITreeNode parent = (ITreeNode) next;

      // we must check a parent if the user initially selected it on opening the wizard
      // or we are importing and it is a dependent of a checked node,
      // or we are exporting and it is a dependency of a checked node,
      // or it is a model sub-unit (required dependency) of a checked node
      boolean mustCheck = initialSet.contains(parent.getElement());
      if (mustCheck) {
        checkable.setChecked(next, true);
      }

      if (visited.add(parent.getElement())) {
        // recurse into the children
        for (Object child : contents.getChildren(next)) {
          ITreeNode treeNode = (ITreeNode) child;
          queue.add(treeNode);

          // we must check a node if either the user initially selected it on opening the wizard,
          // or we are importing and it is a dependent of a checked node,
          // or we are exporting and it is a dependency of a checked node,
          // or it is a model sub-unit (required dependency) of a checked node
          mustCheck =
              initialSet.contains(treeNode.getElement()) //
                  || (isImport ? treeNode.isDependent() : treeNode.isDependency()) //
                  || (checkable.getChecked(parent)
                      && parent.getElement().isModelSubUnit(treeNode.getElement()));

          if (mustCheck) {
            checkable.setChecked(child, true);
            importConfig.addModelToTransfer(treeNode.getElement().getPrimaryResourceURI());
          }
        }
      }
    }
  }
예제 #2
0
    @Override
    public Image getImage(Object element) {
      ITreeNode treeNode = (ITreeNode) element;
      Image result = super.getImage(element);

      if ((result != null) && treeNode.isDependent()) {
        // decorate it
        result =
            (Image)
                images.get(
                    new DecorationOverlayIcon(
                        result,
                        Activator.getIcon(Activator.ICON_DEPENDENT_OVERLAY16),
                        IDecoration.TOP_RIGHT));
      }

      return result;
    }