private <T extends EventListener> void addListener(Class<T> cls, T l) { if (l == null) return; int count = listenerList.getListenerCount(cls); listenerList.add(cls, l); if (count == 0) { if (cls == TreeExpansionListener.class) { tree.addTreeExpansionListener(adapter); } else if (cls == TreeWillExpandListener.class) { tree.addTreeWillExpandListener(adapter); } else if (cls == TreeTableMouseListener.class) { hasTreeTableMouseListener = true; } else if (cls == TreeTableMouseMotionListener.class) { hasTreeTableMouseMotionListener = true; } } }
private <T extends EventListener> void removeListener(Class<T> cls, T l) { if (l == null) return; listenerList.remove(cls, l); int count = listenerList.getListenerCount(cls); if (count == 0) { if (cls == TreeExpansionListener.class) { tree.removeTreeExpansionListener(adapter); } else if (cls == TreeWillExpandListener.class) { tree.removeTreeWillExpandListener(adapter); } else if (cls == TreeTableMouseListener.class) { hasTreeTableMouseListener = false; } else if (cls == TreeTableMouseMotionListener.class) { hasTreeTableMouseMotionListener = false; } } }
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.addTreeWillExpandListener(TreeWillExpandListener)} * through queue */ public void addTreeWillExpandListener(final TreeWillExpandListener treeWillExpandListener) { runMapping(new MapVoidAction("addTreeWillExpandListener") { @Override public void map() { ((JTree) getSource()).addTreeWillExpandListener(treeWillExpandListener); } }); }
/** * Maps * {@code JTree.removeTreeWillExpandListener(TreeWillExpandListener)} * through queue */ public void removeTreeWillExpandListener(final TreeWillExpandListener treeWillExpandListener) { runMapping(new MapVoidAction("removeTreeWillExpandListener") { @Override public void map() { ((JTree) getSource()).removeTreeWillExpandListener(treeWillExpandListener); } }); }
/** * 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); }
@Override public void actionPerformed(ActionEvent e) { TreePath rootPath = new TreePath(model.getRoot()); DummyNode dummyTree = new DummyNode(rootPath.getPathComponent(0).toString(), tree.isExpanded(rootPath)); buildDummyTree(dummyTree, rootPath); // cannot determine listener in constructor because it's not initialized yet TreeListener listener = (TreeListener) tree.getListeners(TreeWillExpandListener.class)[0]; listener.setShowErrorMessages(false); expandTree(dummyTree, rootPath); listener.setShowErrorMessages(true); }
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); } }
public void setUI(TreeTableUI ui) { boolean addExpandLis = false; boolean addWillExpandLis = false; if (table != null) { table.removePropertyChangeListener(adapter); tree.removePropertyChangeListener(adapter); int lisCount = listenerList.getListenerCount(TreeExpansionListener.class); if (lisCount > 0) { tree.removeTreeExpansionListener(adapter); addExpandLis = true; } lisCount = listenerList.getListenerCount(TreeWillExpandListener.class); if (lisCount > 0) { tree.removeTreeWillExpandListener(adapter); addWillExpandLis = true; } getSelectionModel().removeTreeSelectionListener(adapter); if (getAutoCreateColumnsFromModel()) columnModel = null; updateUIProperties(); } super.setUI(ui); tree = getUI().getTreeInterface(this); table = getUI().getTableInterface(this); // if (columnModel == null) { // columnModel = table.getColumnModel(); // int hc = getTreeColumnModel().getHierarchicalColumn(); // if (hc >= 0) // columnModel.getColumn(hc).setPreferredWidth(150); // } getSelectionModel().addTreeSelectionListener(adapter); table.addPropertyChangeListener(adapter); tree.addPropertyChangeListener(adapter); if (addExpandLis) tree.addTreeExpansionListener(adapter); if (addWillExpandLis) tree.addTreeWillExpandListener(adapter); if (getAutoCreateColumnHeader() && isDisplayable()) configureEnclosingScrollPane(); }
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); } } } }
public void addTreeWillExpandListener(TreeWillExpandListener tel) { list.add(TreeWillExpandListener.class, tel); }
public void removeTreeWillExpandListener(TreeWillExpandListener tel) { list.remove(TreeWillExpandListener.class, tel); }
public TreeWillExpandListener[] getTreeWillExpandListeners() { return list.getListeners(TreeWillExpandListener.class); }
/** * Returns all added <code>TreeWillExpandListener</code> objects. * * @return an array of listeners */ public TreeWillExpandListener[] getTreeWillExpandListeners() { return (TreeWillExpandListener[]) getListeners(TreeWillExpandListener.class); }
public void addTreeWillExpandListener(TreeWillExpandListener l) { listenerList.add(TreeWillExpandListener.class, l); }
public void removeTreeWillExpandListener(TreeWillExpandListener l) { listenerList.remove(TreeWillExpandListener.class, l); }
public TreeWillExpandListener[] getTreeWillExpandListeners() { return listenerList.getListeners(TreeWillExpandListener.class); }