Java Code Examples for javax.swing.event.TreeExpansionEvent#getPath()
The following examples show how to use
javax.swing.event.TreeExpansionEvent#getPath() .
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: TreeWillListener.java From leetcode-editor with Apache License 2.0 | 6 votes |
@Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { TreePath selPath = event.getPath(); DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent(); Question question = (Question) node.getUserObject(); if (!isOneOpen(node)) { return; } else if ("lock".equals(question.getStatus())) { MessageUtils.showMsg(toolWindow.getContentManager().getComponent(), MessageType.INFO, "info", "no permissions"); throw new ExpandVetoException(event); } ProgressManager.getInstance().run(new Task.Backgroundable(project,"leetcode.editor.tree",false) { @Override public void run(@NotNull ProgressIndicator progressIndicator) { loadData(question,node,selPath,tree,toolWindow); } }); throw new ExpandVetoException(event); }
Example 2
Source File: TreeSingleChildExpandBehavior.java From weblaf with GNU General Public License v3.0 | 6 votes |
/** * todo 1. Make non-static install/uninstall methods */ @Override public void treeExpanded ( final TreeExpansionEvent event ) { final JTree tree = ( JTree ) event.getSource (); final TreePath expandedPath = event.getPath (); final Object expandedObject = expandedPath.getLastPathComponent (); if ( tree.getModel ().getChildCount ( expandedObject ) == 1 ) { final Object[] parentPath = expandedPath.getPath (); final Object[] path = Arrays.copyOf ( parentPath, parentPath.length + 1 ); path[ parentPath.length ] = tree.getModel ().getChild ( expandedObject, 0 ); tree.expandPath ( new TreePath ( path ) ); } }
Example 3
Source File: WindowsDirectoryChooserUI.java From orbit-image-analysis with GNU General Public License v3.0 | 6 votes |
public void treeExpanded(TreeExpansionEvent event) { // ensure children gets expanded later if (event.getPath() != null) { Object lastElement = event.getPath().getLastPathComponent(); if (lastElement instanceof FileTreeNode && useNodeQueue) { if (((FileTreeNode)lastElement).isLoaded()) { for (Enumeration e = ((FileTreeNode)lastElement).children(); e.hasMoreElements(); ) { //Object node = enum.nextElement(); addToQueue((FileTreeNode)e.nextElement(), tree); } } } } }
Example 4
Source File: Model.java From Luyten with Apache License 2.0 | 6 votes |
@Override public void treeExpanded(final TreeExpansionEvent event) { final TreePath treePath = event.getPath(); final Object expandedTreePathObject = treePath.getLastPathComponent(); if (!(expandedTreePathObject instanceof TreeNode)) { return; } final TreeNode expandedTreeNode = (TreeNode) expandedTreePathObject; if (expandedTreeNode.getChildCount() == 1) { final TreeNode descendantTreeNode = expandedTreeNode.getChildAt(0); if (descendantTreeNode.isLeaf()) { return; } final TreePath nextTreePath = treePath.pathByAddingChild(descendantTreeNode); tree.expandPath(nextTreePath); } }
Example 5
Source File: DNDTree.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
/** Sense node expansion events (the method name is missleading). */ public void treeCollapsed(TreeExpansionEvent tee) { TreePath path = tee.getPath(); //hs_expanded_paths.remove(path); updateInDatabase(path); //Utils.log2("collapsed " + path); }
Example 6
Source File: DataTypeArchiveGTree.java From ghidra with Apache License 2.0 | 5 votes |
@Override public void treeCollapsed(TreeExpansionEvent event) { if (isFiltered()) { return; } TreePath path = event.getPath(); GTreeNode node = (GTreeNode) path.getLastPathComponent(); if ((node instanceof CategoryNode)) { CategoryNode categoryNode = (CategoryNode) node; categoryNode.setChildren(null); } }
Example 7
Source File: ScopeTreeViewPanel.java From consulo with Apache License 2.0 | 5 votes |
@Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { final TreePath path = event.getPath(); if (path == null) return; final PackageDependenciesNode node = (PackageDependenciesNode)path.getLastPathComponent(); node.sortChildren(); ((DefaultTreeModel)myTree.getModel()).reload(node); }
Example 8
Source File: FileSystemTreeImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void treeExpanded(final TreeExpansionEvent event) { if (myTreeBuilder == null || !myTreeBuilder.isNodeBeingBuilt(event.getPath())) return; TreePath path = event.getPath(); DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); if (node.getUserObject() instanceof FileNodeDescriptor) { FileNodeDescriptor nodeDescriptor = (FileNodeDescriptor)node.getUserObject(); final FileElement fileDescriptor = nodeDescriptor.getElement(); final VirtualFile virtualFile = fileDescriptor.getFile(); if (virtualFile != null) { if (!myEverExpanded.contains(virtualFile)) { if (virtualFile instanceof NewVirtualFile) { ((NewVirtualFile)virtualFile).markDirty(); } myEverExpanded.add(virtualFile); } final boolean async = myTreeBuilder.isToBuildChildrenInBackground(virtualFile); if (virtualFile instanceof NewVirtualFile) { RefreshQueue.getInstance().refresh(async, false, null, ModalityState.stateForComponent(myTree), virtualFile); } else { virtualFile.refresh(async, false); } } } }
Example 9
Source File: JcrBrowserTree.java From nextreports-designer with Apache License 2.0 | 5 votes |
public void treeExpanded(TreeExpansionEvent ev) { final TreePath path = ev.getPath(); final Object parentObj = path.getLastPathComponent(); if (parentObj instanceof DBBrowserNode) { startExpandingTree((DBBrowserNode) parentObj, false, null); // expandedPathNames.put(path.toString(), null); } }
Example 10
Source File: DBBrowserTree.java From nextreports-designer with Apache License 2.0 | 5 votes |
public void treeExpanded(TreeExpansionEvent ev) { final TreePath path = ev.getPath(); final Object parentObj = path.getLastPathComponent(); if (parentObj instanceof DBBrowserNode) { startExpandingTree((DBBrowserNode) parentObj, false, null); // expandedPathNames.put(path.toString(), null); } }
Example 11
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@Override public void treeWillExpand(TreeExpansionEvent e) throws ExpandVetoException { TreePath path = e.getPath(); Object o = path.getLastPathComponent(); if (o instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) o; File file = (File) node.getUserObject(); String name = file.getName(); // System.out.println(name); if (!name.isEmpty() && name.codePointAt(0) == '.') { throw new ExpandVetoException(e, "Tree expansion cancelled"); } } }
Example 12
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@Override public void treeWillExpand(TreeExpansionEvent e) throws ExpandVetoException { TreePath path = e.getPath(); Object o = path.getLastPathComponent(); if (o instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) o; File file = (File) node.getUserObject(); if (file.isFile()) { throw new ExpandVetoException(e, "Tree expansion cancelled"); } } }
Example 13
Source File: ObjectTree.java From bigtable-sql with Apache License 2.0 | 5 votes |
public void treeExpanded(TreeExpansionEvent evt) { // Get the node to be expanded. final TreePath path = evt.getPath(); final Object parentObj = path.getLastPathComponent(); if (parentObj instanceof ObjectTreeNode) { startExpandingTree((ObjectTreeNode)parentObj, false, null, false); _expandedPathNames.put(path.toString(), null); } }
Example 14
Source File: FileTree.java From stendhal with GNU General Public License v2.0 | 5 votes |
@Override public void treeExpanded(final TreeExpansionEvent evt) { // The expanded path final TreePath path = evt.getPath(); // The tree final JTree tree = (JTree) evt.getSource(); // Get the last component of the path and // arrange to have it fully populated. final FileTreeNode node = (FileTreeNode) path.getLastPathComponent(); if (node.populateDirectories(true)) { ((DefaultTreeModel) tree.getModel()).nodeStructureChanged(node); } }
Example 15
Source File: InspectorWindow.java From megan-ce with GNU General Public License v3.0 | 5 votes |
/** * Invoked whenever a node in the tree is about to be expanded. */ public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { if (inspectorWindow.isLocked()) { if (dir.getDocument().getProgressListener() != null) dir.getDocument().getProgressListener().setUserCancelled(true); throw new ExpandVetoException(event); } final TreePath path = event.getPath(); final NodeBase node = (NodeBase) path.getLastPathComponent(); if (node.getChildCount() > 0) { // has already been expanded if (node.isCompleted()) return; else { int result = JOptionPane.showConfirmDialog(inspectorWindow.getFrame(), "List of children incomplete, re-fetch?", "Re-fetch", JOptionPane.YES_NO_CANCEL_OPTION); if (result == JOptionPane.NO_OPTION) return; else if (result == JOptionPane.CANCEL_OPTION) throw new ExpandVetoException(event); else // remove all children to trigger re-download node.removeAllChildren(); } } if (node instanceof TopLevelNode) { inspectorWindow.addChildren((TopLevelNode) node); } else if (node instanceof ReadHeadLineNode) { inspectorWindow.addChildren((ReadHeadLineNode) node, path.getPathComponent(1).toString()); } if (node instanceof ReadDataHeadLineNode) { inspectorWindow.addChildren((ReadDataHeadLineNode) node); } else if (node instanceof MatchHeadLineNode) { inspectorWindow.addChildren((MatchHeadLineNode) node); } }
Example 16
Source File: TreeView.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { // prepare wait cursor and optionally show it TreePath path = event.getPath(); prepareWaitCursor(DragDropUtilities.secureFindNode(path.getLastPathComponent())); }
Example 17
Source File: LaunchSaver.java From osp with GNU General Public License v3.0 | 4 votes |
public void treeWillExpand(TreeExpansionEvent e) { TreePath path = e.getPath(); set(path, false); }
Example 18
Source File: DebuggingViewComponent.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void treeExpanded(TreeExpansionEvent event) { TreePath path = event.getPath(); checkIfWeShouldScrollToCurrentThread(path); refreshView(); }
Example 19
Source File: DNDTree.java From TrakEM2 with GNU General Public License v3.0 | 4 votes |
public void treeExpanded(TreeExpansionEvent tee) { TreePath path = tee.getPath(); //hs_expanded_paths.add(path); updateInDatabase(path); //Utils.log2("expanded " + path); }
Example 20
Source File: EventBroadcaster.java From netbeans with Apache License 2.0 | 4 votes |
/** Translates tree expansion event into an appropriate TableModelEvent * indicating the number of rows added/removed at the appropriate index */ private TableModelEvent translateEvent (TreeExpansionEvent e, boolean expand) { //PENDING: This code should be profiled - the descendent paths search //is not cheap, and it might be less expensive (at least if the table //does not have expensive painting logic) to simply fire a generic //"something changed" table model event and be done with it. TreePath path = e.getPath(); //Add one because it is a child of the row. int firstRow = getLayout().getRowForPath(path) + 1; if (firstRow == -1) { //This does not mean nothing happened, it may just be that we are //a large model tree, and the FixedHeightLayoutCache says the //change happened in a row that is not showing. //TODO: Just to make the table scrollbar adjust itself appropriately, //we may want to look up the number of children in the model and //fire an event that says that that many rows were added. Waiting //to see if anybody actually will use this (i.e. fires changes in //offscreen nodes as a normal part of usage return null; } //Get all the expanded descendants of the path that was expanded/collapsed TreePath[] paths = getTreePathSupport().getExpandedDescendants(path); //Start with the number of children of whatever was expanded/collapsed int count = getTreeModel().getChildCount(path.getLastPathComponent()); if (count == 0) { return null; } //Iterate any of the expanded children, adding in their child counts for (int i=0; i < paths.length; i++) { count += getTreeModel().getChildCount(paths[i].getLastPathComponent()); } //Now we can calculate the last row affected for real int lastRow = firstRow + count -1; //Construct a table model event reflecting this data TableModelEvent result = new TableModelEvent (getModel(), firstRow, lastRow, TableModelEvent.ALL_COLUMNS, expand ? TableModelEvent.INSERT : TableModelEvent.DELETE); return result; }