Example usage for javax.swing JTree removeTreeExpansionListener

List of usage examples for javax.swing JTree removeTreeExpansionListener

Introduction

In this page you can find the example usage for javax.swing JTree removeTreeExpansionListener.

Prototype

public void removeTreeExpansionListener(TreeExpansionListener tel) 

Source Link

Document

Removes a listener for TreeExpansion events.

Usage

From source file:org.kepler.objectmanager.library.LibraryManager.java

/**
 * Refresh and redraw any JTrees that the LibraryManager is keeping track
 * of./*from w ww. ja va 2s  .c o m*/
 * 
 *@exception IllegalActionException
 *                Description of the Exception
 */
public void refreshJTrees() throws IllegalActionException {
    if (isDebugging) {
        log.debug("refresh");
    }

    // Iterate over all the registered JTrees and reset their models.
    //Iterator<WeakReference> treeItt = _trees.iterator();

    int size = _trees.size();
    int i = 0;
    while (i < size) {
        WeakReference<JTree> wf = _trees.elementAt(i);
        JTree ptree = (JTree) wf.get();
        if (ptree == null) {
            _trees.remove(wf);
            size--;
        } else {
            ptree.setModel(getTreeModel());

            // stop listening for expansion events since we are going to
            // expand the paths and do not want to modify the list
            ptree.removeTreeExpansionListener(this);

            // expand all the paths that were previously expanded
            final List<TreePath> expansions = _treeExpansionMap.get(ptree);
            for (TreePath path : expansions) {
                //System.out.println("expanding " + path);
                ptree.expandPath(path);
            }

            // start listening again for expansion events
            ptree.addTreeExpansionListener(this);

            /*
            EntityTreeModel etm = (EntityTreeModel) ptree.getModel();
                    
            // Of course this would be easier if
            // ptolemy.vergil.tree.EntityTreeModel
            // had a reload method similar to DefaultTreeModel
            // that did this for us
            // TODO etm.reload()
                    
            ArrayList<NamedObj> path = new ArrayList<NamedObj>();
            path.add(0, (NamedObj) etm.getRoot());
            TreePath tp = new TreePath(path);
            etm.valueForPathChanged(tp, etm.getRoot());
            */
            i++;
        }
    }
}