use of javax.swing.event.TreeModelListener 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.TreeModelListener 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);
}
}
}
use of javax.swing.event.TreeModelListener in project pcgen by PCGen.
the class EquipmentTreeTableModel method fireTreeNodesChanged.
/**
* 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
*/
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;
// 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);
}
}
}
use of javax.swing.event.TreeModelListener in project pcgen by PCGen.
the class EquipmentTreeTableModel method fireTreeNodesInserted.
/**
* 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 new elements are being inserted
* @param path the path to the root node
* @param childIndices the indices of the new elements
* @param children the new elements
* @see EventListenerList
*/
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;
// 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);
}
}
}
use of javax.swing.event.TreeModelListener in project cytoscape-api by cytoscape.
the class AbstractTreeTableModel method fireTreeNodesInserted.
/**
* 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 fireTreeNodesInserted(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]).treeNodesInserted(e);
}
}
}
Aggregations