javax.swing.tree.ExpandVetoException Java Examples

The following examples show how to use javax.swing.tree.ExpandVetoException. 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: EventBroadcaster.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** 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;
    }
}
 
Example #2
Source File: InspectionTree.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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()));
      }
    });
  }
}
 
Example #3
Source File: TreeWillListener.java    From leetcode-editor with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
@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 #5
Source File: TreePathSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #6
Source File: EventBroadcaster.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** 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;
}
 
Example #7
Source File: EventBroadcaster.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** 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;
}
 
Example #8
Source File: TreeView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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 #9
Source File: TranslationTree.java    From i18n-editor with MIT License 5 votes vote down vote up
@Override
 	public void treeWillCollapse(TreeExpansionEvent e) throws ExpandVetoException {
// Prevent root key from being collapsed
 		if (e.getPath().getPathCount() == 1) {
 			throw new ExpandVetoException(e);        			
 		}
 	}
 
Example #10
Source File: TreePathSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #11
Source File: JTreeOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example #12
Source File: JTreeOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example #13
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
@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 #14
Source File: InspectorWindow.java    From megan-ce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 #15
Source File: InspectorWindow.java    From megan-ce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example #16
Source File: ViewerJTree.java    From megan-ce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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());
}
 
Example #17
Source File: ScopeTreeViewPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 #18
Source File: Tree.java    From jsqsh with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void treeWillCollapse(final TreeExpansionEvent event)
        throws ExpandVetoException {

}
 
Example #19
Source File: ProfilerTreeTable.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
    Object expanding = event.getPath().getLastPathComponent();
    if (expanding instanceof TreeNode) nodeExpanding((TreeNode)expanding);
}
 
Example #20
Source File: ProfilerTreeTable.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
    Object expanding = event.getPath().getLastPathComponent();
    if (expanding instanceof TreeNode) nodeExpanding((TreeNode)expanding);
}
 
Example #21
Source File: AbstractReportTree.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void treeWillExpand( final TreeExpansionEvent event ) throws ExpandVetoException {
  addExpandedNode( getRowForPath( event.getPath() ) );
}
 
Example #22
Source File: AbstractReportTree.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void treeWillCollapse( final TreeExpansionEvent event ) throws ExpandVetoException {
  removeExpandedNode( getRowForPath( event.getPath() ) );
}
 
Example #23
Source File: TreeView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void treeWillCollapse(TreeExpansionEvent event)
throws ExpandVetoException {
}
 
Example #24
Source File: InspectionTree.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
  InspectionTreeNode node = (InspectionTreeNode)event.getPath().getLastPathComponent();
  myExpandedUserObjects.remove(node.getUserObject());
}
 
Example #25
Source File: ProfilerTreeTable.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
    Object collapsing = event.getPath().getLastPathComponent();
    if (collapsing instanceof TreeNode) nodeCollapsing((TreeNode)collapsing);
}
 
Example #26
Source File: TranslationTree.java    From i18n-editor with MIT License 4 votes vote down vote up
@Override
public void treeWillExpand(TreeExpansionEvent e) throws ExpandVetoException {}
 
Example #27
Source File: ProfilerTreeTable.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
    Object collapsing = event.getPath().getLastPathComponent();
    if (collapsing instanceof TreeNode) nodeCollapsing((TreeNode)collapsing);
}
 
Example #28
Source File: ScopeTreeViewPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
}
 
Example #29
Source File: ImageProviderNoop.java    From orbit-image-analysis with GNU General Public License v3.0 2 votes vote down vote up
@Override
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {

}
 
Example #30
Source File: ImageProviderNoop.java    From orbit-image-analysis with GNU General Public License v3.0 2 votes vote down vote up
@Override
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {

}