List of usage examples for javax.swing.event TreeModelEvent TreeModelEvent
public TreeModelEvent(Object source, TreePath path, int[] childIndices, Object[] children)
From source file:TreeModelSupport.java
protected void fireTreeNodesChanged(Object source, Object[] path, int[] childIndices, Object[] children) { // Guaranteed to return a non-null array Object[] listeners = listenerList.getListenerList(); TreeModelEvent e = null;//from w w w. j av a 2s.c o m // 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 TreeModelEvent(source, path, childIndices, children); ((TreeModelListener) listeners[i + 1]).treeNodesChanged(e); } } }
From source file:FileTreeFrame.java
private void fireTreeNodesChanged(TreePath parentPath, int[] indices, Object[] children) { TreeModelEvent event = new TreeModelEvent(this, parentPath, indices, children); Iterator iterator = listeners.iterator(); TreeModelListener listener = null; while (iterator.hasNext()) { listener = (TreeModelListener) iterator.next(); listener.treeNodesChanged(event); }/*from w w w .j a v a 2s . c o m*/ }
From source file:TreeModelSupport.java
protected void fireTreeNodesInserted(Object source, Object[] path, int[] childIndices, Object[] children) { // Guaranteed to return a non-null array Object[] listeners = listenerList.getListenerList(); TreeModelEvent e = null;/*from w w w . jav a2 s.co m*/ // 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 TreeModelEvent(source, path, childIndices, children); ((TreeModelListener) listeners[i + 1]).treeNodesInserted(e); } } }
From source file:com.nbt.NBTTreeTableModel.java
/** * @see TreeModelEvent#TreeModelEvent(Object, Object[], int[], Object[]) * @see TreeModelEvent#TreeModelEvent(Object, TreePath, int[], Object[]) * @see TreeModelListener#treeNodesInserted(TreeModelEvent) *//* w w w. j a v a 2 s . co m*/ protected void fireTreeNodesInserted(Object source, TreePath path, int[] childIndices, Object[] children) { TreeModelEvent event = new TreeModelEvent(source, path, childIndices, children); TreeModelListener[] listeners = getTreeModelListeners(); ArrayUtils.reverse(listeners); for (TreeModelListener listener : listeners) listener.treeNodesInserted(event); }
From source file:de.codesourcery.eve.skills.ui.model.FilteringTreeModel.java
@Override public int addChild(ITreeNode parent, ITreeNode n) { delegate.addChild(parent, n);/*from www . j a v a 2 s . c om*/ final int index = getIndexOfChild(parent, n); if (index != -1) { fireEvent(EventType.ADDED, new TreeModelEvent(this, parent.getPathToRoot(), new int[] { index }, new Object[] { n })); } return index; }
From source file:TreeModelSupport.java
protected void fireTreeNodesRemoved(Object source, Object[] path, int[] childIndices, Object[] children) { // Guaranteed to return a non-null array Object[] listeners = listenerList.getListenerList(); TreeModelEvent e = null;/* w ww. ja v a2s . co m*/ // 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 TreeModelEvent(source, path, childIndices, children); ((TreeModelListener) listeners[i + 1]).treeNodesRemoved(e); } } }
From source file:de.codesourcery.eve.skills.ui.model.FilteringTreeModel.java
@Override public void addChild(ITreeNode parent, ITreeNode n, int index) { delegate.addChild(parent, n);/*from w w w . j a va 2s . c om*/ final int realIndex = getIndexOfChild(parent, n); if (realIndex != -1) { fireEvent(EventType.ADDED, new TreeModelEvent(this, parent.getPathToRoot(), new int[] { realIndex }, new Object[] { n })); } }
From source file:TreeModelSupport.java
protected void fireTreeStructureChanged(Object source, Object[] path, int[] childIndices, Object[] children) { // Guaranteed to return a non-null array Object[] listeners = listenerList.getListenerList(); TreeModelEvent e = null;//from w w w. j ava 2s.c o m // 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 TreeModelEvent(source, path, childIndices, children); ((TreeModelListener) listeners[i + 1]).treeStructureChanged(e); } } }
From source file:de.codesourcery.eve.skills.ui.model.FilteringTreeModel.java
@Override public void addChildren(ITreeNode parent, Collection<ITreeNode> nodes) { delegate.addChildren(parent, nodes); if (!isPathToRootVisible(parent)) { // children cannot be visible if their parent is hidden return;/*from w w w . ja va 2 s . c o m*/ } final List<Integer> childIndices = new ArrayList<Integer>(); final List<ITreeNode> children = new ArrayList<ITreeNode>(); for (ITreeNode child : nodes) { if (isHidden(child)) { continue; } childIndices.add(getIndexOfChild(parent, child)); children.add(child); } if (!childIndices.isEmpty()) { final int[] indices = ArrayUtils.toPrimitive(childIndices.toArray(new Integer[childIndices.size()])); final Object[] childs = children.toArray(new ITreeNode[children.size()]); fireEvent(EventType.ADDED, new TreeModelEvent(this, parent.getPathToRoot(), indices, childs)); } }
From source file:de.codesourcery.eve.skills.ui.model.FilteringTreeModel.java
@Override public int removeChild(ITreeNode parent, ITreeNode child) { final int index = getIndexOfChild(parent, child); delegate.removeChild(parent, child); if (index != -1) { fireEvent(EventType.REMOVED,//from ww w .j a v a2 s . c om new TreeModelEvent(this, parent.getPathToRoot(), new int[] { index }, new Object[] { child })); } return index; }