/** * Generate events specific to the user actions and trigger the internal * management of the tree. * * @param parent the parent node of the changed nodes (rename, add, remove) * @param indices the indexes of the changed nodes * @param nodes the affected nodes; the nodes which are changed * @param action the action related to the node: rename, add, remove */ public void fireTreeStructureChanged(CustomTreeNode parent, int[] indices, Object[] nodes, TreeActions action) { TreeModelEvent eventInsRem = new TreeModelEvent(this, parent.getPath(), indices, nodes); TreeModelEvent eventStructChange = new TreeModelEvent(this, new Object[]{parent}); for (TreeModelListener lis : treeModelListeners) { switch (action) { case NODE_RENAMED: lis.treeNodesChanged(eventInsRem); break; case NODE_INSERTED: lis.treeNodesInserted(eventInsRem); break; case NODE_REMOVED: lis.treeNodesRemoved(eventInsRem); break; case TREE_STRUCTURE_CHANGED: lis.treeStructureChanged(eventStructChange); break; } } }
void filter() { final String[] term = new String[1]; filter.render(new Runnable() { public void run() { try { term[0] = filter.getText(0, filter.getLength()); } catch (BadLocationException ex) { throw new IllegalStateException(ex); } } }); category2Nodes.clear(); filterNodes(delegate.getRoot(), term[0]); for (TreeModelListener l : getListeners()) { l.treeStructureChanged(new TreeModelEvent(this, new Object[] {getRoot()})); } }
private void fireTreeNode(int changeType, Object source, Object[] path, int[] childIndices, Object[] children) { Object[] listeners = listenerList.getListenerList(); TreeModelEvent e = new TreeModelEvent(source, path, childIndices, children); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == TreeModelListener.class) { switch (changeType) { case CHANGED: ((TreeModelListener) listeners[i + 1]).treeNodesChanged(e); break; case INSERTED: ((TreeModelListener) listeners[i + 1]).treeNodesInserted(e); break; case REMOVED: ((TreeModelListener) listeners[i + 1]).treeNodesRemoved(e); break; case STRUCTURE_CHANGED: ((TreeModelListener) listeners[i + 1]).treeStructureChanged(e); break; default: break; } } } }
private void fire () { TreeModelListener[] listeners = listenerList.getListeners (TreeModelListener.class); if (listeners.length == 0) return; TreeModelEvent e = new TreeModelEvent (this, new Object[] {getRoot ()}); for (int i = 0; i < listeners.length; i++) listeners [i].treeStructureChanged (e); }
private void fireRemove(ASTNavigatorNode node, int[] indices, ASTNavigatorNode[] children, LinkedList<ASTNavigatorNode> nodePath) { TreeModelListener[] listeners = listenerList.getListeners (TreeModelListener.class); if (listeners.length == 0) return; TreePath path = new TreePath(nodePath.toArray()); TreeModelEvent e = new TreeModelEvent (this, path, indices, children); for (int i = 0; i < listeners.length; i++) listeners [i].treeNodesRemoved (e); }
private void fireInsert(ASTNavigatorNode node, int[] indices, ASTNavigatorNode[] children, LinkedList<ASTNavigatorNode> nodePath) { TreeModelListener[] listeners = listenerList.getListeners (TreeModelListener.class); if (listeners.length == 0) return; TreePath path = new TreePath(nodePath.toArray()); TreeModelEvent e = new TreeModelEvent (this, path, indices, children); for (int i = 0; i < listeners.length; i++) listeners [i].treeNodesInserted (e); }
void nodesWereInsertedInternal(final VisualizerEvent ev) { if (listenerList == null) { return; } TreeNode node = ev.getVisualizer(); Object[] path = getPathToRoot(node); Object[] listeners = listenerList.getListenerList(); TreeModelEvent e = null; // Process the listeners last to first, notifying // those that are interested in this event for (int i = listeners.length-2; i>=0; i-=2) { if (listeners[i]==TreeModelListener.class) { // Lazily create the event: if (e == null) { e = new TreeModelEventImpl(this, path, ev); } try { ((TreeModelListener)listeners[i+1]).treeNodesInserted(e); } catch (IndexOutOfBoundsException ex) { LOG.log(Level.WARNING, "Visualizer: {0}", node); Node n = Visualizer.findNode(node); LOG.log(Level.WARNING, "Node: {0}", n); if (n != null) { LOG.log(Level.WARNING, " # children: {0}", n.getChildren().getNodesCount()); LOG.log(Level.WARNING, " children: {0}", n.getChildren().getClass()); } LOG.log(Level.WARNING, "Path: {0}", Arrays.toString(path)); LOG.log(Level.WARNING, "ev.getArray: {0}", Arrays.toString(ev.getArray())); LOG.log(Level.WARNING, "ev.getSnapshot: {0}", ev.getSnapshot()); throw ex; } } } }
@Override public synchronized void removeTreeModelListener(TreeModelListener l) { listeners.remove(l); if (delegatingTreeModelListener) { delegate.removeTreeModelListener(l); } }
@Override public void entryAdded(final Entry newEntry, Folder parent) { SwingTools.invokeAndWait(new Runnable() { @Override public void run() { final TreeModelEvent e = makeChangeEvent(newEntry); for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) { l.treeNodesInserted(e); } } }); }
@Override public void folderRefreshed(final Folder folder) { final TreeModelEvent e = makeChangeEvent(folder); final RepositoryTreeUtil treeUtil = new RepositoryTreeUtil(); SwingTools.invokeAndWait(new Runnable() { @Override public void run() { if (parentTree != null) { treeUtil.saveExpansionState(parentTree); } for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) { l.treeStructureChanged(e); } treeUtil.locateExpandedEntries(); } }); if (parentTree != null) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { treeUtil.restoreExpansionState(parentTree); } }); } }
private void refresh() { for (Repository repo : root.getRepositories()) { final TreeModelEvent e = makeChangeEvent(repo); SwingTools.invokeAndWait(new Runnable() { @Override public void run() { for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) { l.treeStructureChanged(e); } } }); } }
private void fireTreeNodesChanged(Operator operator) { TreeModelEvent e = makeChangeEvent(operator); if (e.getChildIndices() != null && e.getChildIndices()[0] != -1) { // otherwise the // operator is in // the state of // being removed and // has // triggered an // update while // dying. for (TreeModelListener l : listenerList.getListeners(TreeModelListener.class)) { l.treeNodesChanged(e); } } }
private void fireTreeNodesRemoved(Operator operator, int oldIndex) { TreePath path = getPathTo(operator).getParentPath(); TreeModelEvent e = new TreeModelEvent(this, path, new int[] { oldIndex }, new Object[] { operator }); for (TreeModelListener l : listenerList.getListeners(TreeModelListener.class)) { l.treeNodesRemoved(e); } }
private void fireTreeStructureChanged(ExecutionUnit unit) { TreePath path = getPathTo(unit).getParentPath(); TreeModelEvent e = new TreeModelEvent(this, path); for (TreeModelListener l : listenerList.getListeners(TreeModelListener.class)) { l.treeStructureChanged(e); } }
/** * The only event raised by this model is TreeStructureChanged with the root * as path, i.e. the whole tree has changed. */ protected void fireTreeStructureChanged(Person oldRoot) { int len = treeModelListeners.size(); TreeModelEvent e = new TreeModelEvent(this, new Object[] { oldRoot }); for (TreeModelListener tml : treeModelListeners) { tml.treeStructureChanged(e); } }
public void fireNodesRemoved(Object[] path, int[] childIndices, Object[] children) { TreeModelEvent e = new TreeModelEvent(this, path, childIndices, children); for (TreeModelListener l : treeModelListeners) { l.treeNodesRemoved(e); } }
/** * This method calls {@link TreeModelListener#treeStructureChanged(TreeModelEvent)} * on all listeners of this {@code TreeModel}. * May be used to tell the listeners about a change in the file system. */ // TODO: Declare this package private. protected void fireTreeNodesChanged(final TreeModelEvent evt) { final EventListener[] l = listeners.getListeners(TreeModelListener.class); for (int i = 0, ll = l.length; i < ll; i++) ((TreeModelListener) l[i]).treeNodesChanged(evt); }
/** * This method calls {@link TreeModelListener#treeStructureChanged(TreeModelEvent)} * on all listeners of this {@code TreeModel}. * May be used to tell the listeners about a change in the file system. */ // TODO: Declare this package private. protected void fireTreeNodesInserted(final TreeModelEvent evt) { final EventListener[] l = listeners.getListeners(TreeModelListener.class); for (int i = 0, ll = l.length; i < ll; i++) ((TreeModelListener) l[i]).treeNodesInserted(evt); }
/** * This method calls {@link TreeModelListener#treeStructureChanged(TreeModelEvent)} * on all listeners of this {@code TreeModel}. * May be used to tell the listeners about a change in the file system. */ // TODO: Declare this package private. protected void fireTreeNodesRemoved(final TreeModelEvent evt) { final EventListener[] l = listeners.getListeners(TreeModelListener.class); for (int i = 0, ll = l.length; i < ll; i++) ((TreeModelListener) l[i]).treeNodesRemoved(evt); }
/** * This method calls {@link TreeModelListener#treeStructureChanged(TreeModelEvent)} * on all listeners of this {@code TreeModel}. * May be used to tell the listeners about a change in the file system. */ // TODO: Declare this package private. protected void fireTreeStructureChanged(final TreeModelEvent evt) { final EventListener[] l = listeners.getListeners(TreeModelListener.class); for (int i = 0, ll = l.length; i < ll; i++) ((TreeModelListener) l[i]).treeStructureChanged(evt); }
/** * Notifies all listeners that have registered interest for notification on * this event type. The event instance is lazily created using the * parameters passed into the fire method. * * @param source the node being changed * @param path the path to the root node * @param childIndices the indices of the changed elements * @param children the changed elements * @see EventListenerList */ private void fireTreeNodesChanged(TreePath path, int[] childIndices, Object[] children) { TreeModelListener[] listeners = listenerList.getListeners(TreeModelListener.class); if( listeners != null && listeners.length > 0 ) { TreeModelEvent e = new TreeModelEvent(this, path, childIndices, children); for( TreeModelListener listener : listeners ) { listener.treeNodesChanged(e); } } }
private void fireNodesChanged(List<TreeModelEvent> events) { for (TreeModelEvent e : events) { for (TreeModelListener l : listeners) { l.treeNodesChanged(e); } } }
@Override public void addTreeModelListener(TreeModelListener l) { }
@Override public void removeTreeModelListener(TreeModelListener l) { }
@Override public void addTreeModelListener(TreeModelListener arg0) { }
@Override public void removeTreeModelListener(TreeModelListener arg0) { }
public void addTreeModelListener(TreeModelListener listener) { // do nothing we are read-only }
public void removeTreeModelListener(TreeModelListener listener) { // do nothing we are read-only }
public void addTreeModelListener(final TreeModelListener listener) { synchronized (listeners) { listeners.add(listener); } }
public void removeTreeModelListener(final TreeModelListener listener) { synchronized (listeners) { listeners.remove(listener); } }
public void addTreeModelListener (TreeModelListener l) { listenerList.add (TreeModelListener.class, l); }
public void removeTreeModelListener (TreeModelListener l) { listenerList.remove (TreeModelListener.class, l); }
@Override protected TreeModelListener createTreeModelListener() { return new ModelHandler(); }
@Override public final synchronized void addTreeModelListener(TreeModelListener l) { broadcaster.addTreeModelListener (l); }
@Override public void removeTreeModelListener(TreeModelListener l) { listeners.remove(l); }
/** Add a tree model listener. All events fired by this EventBroadcaster * will have the OutlineModel as the event source */ public synchronized void addTreeModelListener(TreeModelListener l) { treeListeners.add (l); }
public LookTreeModel(Object root, LookSelector sel) { listeners = new ArrayList<TreeModelListener>(); this.rootObject = root; this.sel = sel; }