Example #1
0
 private @Nullable OpenFileDescriptor getDescriptorForTaskNode(MessageNode node) {
   final String[] text = node.getText();
   if (text == null || text.length == 0) return null;
   final String taskName = text[0];
   final TreeNode parentNode = node.getParent();
   if (!(parentNode instanceof MessageNode)) return null;
   final MessageNode messageNode = (MessageNode) parentNode;
   if (messageNode.getType() != AntBuildMessageView.MessageType.TARGET) return null;
   final BuildTask task =
       ((AntBuildModelBase) myBuildFile.getModel()).findTask(messageNode.getText()[0], taskName);
   return (task == null) ? null : task.getOpenFileDescriptor();
 }
Example #2
0
  public boolean restoreSelection(TreeSelection treeSelection) {
    if (treeSelection.isEmpty()) return false;

    DefaultMutableTreeNode root = (DefaultMutableTreeNode) myTreeModel.getRoot();
    for (int i = 0; i < root.getChildCount(); i++) {
      TreeNode node = root.getChildAt(i);
      if (node instanceof MessageNode) {
        MessageNode messageNode = (MessageNode) node;
        String[] text = messageNode.getText();
        if (text.length == 0) continue;
        if (Comparing.equal(treeSelection.mySelectedTarget, text[0])) {
          TreePath pathToSelect = new TreePath(messageNode.getPath());
          for (Enumeration enumeration = messageNode.children(); enumeration.hasMoreElements(); ) {
            Object o = enumeration.nextElement();
            if (o instanceof MessageNode) {
              messageNode = (MessageNode) o;
              if (Comparing.equal(treeSelection.mySelectedTask, text[0])) {
                pathToSelect = new TreePath(messageNode.getPath());
                break;
              }
            }
          }
          TreeUtil.selectPath(myTree, pathToSelect);
          myTree.expandPath(pathToSelect);
          return true;
        }
      }
    }

    return false;
  }
Example #3
0
 @Nullable
 private OpenFileDescriptor getDescriptorForTargetNode(MessageNode node) {
   final String targetName = node.getText()[0];
   final AntBuildTargetBase target =
       (AntBuildTargetBase) myBuildFile.getModel().findTarget(targetName);
   return (target == null) ? null : target.getOpenFileDescriptor();
 }
Example #4
0
  public TreeSelection getSelection() {
    TreeSelection selection = new TreeSelection();

    TreePath path = myTree.getSelectionPath();
    if (path == null) return selection;

    Object[] paths = path.getPath();
    for (Object o : paths) {
      if (o instanceof MessageNode) {
        MessageNode messageNode = (MessageNode) o;
        AntBuildMessageView.MessageType type = messageNode.getType();
        if (type == AntBuildMessageView.MessageType.TARGET) {
          selection.mySelectedTarget = messageNode.getText()[0];
        } else if (type == AntBuildMessageView.MessageType.TASK) {
          selection.mySelectedTask = messageNode.getText()[0];
        }
      }
    }

    return selection;
  }