// {{{ removeSelectedNode() method private void removeSelectedNode() { TreePath path = resultTree.getSelectionPath(); if (path == null) return; MutableTreeNode value = (MutableTreeNode) path.getLastPathComponent(); if (path.getPathCount() > 1) { // Adjust selection so that repeating some removals // behave naturally. TreePath parentPath = path.getParentPath(); MutableTreeNode parent = (MutableTreeNode) parentPath.getLastPathComponent(); int removingIndex = parent.getIndex(value); int nextIndex = removingIndex + 1; if (nextIndex < parent.getChildCount()) { TreeNode next = parent.getChildAt(nextIndex); resultTree.setSelectionPath(parentPath.pathByAddingChild(next)); } else { resultTree.setSelectionPath(parentPath); } resultTreeModel.removeNodeFromParent(value); } HyperSearchOperationNode.removeNodeFromCache(value); if (resultTreeRoot.getChildCount() == 0) { hideDockable(); } } // }}}
private void addJavacMessageImpl(AntMessage message) { MutableTreeNode parentNode = (MutableTreeNode) myParentPath.getLastPathComponent(); MessageNode messageNode = new MessageNode(message, myProject, false); myTreeModel.insertNodeInto(messageNode, parentNode, parentNode.getChildCount()); myMessageItems.add(messageNode); handleExpansion(); }
public Object addMessage(AntMessage message) { MessageNode messageNode = createMessageNode(message); MutableTreeNode parentNode = (MutableTreeNode) myParentPath.getLastPathComponent(); myTreeModel.insertNodeInto(messageNode, parentNode, parentNode.getChildCount()); myMessageItems.add(messageNode); handleExpansion(); return messageNode; }
/* Simple tree node factory method - set's parent and user object. */ private DefaultMutableTreeNode makeNode(Object userObject, MutableTreeNode parent) { DefaultMutableTreeNode node = new DefaultMutableTreeNode(userObject); if (parent != null) { treeModel.insertNodeInto(node, parent, parent.getChildCount()); } return node; }
private ToolsGroup[] getGroupList() { ArrayList<ToolsGroup> result = new ArrayList<ToolsGroup>(); MutableTreeNode root = (MutableTreeNode) myTree.getModel().getRoot(); for (int i = 0; i < root.getChildCount(); i++) { final CheckedTreeNode node = (CheckedTreeNode) root.getChildAt(i); for (int j = 0; j < node.getChildCount(); j++) { final CheckedTreeNode toolNode = (CheckedTreeNode) node.getChildAt(j); ((Tool) toolNode.getUserObject()).setEnabled(toolNode.isChecked()); } result.add((ToolsGroup) node.getUserObject()); } return result.toArray(new ToolsGroup[result.size()]); }
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(); }
private static void addChildrenTo(final MutableTreeNode node, final List<TreeNode> children) { for (final Object aChildren : children) { final MutableTreeNode child = (MutableTreeNode) aChildren; node.insert(child, node.getChildCount()); } }