/** Process a change event from the user-supplied tree model. This * method will throw an assertion failure if it receives any event type * other than TableModelEvent.UPDATE - the ProxyTableModel should never, * ever fire structural changes - only the tree model is allowed to do * that. */ public void tableChanged(TableModelEvent e) { assert SwingUtilities.isEventDispatchThread(); //The *ONLY* time we should see events here is due to user //data entry. The ProxyTableModel should never change out //from under us - all structural changes happen through the //table model. assert (e.getType() == e.UPDATE) : "Table model should only fire " + "updates, never structural changes"; fireTableChange (translateEvent(e)); }
/** 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; }
/** Process a change event from the user-supplied tree model. * Order of operations: * <ol><li>Refire the same tree event with the OutlineModel we're * proxying as the source</li> * <li>Create one or more table model events (more than one if the * incoming event affects discontiguous rows) reflecting the effect * of the tree change</li> * <li>Call the method with the same signature as this one on the * layout cache, so it will update its state appropriately</li> * <li>Fire the generated TableModelEvent(s)</li></ol> */ public void treeNodesChanged(TreeModelEvent e) { assert SwingUtilities.isEventDispatchThread(); fireTreeChange (translateEvent(e), NODES_CHANGED); TableModelEvent[] events = translateEvent(e, NODES_CHANGED); getLayout().treeNodesChanged(e); fireTableChange(events); }
/** Process a node insertion event from the user-supplied tree model * Order of operations: * <ol><li>Refire the same tree event with the OutlineModel we're * proxying as the source</li> * <li>Create one or more table model events (more than one if the * incoming event affects discontiguous rows) reflecting the effect * of the tree change</li> * <li>Call the method with the same signature as this one on the * layout cache, so it will update its state appropriately</li> * <li>Fire the generated TableModelEvent(s)</li></ol> */ public void treeNodesInserted(TreeModelEvent e) { assert SwingUtilities.isEventDispatchThread(); fireTreeChange (translateEvent(e), NODES_INSERTED); TableModelEvent[] events = translateEvent(e, NODES_INSERTED); getLayout().treeNodesInserted(e); fireTableChange(events); }
/** Process a node removal event from the user-supplied tree model * Order of operations: * <ol><li>Refire the same tree event with the OutlineModel we're * proxying as the source</li> * <li>Create one or more table model events (more than one if the * incoming event affects discontiguous rows) reflecting the effect * of the tree change</li> * <li>Call the method with the same signature as this one on the * layout cache, so it will update its state appropriately</li> * <li>Fire the generated TableModelEvent(s)</li></ol> */ public void treeNodesRemoved(TreeModelEvent e) { assert SwingUtilities.isEventDispatchThread(); fireTreeChange (translateEvent(e), NODES_REMOVED); TableModelEvent[] events = translateEvent(e, NODES_REMOVED); getLayout().treeNodesRemoved(e); fireTableChange(events); }
/** Process a structural change event from the user-supplied tree model. * This will result in a generic "something changed" * TableModelEvent being fired. */ public void treeStructureChanged(TreeModelEvent e) { assert SwingUtilities.isEventDispatchThread(); getLayout().treeStructureChanged(e); fireTreeChange (translateEvent(e), STRUCTURE_CHANGED); //If it's a structural change, we need to dump all our info about the //existing tree structure - it can be bogus now. Similar to JTree, //this will have the effect of collapsing all expanded paths. The //TreePathSupport takes care of dumping the layout cache's copy of //such data getTreePathSupport().clear(); //We will just fire a "Something happened. Go figure out what." event. fireTableChange (new TableModelEvent (getModel())); }