Java Code Examples for org.openide.explorer.view.Visualizer#findNode()
The following examples show how to use
org.openide.explorer.view.Visualizer#findNode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckListener.java From netbeans with Apache License 2.0 | 6 votes |
public void keyPressed(KeyEvent e) { if (e.getKeyChar() == ' ') { JTree tree = (JTree) e.getSource(); TreePath path = tree.getSelectionPath(); if( null == path ) return; Node node = Visualizer.findNode( path.getLastPathComponent() ); if( null == node ) return; boolean isSelected = settings.isNodeVisible( node ); settings.setNodeVisible( node, !isSelected ); tree.repaint(); e.consume(); } }
Example 2
Source File: CheckListener.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void keyPressed(KeyEvent e) { if (e.getKeyChar() == ' ') { // NOI18N JTree tree = (JTree) e.getSource(); TreePath path = tree.getSelectionPath(); if (path == null) { return; } Node node = Visualizer.findNode(path.getLastPathComponent()); if (node == null) { return; } boolean isSelected = model.isNodeSelected(node); model.setNodeSelected(node, !isSelected); tree.repaint(); e.consume(); } }
Example 3
Source File: HistoryFileView.java From netbeans with Apache License 2.0 | 6 votes |
private int getPrevRow(int row) { row = row - 1; Outline outline = tablePanel.treeView.getOutline(); if(row < 0 || row >= outline.getRowCount()) { return -1; } TreePath path = outline.getOutlineModel().getLayout().getPathForRow(row); Node node = Visualizer.findNode(path.getLastPathComponent()); if(node.isLeaf()) { if(node instanceof RevisionNode || node instanceof RevisionNode.FileNode) { return row; } else { return -1; } } else { TreePathSupport support = outline.getOutlineModel().getTreePathSupport(); if(support.isExpanded(path)) { return getPrevRow(row); } else { support.expandPath(path); return row + node.getChildren().getNodesCount(); } } }
Example 4
Source File: FileTreeView.java From netbeans with Apache License 2.0 | 6 votes |
@Override public String getDisplayName (Object o) { Node n = Visualizer.findNode(o); String value = n.getDisplayName(); T leafNode = convertNode(n); if (leafNode != null) { // do not set selected flag, outline view handles color in its own way // instead return fg color in getForeground String htmlDisplayName = DiffUtils.getHtmlDisplayName(leafNode, isModified(leafNode), false); htmlDisplayName = annotateName(leafNode, htmlDisplayName); if (htmlDisplayName != null) { value = "<html>" + htmlDisplayName; //NOI18N } } return value; }
Example 5
Source File: TreeModelRoot.java From netbeans with Apache License 2.0 | 6 votes |
private Object initExpandCollapseNotify(TreeExpansionEvent event) { Node node = Visualizer.findNode(event.getPath ().getLastPathComponent()); Object obj = node.getLookup().lookup(Object.class); Object actOn; node = node.getParentNode(); if (node == null) { actOn = new Integer(0); } else { Children ch = node.getChildren(); if (ch instanceof TreeModelNode.TreeModelChildren) { actOn = ((TreeModelNode.TreeModelChildren) ch).getTreeDepth(); } else { actOn = ch; } } Models.CompoundModel model = getModel(); if (model != null) { DefaultTreeExpansionManager.get(model).setChildrenToActOn(actOn); } return obj; }
Example 6
Source File: ClassMemberPanelUI.java From netbeans with Apache License 2.0 | 6 votes |
@CheckForNull @Override public Node findNode(@NonNull final Point loc) { final TreePath path = tree.getPathForLocation( loc.x, loc.y ); if( null == path ) { return null; } final Node node = Visualizer.findNode( path.getLastPathComponent()); if (!(node instanceof ElementNode)) { return null; } final ElementNode enode = (ElementNode) node; final ElementNode.Description desc = enode.getDescritption(); //Other and module do not have javadoc return desc.kind != ElementKind.OTHER && desc.kind != ElementKind.MODULE ? node : null; }
Example 7
Source File: FileTreeView.java From netbeans with Apache License 2.0 | 5 votes |
private static boolean testNodeInRow(Outline outline, Node node, int i) { int modelIndex = outline.convertRowIndexToModel(i); if (modelIndex != -1) { Object o = outline.getModel().getValueAt(modelIndex, 0); Node n = Visualizer.findNode(o); if (n == node) { return true; } } return false; }
Example 8
Source File: Browser.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void treeExpanded(TreeExpansionEvent event) { Object obj = event.getPath().getLastPathComponent(); if(obj == null) return; Node n = Visualizer.findNode(obj); if(n instanceof RepositoryPathNode) { RepositoryPathNode node = (RepositoryPathNode) n; node.expand(); } }
Example 9
Source File: CheckListener.java From netbeans with Apache License 2.0 | 5 votes |
public void mouseClicked(MouseEvent e) { // todo (#pf): we need to solve problem between click and double // click - click should be possible only on the check box area // and double click should be bordered by title text. // we need a test how to detect where the mouse pointer is JTree tree = (JTree) e.getSource(); Point p = e.getPoint(); int x = e.getX(); int y = e.getY(); int row = tree.getRowForLocation(x, y); TreePath path = tree.getPathForRow(row); // if path exists and mouse is clicked exactly once if( null == path ) return; Node node = Visualizer.findNode( path.getLastPathComponent() ); if( null == node ) return; Rectangle chRect = CheckRenderer.getCheckBoxRectangle(); Rectangle rowRect = tree.getPathBounds(path); chRect.setLocation(chRect.x + rowRect.x, chRect.y + rowRect.y); if (e.getClickCount() == 1 && chRect.contains(p)) { boolean isSelected = settings.isNodeVisible( node ); settings.setNodeVisible( node, !isSelected ); tree.repaint(); } }
Example 10
Source File: DelegatingCellRenderer.java From netbeans with Apache License 2.0 | 5 votes |
static final Node getNodeAt(Outline outline, int rowInUI) { Node result = null; OutlineModel om = (OutlineModel) outline.getModel(); int row = outline.convertRowIndexToModel(rowInUI); TreePath path = om.getLayout().getPathForRow(row); if (path != null) { result = Visualizer.findNode(path.getLastPathComponent()); } return result; }
Example 11
Source File: FileTreeView.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Color getForeground (Object o) { Color c = null; Node n = Visualizer.findNode(o); T leafNode = convertNode(n); if (leafNode != null) { c = leafNode.getAnnotatedFontColor(); } return c; }
Example 12
Source File: FileTreeView.java From netbeans with Apache License 2.0 | 5 votes |
private Node getNodeAt( int rowIndex ) { Node result = null; TreePath path = view.getOutline().getOutlineModel().getLayout().getPathForRow(rowIndex); if (path != null) { result = Visualizer.findNode(path.getLastPathComponent()); } return result; }
Example 13
Source File: ResultsOutlineSupport.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void treeExpanded(TreeExpansionEvent event) { if (!expansionListenerEnabled) { return; } Object lpc = event.getPath().getLastPathComponent(); Node node = Visualizer.findNode(lpc); if (node != null) { expandOnlyChilds(node); } }
Example 14
Source File: DebugTreeView.java From netbeans with Apache License 2.0 | 5 votes |
/** * Get the DVThread or DVThreadGroup instance on the given path. * @param path * @return an instance of DVThread or DVThreadGroup */ public Object getThreadObject(TreePath path) { Node node = Visualizer.findNode(path.getLastPathComponent()); DVThread dvThread = node.getLookup().lookup(DVThread.class); if (dvThread != null) { return dvThread; } DVThreadGroup dvThreadGroup = node.getLookup().lookup(DVThreadGroup.class); return dvThreadGroup; }
Example 15
Source File: DebuggingViewComponent.java From netbeans with Apache License 2.0 | 5 votes |
/** * Check whether we should scroll to the current thread. * * @param path Path of node that has been just expanded, or that has new * children. */ private void checkIfWeShouldScrollToCurrentThread(TreePath path) { Node node = Visualizer.findNode(path.getLastPathComponent()); if (node == null) { return; } DVThread dvThread = node.getLookup().lookup(DVThread.class); DVThread currentThread; synchronized (lock) { currentThread = (debugger != null) ? debugger.getCurrentThread() : null; } if (currentThread != null && currentThread == dvThread) { threadToScrollRef = new WeakReference<DVThread>(dvThread); } }
Example 16
Source File: CheckTreeView.java From netbeans with Apache License 2.0 | 5 votes |
private boolean toggle( TreePath treePath ) { if( treePath == null ) return false; Node node = Visualizer.findNode( treePath.getLastPathComponent() ); if( node == null ) return false ; Collection<? extends FixDescription> fixes = node.getLookup().lookupAll(FixDescription.class); if (!fixes.isEmpty()) { State s = CheckRenderer.getCheckState(fixes); boolean select = s != State.SELECTED; for (FixDescription fd : fixes) { fd.setSelected(select); } return true; // if( description.isSelectable() ) { // description.setSelected( !description.isSelected() ); // return true; // } else { // boolean newState = !description.isSelected(); // description.setSelected(newState); // toggleChildren( description.getSubs(), newState ); // } } return false; }
Example 17
Source File: HistoryFileView.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Icon getIcon(Object o) { final Node n = Visualizer.findNode(o); if(HistoryRootNode.isWait(n)) { return delegate.getIcon(o); } if(getOutline().getOutlineModel().isLeaf(o) || HistoryRootNode.isLoadNext(n)) return NO_ICON; return null; }
Example 18
Source File: BeanInfoEditorTest.java From netbeans with Apache License 2.0 | 5 votes |
private void browseTree(Object root, TreeModel model, String string) { Object node = Visualizer.findNode(root); if (node instanceof Node) { Node n = (Node) node; System.out.println(n.getDisplayName()); } System.out.println(string + node.getClass().getName()); int childCount = model.getChildCount(root); for (int i = 0; i < childCount; i++) { browseTree(model.getChild(root, i), model, string + " "); } }
Example 19
Source File: CheckNodeListModel.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public CheckNode getCheckNodeAt(int index) { Object item = getElementAt(index); if (item != null) { return (CheckNode) Visualizer.findNode(item); } return null; }
Example 20
Source File: FileTreeView.java From netbeans with Apache License 2.0 | 4 votes |
@Override public String getTooltipText (Object o) { Node n = Visualizer.findNode(o); File file = n.getLookup().lookup(File.class); return file != null ? file.getAbsolutePath() : n.getShortDescription(); }