use of javax.swing.event.TreeModelEvent in project processdash by dtuma.
the class AbstractTreeTableModel method fireTreeStructureWillChange.
/*
* Notify 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.
* @see EventListenerList
*/
protected void fireTreeStructureWillChange(Object source, Object[] path, int[] childIndices, Object[] children) {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
TreeModelEvent e = null;
// those that are interested in this event
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == TreeModelWillChangeListener.class) {
// Lazily create the event:
if (e == null)
e = new TreeModelEvent(source, path, childIndices, children);
((TreeModelWillChangeListener) listeners[i + 1]).treeStructureWillChange(e);
}
}
}
use of javax.swing.event.TreeModelEvent in project checkstyle by checkstyle.
the class ParseTreeTableModel method fireTreeStructureChanged.
/**
* Notify all listeners that have registered interest for
* 'tree structure changed' event. The event instance
* is lazily created using the parameters passed into
* the fire method.
* @param source The Object responsible for generating the event.
* @param path An array of Object identifying the path to the parent of the modified items.
* @param childIndices An array of int that specifies the index values of the removed items.
* @param children An array of Object containing the inserted, removed, or changed objects.
* @see EventListenerList
*/
private void fireTreeStructureChanged(Object source, Object[] path, int[] childIndices, Object... children) {
// Guaranteed to return a non-null array
final Object[] listeners = listenerList.getListenerList();
TreeModelEvent event = null;
// 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 (event == null) {
event = new TreeModelEvent(source, path, childIndices, children);
}
((TreeModelListener) listeners[i + 1]).treeStructureChanged(event);
}
}
}
use of javax.swing.event.TreeModelEvent in project intellij-community by JetBrains.
the class TreeBuilder method nodeStructureChanged.
public void nodeStructureChanged(TreeNode node) {
TreeModelEvent event = new TreeModelEvent(this, getPathToRoot(node, 0), null, null);
myDispatcher.getMulticaster().treeStructureChanged(event);
}
use of javax.swing.event.TreeModelEvent in project intellij-community by JetBrains.
the class TreeUiTest method testNoExtraJTreeModelUpdate.
public void testNoExtraJTreeModelUpdate() throws Exception {
buildStructure(myRoot);
expand(getPath("/"));
assertTree("-/\n" + " +com\n" + " +jetbrains\n" + " +org\n" + " +xUnit\n");
final Ref<StringBuffer> updates = new Ref<>(new StringBuffer());
notNull(getMyBuilder().getTreeModel()).addTreeModelListener(new TreeModelListener() {
@Override
public void treeNodesChanged(TreeModelEvent e) {
updates.get().append("changed parent").append(e.getTreePath()).append(" children=").append(Arrays.asList(e.getChildren())).append("\n");
}
@Override
public void treeNodesInserted(TreeModelEvent e) {
updates.get().append("inserted=").append(e.getTreePath()).append("\n");
}
@Override
public void treeNodesRemoved(TreeModelEvent e) {
updates.get().append("removed=").append(e.getTreePath()).append("\n");
}
@Override
public void treeStructureChanged(TreeModelEvent e) {
updates.get().append("structureChanged=").append(e.getTreePath()).append("\n");
}
});
assertEquals("", updates.get().toString());
updateFromRoot();
assertEquals("", updates.get().toString());
myChanges.add(new NodeElement("com"));
updateFromRoot();
assertEquals("changed parent[/] children=[com]\n", updates.get().toString());
assertTree("-/\n" + " +com\n" + " +jetbrains\n" + " +org\n" + " +xUnit\n");
updates.set(new StringBuffer());
updateFrom(new NodeElement("org"));
assertEquals("", updates.get().toString());
myChanges.add(new NodeElement("org"));
updateFrom(new NodeElement("org"));
assertEquals("changed parent[/] children=[org]\n", updates.get().toString());
updates.set(new StringBuffer());
myChanges.add(new NodeElement("intellij"));
updateFromRoot();
assertEquals("", updates.get().toString());
}
use of javax.swing.event.TreeModelEvent in project pcgen by PCGen.
the class EquipmentTreeTableModel method fireTreeStructureChanged.
/**
* 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 where the tree model has changed
* @param path the path to the root node
* @param childIndices the indices of the affected elements
* @param children the affected elements
* @see EventListenerList
*/
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;
// 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);
}
}
}
Aggregations