Java Code Examples for javax.swing.tree.ExpandVetoException

The following are top voted examples for showing how to use javax.swing.tree.ExpandVetoException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: EventBroadcaster.java   Source Code and License 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
Project: javify   File: JTree.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 3
Project: intellij-ce-playground   File: InspectionTree.java   Source Code and License 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 4
Project: jvm-stm   File: JTree.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 5
Project: mindraider   File: TrashJPanel.java   Source Code and License 6 votes vote down vote up
/**
 * @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()); } } }
     */
}
 
Example 6
Project: DataCleaner   File: SchemaTree.java   Source Code and License 6 votes vote down vote up
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();
    }
}
 
Example 7
Project: cn1   File: JTree.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 8
Project: JamVM-PH   File: JTree.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 9
Project: tools-idea   File: InspectionTree.java   Source Code and License 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 10
Project: classpath   File: JTree.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 11
Project: freeVM   File: JTree.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 12
Project: freeVM   File: JTree.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 13
Project: consulo   File: InspectionTree.java   Source Code and License 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 14
Project: incubator-netbeans   File: TreeView.java   Source Code and License 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 15
Project: incubator-netbeans   File: EventBroadcaster.java   Source Code and License 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 16
Project: incubator-netbeans   File: EventBroadcaster.java   Source Code and License 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 17
Project: incubator-netbeans   File: TreePathSupport.java   Source Code and License 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 18
Project: incubator-netbeans   File: TreePathSupport.java   Source Code and License 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 19
Project: openjdk-jdk10   File: JTreeOperator.java   Source Code and License 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 20
Project: openjdk-jdk10   File: JTreeOperator.java   Source Code and License 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 21
Project: openjdk9   File: JTreeOperator.java   Source Code and License 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 22
Project: openjdk9   File: JTreeOperator.java   Source Code and License 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 23
Project: megan-ce   File: ViewerJTree.java   Source Code and License 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 24
Project: megan-ce   File: InspectorWindow.java   Source Code and License 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 25
Project: megan-ce   File: InspectorWindow.java   Source Code and License 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 26
Project: javify   File: JTree.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 27
Project: javify   File: JTree.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 28
Project: javify   File: JTree.java   Source Code and License 5 votes vote down vote up
public void collapsePath(TreePath path)
{
  try
    {
      fireTreeWillCollapse(path);
    }
  catch (ExpandVetoException ev)
    {
      // We do nothing if attempt has been vetoed.
    }
  setExpandedState(path, false);
  fireTreeCollapsed(path);
}
 
Example 29
Project: intellij-ce-playground   File: ScopeTreeViewPanel.java   Source Code and License 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 30
Project: jvm-stm   File: JTree.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 31
Project: jvm-stm   File: JTree.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 32
Project: jvm-stm   File: JTree.java   Source Code and License 5 votes vote down vote up
public void collapsePath(TreePath path)
{
  try
    {
      fireTreeWillCollapse(path);
    }
  catch (ExpandVetoException ev)
    {
      // We do nothing if attempt has been vetoed.
    }
  setExpandedState(path, false);
  fireTreeCollapsed(path);
}
 
Example 33
Project: smoothcsv   File: SqlTableList.java   Source Code and License 5 votes vote down vote up
@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();
  }
}
 
Example 34
Project: i18n-editor   File: TranslationTree.java   Source Code and 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 35
Project: KSPSavefileEditor   File: NodeTreeModel.java   Source Code and License 5 votes vote down vote up
@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);
		}
	}
}
 
Example 36
Project: cats   File: PreferencePanel.java   Source Code and License 5 votes vote down vote up
@Override
public void treeWillCollapse(TreeExpansionEvent event)
		throws ExpandVetoException {
	DefaultMutableTreeNode node = (DefaultMutableTreeNode)
       preferenceTree.getLastSelectedPathComponent();
	
	if(node == top){
		throw new ExpandVetoException(event);
	}
}
 
Example 37
Project: cn1   File: JTree.java   Source Code and License 5 votes vote down vote up
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);
    }
}
 
Example 38
Project: cn1   File: JTree.java   Source Code and License 5 votes vote down vote up
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);
    }
}
 
Example 39
Project: JamVM-PH   File: JTree.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 40
Project: JamVM-PH   File: JTree.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 41
Project: JamVM-PH   File: JTree.java   Source Code and License 5 votes vote down vote up
public void collapsePath(TreePath path)
{
  try
    {
      fireTreeWillCollapse(path);
    }
  catch (ExpandVetoException ev)
    {
      // We do nothing if attempt has been vetoed.
    }
  setExpandedState(path, false);
  fireTreeCollapsed(path);
}
 
Example 42
Project: K-scope   File: JEntireRowTree.java   Source Code and License 5 votes vote down vote up
/**
 * ツリーを開く際に呼ばれるイベント
 */
@Override
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
    TreePath path = event.getPath();
    Object obj = path.getLastPathComponent(); //一番末端の(今回開こうとしている)ノード
    if (obj instanceof FilterTreeNode) {
        int depth = ((FilterTreeNode)obj).getDepth();
        if (depth > 0) {
            // ((FilterTreeNode)obj).removeAllChildren();
            // System.out.println("expand=" + obj + ", depth=" + depth);
            LanguageService service = new LanguageService();
            int writedepth = 0;
            if (((FilterTreeNode)obj).getUserObject() instanceof ProcedureUsage) {
                ProcedureUsage call = (ProcedureUsage)((FilterTreeNode)obj).getUserObject();
                service.writeProcedureUsage(call, ((FilterTreeNode)obj), true, writedepth);
            }
            else if (((FilterTreeNode)obj).getUserObject() instanceof Selection) {
                Selection select = (Selection)((FilterTreeNode)obj).getUserObject();
                service.writeSelection(select, ((FilterTreeNode)obj), true, writedepth);
            }
            else if (((FilterTreeNode)obj).getUserObject() instanceof Block) {
                Block block = (Block)((FilterTreeNode)obj).getUserObject();
                service.writeBlocks(block, ((FilterTreeNode)obj), true, writedepth);
            }
            else if (((FilterTreeNode)obj).getUserObject() instanceof Procedure) {
                Procedure proc = (Procedure)((FilterTreeNode)obj).getUserObject();
                service.writeProcedure(proc, ((FilterTreeNode)obj), true, writedepth);
            }
            ((FilterTreeNode)obj).setDepth(writedepth);
        }
    }

}
 
Example 43
Project: tools-idea   File: ScopeTreeViewPanel.java   Source Code and License 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 44
Project: classpath   File: JTree.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 45
Project: classpath   File: JTree.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 46
Project: classpath   File: JTree.java   Source Code and License 5 votes vote down vote up
public void collapsePath(TreePath path)
{
  try
    {
      fireTreeWillCollapse(path);
    }
  catch (ExpandVetoException ev)
    {
      // We do nothing if attempt has been vetoed.
    }
  setExpandedState(path, false);
  fireTreeCollapsed(path);
}
 
Example 47
Project: freeVM   File: JTree.java   Source Code and License 5 votes vote down vote up
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);
    }
}
 
Example 48
Project: freeVM   File: JTree.java   Source Code and License 5 votes vote down vote up
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);
    }
}
 
Example 49
Project: freeVM   File: JTree.java   Source Code and License 5 votes vote down vote up
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);
    }
}
 
Example 50
Project: freeVM   File: JTree.java   Source Code and License 5 votes vote down vote up
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);
    }
}
 
Example 51
Project: TreeTable   File: TreeTable.java   Source Code and License 5 votes vote down vote up
private void fireTreeWillExpandEvent(TreePath path, boolean exp) throws ExpandVetoException {
    TreeExpansionEvent e = new TreeExpansionEvent(this, path);
    Object[] listeners = listenerList.getListenerList();
    for (int i = listeners.length-2; i>=0; i-=2) {
        if (listeners[i]==TreeWillExpandListener.class) {
            TreeWillExpandListener lis = (TreeWillExpandListener)listeners[i+1];
            if (exp) {
                lis.treeWillExpand(e);
            } else {
                lis.treeWillCollapse(e);
            }
        }
    }
}
 
Example 52
Project: consulo   File: ScopeTreeViewPanel.java   Source Code and License 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 53
Project: consulo-java   File: ClassesScopeTreeStructureExpander.java   Source Code and License 5 votes vote down vote up
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
  final TreePath path = event.getPath();
  if (path == null) return;
  final DefaultMutableTreeNode node = (PackageDependenciesNode)path.getLastPathComponent();
  if (node instanceof DirectoryNode) {
    Set<FileNode> fileNodes = null;
    for (int i = node.getChildCount() - 1; i >= 0; i--) {
      final TreeNode childNode = node.getChildAt(i);
      if (childNode instanceof ClassNode) {
        final ClassNode classNode = (ClassNode)childNode;
        final PsiFile containingFile = classNode.getContainingFile();
        if (containingFile != null && containingFile.isValid()) {
          if (fileNodes == null) {
            fileNodes = new HashSet<FileNode>();
          }
          fileNodes.add(new FileNode(containingFile.getVirtualFile(), myProject, true));
        }
        node.remove(classNode);
      }
    }
    if (fileNodes != null) {
      for (FileNode fileNode : fileNodes) {
        node.add(fileNode);
      }
    }
    TreeUtil.sort(node, getNodeComparator());
    final Object source = event.getSource();
    if (source instanceof JTree) {
      ((DefaultTreeModel)((JTree)source).getModel()).reload(node);
    }
  }
}
 
Example 54
Project: incubator-netbeans   File: TreeView.java   Source Code and License 4 votes vote down vote up
@Override
public void treeWillCollapse(TreeExpansionEvent event)
throws ExpandVetoException {
}
 
Example 55
Project: RxJava2Swing   File: TreeWillExpandEventObservable.java   Source Code and License 4 votes vote down vote up
@Override
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
    actual.onNext(event);
}
 
Example 56
Project: RxJava2Swing   File: TreeWillExpandEventObservable.java   Source Code and License 4 votes vote down vote up
@Override
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
    actual.onNext(event);
}
 
Example 57
Project: intellij-ce-playground   File: InspectionTree.java   Source Code and License 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 58
Project: intellij-ce-playground   File: ScopeTreeViewPanel.java   Source Code and License 4 votes vote down vote up
@Override
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {}
 
Example 59
Project: swingx   File: TreeWillExpandReport.java   Source Code and License 4 votes vote down vote up
public void treeWillExpand(TreeExpansionEvent e) throws ExpandVetoException {
    expandedEvents.add(0, e);
    allEvents.add(0, e);
    if (veto) throw new ExpandVetoException(e, "vetoed expand");
}
 
Example 60
Project: swingx   File: TreeWillExpandReport.java   Source Code and License 4 votes vote down vote up
public void treeWillCollapse(TreeExpansionEvent e) throws ExpandVetoException {
    collapsedEvents.add(0, e);
    allEvents.add(0, e);
    if (veto) throw new ExpandVetoException(e, "vetoed collapse");
    
}