示例#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
 @Nullable
 public Object getData(String dataId) {
   if (DataConstants.NAVIGATABLE.equals(dataId)) {
     MessageNode item = getSelectedItem();
     if (item == null) return null;
     if (isValid(item.getFile())) {
       return new OpenFileDescriptor(myProject, item.getFile(), item.getOffset());
     }
     if (item.getType() == AntBuildMessageView.MessageType.TARGET) {
       final OpenFileDescriptor descriptor = getDescriptorForTargetNode(item);
       if (descriptor != null && isValid(descriptor.getFile())) {
         return descriptor;
       }
     }
     if (item.getType() == AntBuildMessageView.MessageType.TASK) {
       final OpenFileDescriptor descriptor = getDescriptorForTaskNode(item);
       if (descriptor != null && isValid(descriptor.getFile())) {
         return descriptor;
       }
     }
   }
   return null;
 }
示例#3
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;
  }