Пример #1
0
  private void rehighlightNode(@NotNull MPSTreeNode node, @NotNull Feature feature) {
    unhighlightNode(node);

    SModel model = SModelRepository.getInstance().getModelDescriptor(feature.getModelReference());
    if (model instanceof EditableSModel && !(model.isReadOnly())) {
      if (feature instanceof ModelFeature) {
        // do not try to compute changes in case we need only model status
        TreeMessage message = getMessage((ModelFeature) feature);
        if (message != null) {
          node.addTreeMessage(message);
        }
        return;
      }

      EditableSModel emd = (EditableSModel) model;
      myRegistry.getCurrentDifference(emd).setEnabled(true);

      ModelChange change = myMap.get(feature);
      if (change == null) {
        change = myMap.getAddedAncestorValue(feature);
      }
      if (change != null) {
        node.addTreeMessage(getMessage(change, emd));
      } else if (myMap.isAncestorOfAddedFeature(feature)) {
        node.addTreeMessage(getMessage(FileStatus.MODIFIED));
      }
    }
  }
Пример #2
0
 private void collectExisting(MPSTreeNode node, Collection<String> existing) {
   for (int idx = 0; idx < node.getChildCount(); idx++) {
     TreeNode child = node.getChildAt(idx);
     if (child instanceof MPSTreeNode) {
       existing.add(child.toString());
       collectExisting(((MPSTreeNode) child), existing);
     }
   }
 }
Пример #3
0
 @Nullable
 @Override
 public Object getData(@NonNls String dataId) {
   if (dataId.equals(Location.LOCATION)) {
     MPSTreeNode currentNode = myTreeComponent.getCurrentNode();
     if (currentNode == null) {
       return null;
     }
     return new MPSLocation(
         myProject, ((ITestNodeWrapper) currentNode.getUserObject()).getNodePointer());
   }
   return null;
 }
Пример #4
0
 @Override
 protected void doInit() {
   DependencyTree tree = (DependencyTree) getTree();
   for (DepPath c : Sequence.fromIterable(myCycles).distinct()) {
     Iterator<DepLink> itr = Sequence.fromIterable(c.elements()).iterator();
     // skip first path element, which is always the one from my getCapturedDependencies()
     itr.next();
     MPSTreeNode parent = this;
     while (itr.hasNext()) {
       DependencyTreeNode dtn = new DependencyTreeNode(tree.getProject(), itr.next());
       parent.add(dtn);
       parent = dtn;
     }
   }
   myInitialized = true;
 }
Пример #5
0
 private void collectNew(
     TreePath path, Collection<String> existing, Collection<TreePath> newNodes) {
   Object lastPathComponent = path.getLastPathComponent();
   if (lastPathComponent instanceof MPSTreeNode) {
     MPSTreeNode node = ((MPSTreeNode) lastPathComponent);
     for (int idx = 0; idx < node.getChildCount(); idx++) {
       TreeNode child = node.getChildAt(idx);
       if (child instanceof MPSTreeNode) {
         TreePath childPath = path.pathByAddingChild(child);
         if (!(existing.contains(child.toString()))) {
           newNodes.add(childPath);
         }
         collectNew(childPath, existing, newNodes);
       }
     }
   }
 }
Пример #6
0
 private void unregisterNode(@NotNull MPSTreeNode node) {
   Feature feature = myFeatureExtractor.getFeature(node);
   if (feature != null) {
     synchronized (myFeaturesHolder) {
       if (myFeaturesHolder.getNodesByFeature(feature).contains(node)) {
         myFeaturesHolder.removeNodeWithFeature(feature, node);
       } else {
         if (LOG.isEnabledFor(Priority.ERROR)) {
           LOG.error(
               "trying to remove tree node which was not registered: "
                   + node.getClass().getName()
                   + " "
                   + feature);
         }
       }
     }
     unhighlightNode(node);
   }
 }
Пример #7
0
 private void unhighlightNode(@NotNull MPSTreeNode node) {
   node.removeTreeMessages(this, true);
 }