/** Expand a path. Notifies the layout cache of the change, * stores the expanded path info (so reexpanding a parent node also reexpands * this path if a parent node containing it is later collapsed). Fires * TreeWillExpand and TreeExpansion events. */ public void expandPath (TreePath path) { if (Boolean.TRUE.equals(expandedPaths.get(path))) { //It's already expanded, don't waste cycles firing bogus events return; } TreeExpansionEvent e = new TreeExpansionEvent (this, path); try { fireTreeWillExpand(e, true); expandedPaths.put(path, Boolean.TRUE); layout.setExpandedState(path, true); fireTreeExpansion(e, true); } catch (ExpandVetoException eve) { fireTreeExpansionVetoed (e, eve); } }
/** Collapse a path. Notifies the layout cache of the change, * stores the expanded path info (so reexpanding a parent node also reexpands * this path if a parent node containing it is later collapsed). Fires * TreeWillExpand and TreeExpansion events. */ public void collapsePath (TreePath path) { if (Boolean.FALSE.equals(expandedPaths.get(path))) { //It's already collapsed, don't waste cycles firing bogus events return; } TreeExpansionEvent e = new TreeExpansionEvent (this, path); try { fireTreeWillExpand(e, false); expandedPaths.put(path, Boolean.FALSE); layout.setExpandedState(path, false); fireTreeExpansion(e, false); } catch (ExpandVetoException eve) { fireTreeExpansionVetoed (e, eve); } }