コード例 #1
0
ファイル: TreeView.java プロジェクト: jexp/idea2
 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();
 }
コード例 #2
0
ファイル: TreeView.java プロジェクト: jexp/idea2
  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;
  }
コード例 #3
0
ファイル: TreeView.java プロジェクト: jexp/idea2
 @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();
 }
コード例 #4
0
ファイル: TreeView.java プロジェクト: jexp/idea2
  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;
  }