/** Messaged if the tree expansion event (for which we will have already * constructed a TableModelEvent) was vetoed; disposes of the constructed * TableModelEvent in that circumstance. */ @Override public void treeExpansionVetoed(TreeExpansionEvent event, ExpandVetoException exception) { assert SwingUtilities.isEventDispatchThread(); log ("treeExpansionVetoed", exception); //Make sure the event that was vetoed is the one we're interested in if (event == inProgressEvent) { //If so, delete the expansion event we thought we were going //to use in treeExpanded/treeCollapsed, so that it doesn't //stick around forever holding references to objects from the //model pendingExpansionEvent = null; inProgressEvent = null; } }
public void expandPath(TreePath path) { // Don't expand if path is null // or is already expanded. if (path == null || isExpanded(path)) return; try { fireTreeWillExpand(path); } catch (ExpandVetoException ev) { // We do nothing if attempt has been vetoed. } setExpandedState(path, true); fireTreeExpanded(path); }
@Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { final InspectionTreeNode node = (InspectionTreeNode)event.getPath().getLastPathComponent(); final Object userObject = node.getUserObject(); //TODO: never re-sort if (node.isValid() && !myExpandedUserObjects.contains(userObject)) { sortChildren(node); nodeStructureChanged(node); } myExpandedUserObjects.add(userObject); // Smart expand if (node.getChildCount() == 1) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { expandPath(new TreePath(node.getPath())); } }); } }
/** * @see javax.swing.event.TreeWillExpandListener#treeWillExpand(javax.swing.event.TreeExpansionEvent) */ public void treeWillExpand(TreeExpansionEvent e) throws ExpandVetoException { logger.debug("Tree will expand " + e.getPath()); /* * DefaultMutableTreeNode node = (DefaultMutableTreeNode) * tree.getLastSelectedPathComponent(); if (node == null) { return; } * logger.debug(""+node.getPath()[node.getLevel()]); // buttons * disabling switch(node.getLevel()) { case LEVEL_FOLDERS: // disconnect * childrens from the node Enumeration enumeration=node.children(); // * delete nodes itself while (enumeration.hasMoreElements()) { Object * object=enumeration.nextElement(); * treeNodeToResourceUriMap.remove(object); * treeModel.removeNodeFromParent((MutableTreeNode)object); } // get * folder URI logger.debug("Expanding folder: * "+treeNodeToResourceUriMap.get(node)); FolderResource folder =new * FolderResource(MindRaider.folderCustodian.get((String)treeNodeToResourceUriMap.get(node))); * String[] notebookUris=folder.getNotebookUris(); if (notebookUris != * null) { for (int i= 0; i < notebookUris.length; i++) { * NotebookResource notebook=new * NotebookResource(MindRider.notebookCustodian.get(notebookUris[i])); * addNotebookNode(node,notebook.resource.metadata.uri.toASCIIString(),notebook.getLabel()); } } } */ }
public void treeWillExpand(final TreeExpansionEvent event) throws ExpandVetoException { final TreePath path = event.getPath(); final DefaultMutableTreeNode lastTreeNode = (DefaultMutableTreeNode) path.getLastPathComponent(); SwingWorker<?, ?> worker = null; if (lastTreeNode.getChildCount() == 1) { final DefaultMutableTreeNode firstChildNode = (DefaultMutableTreeNode) lastTreeNode.getChildAt(0); if (firstChildNode.getUserObject() == LOADING_TABLES_STRING) { // Load a schema's tables worker = new LoadTablesSwingWorker(lastTreeNode); } else if (firstChildNode.getUserObject() == LOADING_COLUMNS_STRING) { // Load a table's columns worker = new LoadColumnsSwingWorker(path, lastTreeNode); } } if (worker != null) { worker.execute(); } }
private void doSetExpandedState(TreePath path, boolean state) { if (path == null) { return; } doSetExpandedState(path.getParentPath(), true); if (isExpanded(path) == state) { return; } try { if (state) { fireTreeWillExpand(path); } else { fireTreeWillCollapse(path); } } catch (ExpandVetoException e) { return; } togglePaths.put(path, Boolean.valueOf(state)); if (state) { fireTreeExpanded(path); } else { fireTreeCollapsed(path); } }
@Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { // prepare wait cursor and optionally show it TreePath path = event.getPath(); prepareWaitCursor(DragDropUtilities.secureFindNode(path.getLastPathComponent())); }
/** Receives a TreeWillCollapse event and constructs a TableModelEvent * based on the pending changes while the model still reflects the unchanged * state */ @Override public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { assert SwingUtilities.isEventDispatchThread(); log ("treeWillCollapse", event); //Construct the TableModelEvent here, before data structures have //changed. We will fire it from TreeCollapsed if the change is //not vetoed. pendingExpansionEvent = translateEvent (event, false); log ("treeWillCollapse generated ", pendingExpansionEvent); inProgressEvent = event; }
/** Receives a TreeWillExpand event and constructs a TableModelEvent * based on the pending changes while the model still reflects the unchanged * state */ @Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { assert SwingUtilities.isEventDispatchThread(); log ("treeWillExpand", event); //Construct the TableModelEvent here, before data structures have //changed. We will fire it from TreeExpanded if the change is not //vetoed pendingExpansionEvent = translateEvent (event, true); log ("treeWillExpand generated", pendingExpansionEvent); inProgressEvent = event; }
private void fireTreeWillExpand (TreeExpansionEvent e, boolean expanded) throws ExpandVetoException { int size = weListeners.size(); TreeWillExpandListener[] listeners = new TreeWillExpandListener[size]; synchronized (this) { listeners = weListeners.toArray(listeners); } for (int i=0; i < listeners.length; i++) { if (expanded) { listeners[i].treeWillExpand(e); } else { listeners[i].treeWillCollapse(e); } } }
private void fireTreeExpansionVetoed (TreeExpansionEvent e, ExpandVetoException ex) { int size = weListeners.size(); TreeWillExpandListener[] listeners = new TreeWillExpandListener[size]; synchronized (this) { listeners = weListeners.toArray(listeners); } for (int i=0; i < listeners.length; i++) { if (listeners[i] instanceof ExtTreeWillExpandListener) { ((ExtTreeWillExpandListener) listeners[i]).treeExpansionVetoed(e, ex); } } }
/** * Maps {@code JTree.fireTreeWillCollapse(TreePath)} through queue */ public void fireTreeWillCollapse(final TreePath treePath) { runMapping(new MapVoidAction("fireTreeWillCollapse") { @Override public void map() throws ExpandVetoException { ((JTree) getSource()).fireTreeWillCollapse(treePath); } }); }
/** * Maps {@code JTree.fireTreeWillExpand(TreePath)} through queue */ public void fireTreeWillExpand(final TreePath treePath) { runMapping(new MapVoidAction("fireTreeWillExpand") { @Override public void map() throws ExpandVetoException { ((JTree) getSource()).fireTreeWillExpand(treePath); } }); }
/** * Invoked whenever a node in the tree is about to be expanded. */ public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { if (classificationViewer.isLocked()) { throw new ExpandVetoException(event); } jTree.addChildren((ViewerJTree.MyJTreeNode) event.getPath().getLastPathComponent()); }
/** * Invoked whenever a node in the tree is about to be collapsed. */ public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { if (inspectorWindow.isLocked()) { if (dir.getDocument().getProgressListener() != null) dir.getDocument().getProgressListener().setUserCancelled(true); throw new ExpandVetoException(event); } }
/** * 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); } }
/** * Notifies all listeners that the tree will collapse. * * @param path the path to the node that will collapse */ public void fireTreeWillCollapse(TreePath path) throws ExpandVetoException { TreeExpansionEvent event = new TreeExpansionEvent(this, path); TreeWillExpandListener[] listeners = getTreeWillExpandListeners(); for (int index = 0; index < listeners.length; ++index) listeners[index].treeWillCollapse(event); }
/** * Notifies all listeners that the tree will expand. * * @param path the path to the node that will expand */ public void fireTreeWillExpand(TreePath path) throws ExpandVetoException { TreeExpansionEvent event = new TreeExpansionEvent(this, path); TreeWillExpandListener[] listeners = getTreeWillExpandListeners(); for (int index = 0; index < listeners.length; ++index) listeners[index].treeWillExpand(event); }
public void collapsePath(TreePath path) { try { fireTreeWillCollapse(path); } catch (ExpandVetoException ev) { // We do nothing if attempt has been vetoed. } setExpandedState(path, false); fireTreeCollapsed(path); }
@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); }
@Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { TreePath path = event.getPath(); Object obj = path.getLastPathComponent(); if (obj instanceof AbstractTreeNode) { AbstractTreeNode node = (AbstractTreeNode) obj; node.beforeExpand(); } }
@Override public void treeWillCollapse(TreeExpansionEvent e) throws ExpandVetoException { // Prevent root key from being collapsed if (e.getPath().getPathCount() == 1) { throw new ExpandVetoException(e); } }
@Override public void treeWillExpand(TreeExpansionEvent e) throws ExpandVetoException { TreePath tp = e.getPath(); if(tp!=null){ TreeBaseNode lpc = (TreeBaseNode) tp.getLastPathComponent(); if(lpc!=null){ lpc.isExpanded(true); } } }
@Override public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { DefaultMutableTreeNode node = (DefaultMutableTreeNode) preferenceTree.getLastSelectedPathComponent(); if(node == top){ throw new ExpandVetoException(event); } }
public void fireTreeWillExpand(TreePath path) throws ExpandVetoException { TreeWillExpandListener[] listeners = getTreeWillExpandListeners(); if (listeners.length == 0) { return; } TreeExpansionEvent event = new TreeExpansionEvent(this, path); for (TreeWillExpandListener element : listeners) { element.treeWillExpand(event); } }
public void fireTreeWillCollapse(TreePath path) throws ExpandVetoException { TreeWillExpandListener[] listeners = getTreeWillExpandListeners(); if (listeners.length == 0) { return; } TreeExpansionEvent event = new TreeExpansionEvent(this, path); for (TreeWillExpandListener element : listeners) { element.treeWillCollapse(event); } }