/** Messaged if the tree expansion event (for which we will have already * constructed a TableModelEvent) was vetoed; disposes of the constructed * TableModelEvent in that circumstance. */ public void treeExpansionVetoed(TreeExpansionEvent event, ExpandVetoException exception) { assert SwingUtilities.isEventDispatchThread(); log ("treeExpansionVetoed", exception); //Make sure the event that was vetoed is the one we're interested in if (event == inProgressEvent) { //If so, delete the expansion event we thought we were going //to use in treeExpanded/treeCollapsed, so that it doesn't //stick around forever holding references to objects from the //model pendingExpansionEvent = null; inProgressEvent = null; } }
/** Receives a TreeWillCollapse event and constructs a TableModelEvent * based on the pending changes while the model still reflects the unchanged * state */ public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { assert SwingUtilities.isEventDispatchThread(); log ("treeWillCollapse", event); //Construct the TableModelEvent here, before data structures have //changed. We will fire it from TreeCollapsed if the change is //not vetoed. pendingExpansionEvent = translateEvent (event, false); log ("treeWillCollapse generated ", pendingExpansionEvent); inProgressEvent = event; }
/** Receives a TreeWillExpand event and constructs a TableModelEvent * based on the pending changes while the model still reflects the unchanged * state */ public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { assert SwingUtilities.isEventDispatchThread(); log ("treeWillExpand", event); //Construct the TableModelEvent here, before data structures have //changed. We will fire it from TreeExpanded if the change is not //vetoed pendingExpansionEvent = translateEvent (event, true); log ("treeWillExpand generated", pendingExpansionEvent); inProgressEvent = event; }
/** Fire a table change to the list of listeners supplied. The event should * already have its source set to be the OutlineModel we're proxying for. */ private void fireTableChange (TableModelEvent e, TableModelListener[] listeners) { //Event may be null for offscreen info, etc. if (e == null) { return; } assert (e.getSource() == getModel()); log ("fireTableChange", e); for (int i=0; i < listeners.length; i++) { listeners[i].tableChanged(e); } }
TableModelEvent result = null; log ("createTableDeletionEvent " + Arrays.asList(toArrayOfInteger(indices)), e); log (childPath + " has ", new Integer(visibleChildren)); log ("firstRow", new Integer(firstRow)); log("Count removed is ", new Integer(countRemoved)); log("TableModelEvent: fromRow: ", new Integer(firstRow)); log(" toRow: ", new Integer(lastRow));
/** Updates the layout to mark the descendants of the events path as also * expanded if they were the last it was expanded, then fires a table change. */ public void treeExpanded(TreeExpansionEvent event) { assert SwingUtilities.isEventDispatchThread(); log ("treeExpanded", event); //Mysterious how the event could be null, but JTree tests it //so we will too. if(event != null) { updateExpandedDescendants(event.getPath()); } log ("about to fire", pendingExpansionEvent); //Now fire a change on the owning row so its display is updated (it //may have just become an expandable node) TreePath path = event.getPath(); int row = getLayout().getRowForPath(path); TableModelEvent evt = new TableModelEvent (getModel(), row, row, 0, TableModelEvent.UPDATE); if (row == -1) { evt = new TableModelEvent(getModel()); } fireTableChange(new TableModelEvent[] {evt, pendingExpansionEvent}); pendingExpansionEvent = null; inProgressEvent = null; }
log ("fireTreeChange-" + types[type], e);
if (discontiguous) { blocks = getContiguousIndexBlocks(e, type == NODES_REMOVED); log ("discontiguous " + types[type] + " event", blocks.length + " blocks"); } else { blocks = new Object[] {e.getChildIndices()}; log ("translateEvent", e); log ("generated table events", new Integer(result.length)); if (log) { for (int i=0; i < result.length; i++) { log (" Event " + i, result[i]);
public void treeCollapsed(TreeExpansionEvent event) { assert SwingUtilities.isEventDispatchThread(); log ("treeExpanded", event); //FixedHeightLayoutCache tests if the event is null. //Don't know how it could be, but there's probably a reason... if(event != null) { TreePath path = event.getPath(); //Tell the layout about the change if(path != null && getTreePathSupport().isVisible(path)) { getLayout().setExpandedState(path, false); } } log ("about to fire", pendingExpansionEvent); //Now fire a change on the owning row so its display is updated (it //may have just become an expandable node) TreePath path = event.getPath(); int row = getLayout().getRowForPath(path); TableModelEvent evt = new TableModelEvent (getModel(), row, row, 0, TableModelEvent.UPDATE); fireTableChange(new TableModelEvent[] {evt, pendingExpansionEvent}); pendingExpansionEvent = null; inProgressEvent = null; }
TableModelEvent result = null; log ("createTableInsertionEvent", e);