Пример #1
0
    @Override
    public Object[] getElements(Object inputElement) {
      Object[] result = elements;

      if ((inputElement != config) || (result == null)) {
        IModelTransferConfiguration inputConfig = (IModelTransferConfiguration) inputElement;
        List<TreeNode> nodes =
            Lists.newArrayListWithCapacity(inputConfig.getModelsToTransfer().size());

        for (IModelTransferNode next : inputConfig.getModelsToTransfer()) {
          nodes.add(new TreeNode(next));
        }

        result = nodes.toArray();

        if (inputConfig == config) {
          // cache the result
          elements = result;
        }
      }

      return result;
    }
Пример #2
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());
          }
        }
      }
    }
  }
Пример #3
0
  @Override
  protected Diagnostic doValidatePage() {
    Diagnostic result = Diagnostic.CANCEL_INSTANCE;

    if (importConfig != null) {
      if (importConfig.getModelsToTransfer().isEmpty()) {
        result =
            report(
                Diagnostic.CANCEL,
                NLS.bind(
                    Messages.ModelReferencesPage_7,
                    isImport ? Messages.ModelReferencesPage_8 : Messages.ModelReferencesPage_9));
      } else {
        result = importConfig.validate();
      }
    }

    return result;
  }