Beispiel #1
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;
  }
 public void clearAllMessages() {
   for (MessageNode messageItem : myMessageItems) {
     messageItem.clearRangeMarker();
   }
   myMessageItems.clear();
   myStatusNode = null;
   createModel();
   myTree.setModel(myTreeModel);
 }
Beispiel #3
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();
 }
Beispiel #4
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();
 }
Beispiel #5
0
  public void addException(AntMessage exception, boolean showFullTrace) {
    MessageNode exceptionRootNode = null;

    StringTokenizer tokenizer = new StringTokenizer(exception.getText(), "\r\n");
    while (tokenizer.hasMoreElements()) {
      String line = (String) tokenizer.nextElement();
      if (exceptionRootNode == null) {
        AntMessage newMessage =
            new AntMessage(
                exception.getType(),
                exception.getPriority(),
                line,
                exception.getFile(),
                exception.getLine(),
                exception.getColumn());
        exceptionRootNode = new MessageNode(newMessage, myProject, true);
        myMessageItems.add(exceptionRootNode);
      } else if (showFullTrace) {
        if (StringUtil.startsWithChar(line, '\t')) {
          line = line.substring(1);
        }

        HyperlinkUtil.PlaceInfo info = HyperlinkUtil.parseStackLine(myProject, '\t' + line);
        VirtualFile file = info != null ? info.getFile() : null;
        int lineNumber = info != null ? info.getLine() : 0;
        int column = info != null ? info.getColumn() : 1;
        AntMessage newMessage =
            new AntMessage(
                exception.getType(), exception.getPriority(), line, file, lineNumber, column);
        MessageNode child = new MessageNode(newMessage, myProject, false);
        exceptionRootNode.add(child);
        myMessageItems.add(child);
      }
    }
    if (exceptionRootNode == null) return;

    MutableTreeNode parentNode = (MutableTreeNode) myParentPath.getLastPathComponent();
    myTreeModel.insertNodeInto(exceptionRootNode, parentNode, parentNode.getChildCount());

    handleExpansion();
  }
Beispiel #6
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;
  }
Beispiel #7
0
 @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;
 }