instrument/JTree API Documentation

org.pvv.bcd.instrument.JTree
Class Instrumenter

java.lang.Object
  |
  +--org.pvv.bcd.instrument.JTree.Instrumenter

public class Instrumenter
extends java.lang.Object

This class provides instrumentation of JTree objects. What this means is that by associating a JTree with an instance of the Instrumenter class, you can get features such as drag-and-drop, import/export XML, tree structure rearranging and editing of node names pretty much for free. While some of these features require you to do some adaption coding (particularly if you're not 100% happy with the default behaviour), such adaption is designed to be reasonably easy and we also provide means of disabling features that you do not desire.

Typical use of this class is as follows:

 JTree tree = new JTree(someModel);
 Instrumenter instrument = Instrumenter.createInstrument(tree);
 
You now proceed to put your tree into your GUI and will immediately reap the benefit of the instrumenter's many features. If you intend to interact with the instrument in the future, you will want to keep a reference to it. If not, you do not need to do so.

The instrumenter works primarily by attaching listeners to the input tree, but will also do some tweaking of the tree. Refer to the documentation for the various setUseDefaultXxx() methods for details on which features are available, what they do to your tree, and how to disable them.

To get the maximum usability with the least amount of fuss, it is recommended that you use tree nodes of type DefaultMutableTreeNode. The instrumenter expects this type for a variety of its features. It should be evident in the API documentation what features that require this. If you find any discrepancies, please let us know.

The instrument can be further customised by calling the various public methods in it. Refer to the API documentation for details.

Instances of Instrumenter can only be obtained by calling one of its factory methods;


Field Summary
static java.lang.String ACTION_ADD_ABOVE
          Action name object for "Add Node Above" action
static java.lang.String ACTION_ADD_BELOW
          Action name object for "Add Node Below" action
static java.lang.String ACTION_ADD_CHILD
          Action name object for "Add Child Node" action
static java.lang.String ACTION_COPY
          Action name object for "Copy Selection" action
static java.lang.String ACTION_CUT
          Action name object for "Cut Selection" action
static java.lang.String ACTION_DELETE
          Action name object for "Delete Selection" action
static java.lang.String ACTION_MAKE_ANCESTOR
          Action name object for "Move Left" action
static java.lang.String ACTION_MAKE_CHILD
          Action name object for "Move Right" action
static java.lang.String ACTION_MOVE_DOWN
          Action name object for "Move Down" action
static java.lang.String ACTION_MOVE_UP
          Action name object for "Move Up" action
static java.lang.String ACTION_PASTE
          Action name object for "Paste" action
static java.lang.String ACTION_REDO
          Action name object for "Redo Undo" action
static java.lang.String ACTION_START_EDIT
          Action name object for "Edit Node Name" action
static java.lang.String ACTION_UNDO
          Action name object for "Undo Edit" action
protected  javax.swing.AbstractAction m_actAddAbove
           
protected  javax.swing.AbstractAction m_actAddBelow
           
protected  javax.swing.AbstractAction m_actAddChild
           
protected  javax.swing.AbstractAction m_actCopy
           
protected  javax.swing.AbstractAction m_actCut
           
protected  javax.swing.AbstractAction m_actDelete
           
protected  javax.swing.AbstractAction m_actMakeAncestor
           
protected  javax.swing.AbstractAction m_actMakeChild
           
protected  javax.swing.AbstractAction m_actMoveDown
           
protected  javax.swing.AbstractAction m_actMoveUp
           
protected  javax.swing.AbstractAction m_actPaste
           
protected  javax.swing.AbstractAction m_actRedo
           
protected  javax.swing.AbstractAction m_actStartEdit
           
protected  javax.swing.AbstractAction m_actUndo
           
protected  javax.swing.Action[] m_arrSelectionDependentActions
          An array of all actions that are enabled only when 1+ nodes are selected
 java.util.Hashtable m_hashDefaultActionMap
           
 java.util.Hashtable m_hashDefaultInputMap
           
 
Method Summary
 void addChildNode()
          Adds a new node at the end of the selected node's children
 void addNodeAbove()
          Adds a new node above the selection, or at top if no selection
 void addNodeBelow()
          Adds a new node below the selection, or at bottom if no selection
 void addNodes(javax.swing.tree.DefaultMutableTreeNode parent, javax.swing.tree.DefaultMutableTreeNode[] nodes, int parent_index)
          Adds a set of nodes to the tree.
 void addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
          Adds listeners for undoableedit events.
 void addVetoableTreeStructureChangeListener(VetoableTreeStructureChangeListener l)
          Adds a listener to changes in the tree structure.
protected  void configureCellEditor()
           This method tweaks a cell editor so that we can use it.
 void copyNode()
          Puts the selected nodes into the local clipboard.
 java.lang.String createFromXml(java.io.InputStream is)
           Reads text from the given inputstream, parses it according to infobank.dtd and creates a new tree based upon the information.
static Instrumenter createInstrument(javax.swing.JTree tree)
          Convenience factory method to fully instrument a tree with all available functionality, keeping its contents.
static Instrumenter createInstrument(javax.swing.JTree tree, boolean full_instrumentation)
          Convenience factory method instrumenting a tree while keeping the tree's contents.
static Instrumenter createInstrument(javax.swing.JTree tree, boolean full_instrumentation, boolean clear)
          Factory method for instrumenting a tree and returning the instrument.
 void cutNode()
          Deletes the selected nodes and puts them into the local clipboard.
 void deleteSelectedNodes()
          Deletes currently selected nodes with a "delete" semantic (as opposed to a "backspace" semantic).
 void doDndCompoundAdd(long op_id, javax.swing.tree.DefaultMutableTreeNode parent, javax.swing.tree.DefaultMutableTreeNode node, int index)
          The purpose and workings of this method are shrouded in the mists of time.
 void doDndCompoundDelete(long op_id, javax.swing.tree.DefaultMutableTreeNode node)
          The purpose and workings of this method are shrouded in the mists of time.
 void finishDndOperation(long op_id, boolean source)
          Finishes a Drag And Drop operation.
protected  void fireNodeCreation(VetoableTreeStructureChangeEvent e)
          Fires a Node Creation event
protected  void fireNodeDeletion(VetoableTreeStructureChangeEvent e)
          Fires a Node Deletion event
protected  void fireNodeMove(VetoableTreeStructureChangeEvent e)
          Fires a Node Move event
protected  void fireNodeRename(VetoableTreeStructureChangeEvent e)
          Fires a Node Rename event
 javax.swing.Action getAddAboveAction()
           
 javax.swing.Action getAddBelowAction()
           
 javax.swing.Action getAddChildAction()
           
 javax.swing.Action getCopyAction()
           
 javax.swing.Action getCutAction()
           
 javax.swing.Action getDeleteAction()
           
 javax.swing.Action getMakeAncestorAction()
           
 javax.swing.Action getMakeChildAction()
           
 javax.swing.Action getMoveDownAction()
           
 javax.swing.Action getMoveUpAction()
           
 long getMyInstrumentId()
          Retrieves my unique instrument ID
 DndId getNextDndId()
          Utility method that hands out unique IDs to use for identifying drag and drop operations.
static long getNextInstrumentId()
          Generates a unique ID.
 NodeFactory getNodeFactory()
          Retrieve the currently active node factory.
 javax.swing.Action getPasteAction()
           
 javax.swing.Action getRedoAction()
           
 javax.swing.Action getStartEditAction()
           
 javax.swing.Action getUndoAction()
           
 javax.swing.undo.UndoManager getUndoManager()
          Returns a reference to the currently active undo manager, if I know about it.
 void makeAncestor()
          Moves all selected nodes one position to the "left" on the tree.
 void makeChild()
          Moves all selected nodes one position to the "right" in the tree.
protected  javax.swing.tree.MutableTreeNode makeNodeFromXMLRecursive(org.jdom.Element xml_elem, boolean is_root)
           
protected  org.jdom.Element makeXMLNodeRecursive(java.lang.Object node, boolean is_root)
           
 void moveNode(javax.swing.tree.DefaultMutableTreeNode node_to_move, javax.swing.tree.DefaultMutableTreeNode dest_node, int dest_index)
          Moves a node in the tree.
 void moveNodesDown()
          Moves selected nodes one position towards the bottom
 void moveNodesUp()
          Moves selected nodes one position towards the top
 void outputXml(java.io.OutputStream os)
           Builds an XML representation of the tree, as defined by infobank.dtd.
 void pasteNode()
          Makes copies of the nodes in the local clipboard (not the system clipboard) in the currently focused location.
 void pasteNode(org.pvv.bcd.instrument.JTree.SubTreeNode[] nodes)
          Copies nodes into the currently focused location.
 void purgeUndoBuffer()
          Empties the undo buffer.
static javax.swing.tree.TreePath[] reduceSelection(javax.swing.tree.TreePath[] original)
          Reduces a set of tree nodes to the minimum set that includes them all.
 void removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
          Removes an UndoableEdit listener.
 void removeVetoableTreeStructureChangeListener(VetoableTreeStructureChangeListener l)
          Removes a tree structure change listener.
 void setNodeFactory(NodeFactory factory)
          Sets the object to use for creating new nodes in the tree.
 void setUndoManager(javax.swing.undo.UndoManager manager)
          Registers a new undo manager with me.
 void setUseDefaultActionMap(boolean b)
          Configures whether to use our default actions.
 void setUseDefaultDnd(boolean b)
           Will configure the tree to use the default Drag And Drop implementation.
 void setUseDefaultKeyboardShortcuts(boolean b)
          Configures whether to use our default keyboard shortcuts.
 void setUseDefaultNodeFactory(boolean b)
          Configures whether or not to use the default node factory.
 void setUseDefaultTreeConfiguration(boolean b)
           Will configure the tree for optimal instrumented operation.
 void setUseDefaultUndoManager(boolean b)
          Configures whether or not to use the default Infobank undo manager.
protected  void updateActionObjects()
          Will ensure that the Action objects we have created are in sync with the selection state of the tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_actAddAbove

protected javax.swing.AbstractAction m_actAddAbove

m_actAddBelow

protected javax.swing.AbstractAction m_actAddBelow

m_actAddChild

protected javax.swing.AbstractAction m_actAddChild

m_actMakeAncestor

protected javax.swing.AbstractAction m_actMakeAncestor

m_actMakeChild

protected javax.swing.AbstractAction m_actMakeChild

m_actUndo

protected javax.swing.AbstractAction m_actUndo

m_actRedo

protected javax.swing.AbstractAction m_actRedo

m_actDelete

protected javax.swing.AbstractAction m_actDelete

m_actMoveUp

protected javax.swing.AbstractAction m_actMoveUp

m_actMoveDown

protected javax.swing.AbstractAction m_actMoveDown

m_actCopy

protected javax.swing.AbstractAction m_actCopy

m_actCut

protected javax.swing.AbstractAction m_actCut

m_actPaste

protected javax.swing.AbstractAction m_actPaste

m_actStartEdit

protected javax.swing.AbstractAction m_actStartEdit

m_arrSelectionDependentActions

protected javax.swing.Action[] m_arrSelectionDependentActions
An array of all actions that are enabled only when 1+ nodes are selected

ACTION_MOVE_UP

public static final java.lang.String ACTION_MOVE_UP
Action name object for "Move Up" action

ACTION_MOVE_DOWN

public static final java.lang.String ACTION_MOVE_DOWN
Action name object for "Move Down" action

ACTION_MAKE_ANCESTOR

public static final java.lang.String ACTION_MAKE_ANCESTOR
Action name object for "Move Left" action

ACTION_MAKE_CHILD

public static final java.lang.String ACTION_MAKE_CHILD
Action name object for "Move Right" action

ACTION_COPY

public static final java.lang.String ACTION_COPY
Action name object for "Copy Selection" action

ACTION_CUT

public static final java.lang.String ACTION_CUT
Action name object for "Cut Selection" action

ACTION_PASTE

public static final java.lang.String ACTION_PASTE
Action name object for "Paste" action

ACTION_UNDO

public static final java.lang.String ACTION_UNDO
Action name object for "Undo Edit" action

ACTION_REDO

public static final java.lang.String ACTION_REDO
Action name object for "Redo Undo" action

ACTION_ADD_ABOVE

public static final java.lang.String ACTION_ADD_ABOVE
Action name object for "Add Node Above" action

ACTION_ADD_BELOW

public static final java.lang.String ACTION_ADD_BELOW
Action name object for "Add Node Below" action

ACTION_ADD_CHILD

public static final java.lang.String ACTION_ADD_CHILD
Action name object for "Add Child Node" action

ACTION_DELETE

public static final java.lang.String ACTION_DELETE
Action name object for "Delete Selection" action

ACTION_START_EDIT

public static final java.lang.String ACTION_START_EDIT
Action name object for "Edit Node Name" action

m_hashDefaultActionMap

public final java.util.Hashtable m_hashDefaultActionMap

m_hashDefaultInputMap

public final java.util.Hashtable m_hashDefaultInputMap
Method Detail

createInstrument

public static Instrumenter createInstrument(javax.swing.JTree tree,
                                            boolean full_instrumentation,
                                            boolean clear)
Factory method for instrumenting a tree and returning the instrument.
Parameters:
tree - Tree to instrument. It must already have been constructed (i.e., null pointer not allowed).
full_instrumentation - If true, will install all instrumentation features. If false, will install only those essential for the correct operation of the instrumentation. If set to false, you may want to install a subset of the full instrumentation. This is accomplished by calling one or more of the setUseXxxx methods with "true" as parameter.
clear - If true, will clear the contents of the tree and create a default root node of type DefaultMutableTreeNode. If false, will keep any old contents.
See Also:
createInstrument(JTree,boolean), createInstrument(JTree), setUseDefaultKeyboardShortcuts(boolean), setUseDefaultActionMap(boolean), setUseDefaultUndoManager(boolean), #setUseDefaultCellEditor, setUseDefaultNodeFactory(boolean), setUseDefaultTreeConfiguration(boolean)

createInstrument

public static Instrumenter createInstrument(javax.swing.JTree tree,
                                            boolean full_instrumentation)
Convenience factory method instrumenting a tree while keeping the tree's contents.
See Also:
createInstrument(JTree,boolean,boolean)

createInstrument

public static Instrumenter createInstrument(javax.swing.JTree tree)
Convenience factory method to fully instrument a tree with all available functionality, keeping its contents.
See Also:
createInstrument(JTree,boolean,boolean),

configureCellEditor

protected void configureCellEditor()

This method tweaks a cell editor so that we can use it. Specifically, we add a CellEditorListener to it so we can handle focus when editing stops.

NOTE that when the cell editor changes, we make no attempt to remove the listener from the old cell editor. This is a potential source of memory leaks.


setUseDefaultDnd

public void setUseDefaultDnd(boolean b)

Will configure the tree to use the default Drag And Drop implementation. This will work for many applications, and when it does not is is generally easy to make it work. If Drag And Drop is not wanted, however, it may make sense to disable it.

This method is called automatically if you choose full instrumentation in the call to createInstrument.
Parameters:
b - If true, uses our default tree config. If false, does nothing.
See Also:
createInstrument(JTree,boolean,boolean)

setUseDefaultTreeConfiguration

public void setUseDefaultTreeConfiguration(boolean b)

Will configure the tree for optimal instrumented operation. If you do not call this method (it is called automatically if you choose full instrumentation in the call to createInstrument), take note of the following;

Parameters:
b - If true, uses our default tree config. If false, does nothing.
See Also:
createInstrument(JTree,boolean,boolean)

setUseDefaultNodeFactory

public void setUseDefaultNodeFactory(boolean b)
Configures whether or not to use the default node factory. The default node factory has no particular expectations of the type of nodes or their contents but creates DefaultMutableTreeNode objects with DefaultNodeInfo contents when constructing new nodes.
Parameters:
b - If true, will use our default node factory. If false, does nothing.
See Also:
createInstrument(JTree,boolean,boolean)

setUseDefaultUndoManager

public void setUseDefaultUndoManager(boolean b)
Configures whether or not to use the default Infobank undo manager. The default undo manager has not particular expectations of the nodes or their contents.
Parameters:
b - If true, will call setUndoManager() with a new InfoUndoManager. If false, does nothing.
See Also:
setUndoManager(javax.swing.undo.UndoManager), InfoUndoManager, createInstrument(JTree,boolean,boolean)

setUseDefaultKeyboardShortcuts

public void setUseDefaultKeyboardShortcuts(boolean b)
Configures whether to use our default keyboard shortcuts. Some of the default shortcuts (i.e., Ctrl-Up, Ctrl-Down, Space) conflict with and override default Swing JTree shortcuts. The keyboard shortcuts will not work properly unless you also install the default action map (or the subset of it that is of interest to you).
Parameters:
b - If true, will install our keyboard shortcuts. If false, removes them (only really useful if you've installed them previously and don't want them anymore).
See Also:
createInstrument(JTree,boolean,boolean), setUseDefaultActionMap(boolean)

setUseDefaultActionMap

public void setUseDefaultActionMap(boolean b)
Configures whether to use our default actions. While these should not conflict with existing ones, you don't really need to install them if you don't intend to use them (i.e., if you haven't installed the default keyboard map). The keyboard shortcuts will not work properly unless you also install the default action map (or the subset of it that is of interest to you).
Parameters:
b - If true, will install our actions. If false, removes them (only really useful if you've installed them previously and don't want them anymore).
See Also:
createInstrument(JTree,boolean,boolean), setUseDefaultKeyboardShortcuts(boolean)

setNodeFactory

public void setNodeFactory(NodeFactory factory)
Sets the object to use for creating new nodes in the tree. Extend NodeFactory and implement your own methods if you need specialized behaviour.
See Also:
NodeFactory

getNodeFactory

public NodeFactory getNodeFactory()
Retrieve the currently active node factory.
See Also:
setNodeFactory(org.pvv.bcd.instrument.JTree.NodeFactory)

addUndoableEditListener

public void addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
Adds listeners for undoableedit events.
See Also:
UndoableEdit

removeUndoableEditListener

public void removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
Removes an UndoableEdit listener.
See Also:
UndoableEdit

getUndoManager

public javax.swing.undo.UndoManager getUndoManager()
Returns a reference to the currently active undo manager, if I know about it. If I do not know about it, returns null.

setUndoManager

public void setUndoManager(javax.swing.undo.UndoManager manager)
Registers a new undo manager with me. I take care of getting rid of any old one (removing it as listener) and making the new one a listener. I will also subscribe to its changeEvents if it is a "InfoUndoManager" or subclass. If so, I will correctly update my undo and redo actions. If I do not know about the current undo manager (i.e., this attribute has been set to null) the actions will always be disabled. If I think I know about it but do not (i.e., I have wrong information) the state of these actions may be wrong.
See Also:
getUndoAction(), getRedoAction()

purgeUndoBuffer

public void purgeUndoBuffer()
Empties the undo buffer. Only works if I know about the current undo manager.
See Also:
setUndoManager(javax.swing.undo.UndoManager)

moveNodesUp

public void moveNodesUp()
Moves selected nodes one position towards the top

moveNodesDown

public void moveNodesDown()
Moves selected nodes one position towards the bottom

addNodeAbove

public void addNodeAbove()
                  throws VetoException
Adds a new node above the selection, or at top if no selection

addNodeBelow

public void addNodeBelow()
                  throws VetoException
Adds a new node below the selection, or at bottom if no selection

addChildNode

public void addChildNode()
                  throws VetoException
Adds a new node at the end of the selected node's children

moveNode

public void moveNode(javax.swing.tree.DefaultMutableTreeNode node_to_move,
                     javax.swing.tree.DefaultMutableTreeNode dest_node,
                     int dest_index)
              throws VetoException
Moves a node in the tree. Makes sure that an undo object is created and stored.
Parameters:
node_to_move - Reference to the node to move
dest_node - New parent for the node to move
dest_index - Index within dest_node that node_to_move should end up in
Throws:
VetoException - The move was vetoed by one of the veto listeners

makeAncestor

public void makeAncestor()
Moves all selected nodes one position to the "left" on the tree. This has the effect of making the node the parent of what used to be the siblings below it in the tree. If the node is at root level, nothing happens to it. Expects nodes to be of type DefaultMutableTreeNode.

makeChild

public void makeChild()
Moves all selected nodes one position to the "right" in the tree. This has the effect of making a node the child of what used to be the sibling just above it in the tree. If the node is topmost among its siblings, nothing happens to it. Expects nodes to be of type DefaultMutableTreeNode.

addNodes

public void addNodes(javax.swing.tree.DefaultMutableTreeNode parent,
                     javax.swing.tree.DefaultMutableTreeNode[] nodes,
                     int parent_index)
Adds a set of nodes to the tree. Makes sure to update undo information.
Parameters:
parent - Node to place new nodes within
nodes - Array of nodes to add
parent_index - Index in parent into which the first node in the node array will be placed. Each following node in the array will be placed at the next index.

deleteSelectedNodes

public void deleteSelectedNodes()
Deletes currently selected nodes with a "delete" semantic (as opposed to a "backspace" semantic).
See Also:
#deleteSelection(boolean)

reduceSelection

public static javax.swing.tree.TreePath[] reduceSelection(javax.swing.tree.TreePath[] original)
Reduces a set of tree nodes to the minimum set that includes them all. That is, if node n2 is a child of node n1 and both are included in the input parameter, then node n2 will not be part of the return value. n2 is implicitly included by the fact that n1 is included with all its children. This is a utility method.
Parameters:
original - Set of tree nodes to reduce.
Returns:
Minimum set of tree nodes that includes all nodes in the original when a node's children are assumed to be included implicitly if the node is included.

updateActionObjects

protected void updateActionObjects()
Will ensure that the Action objects we have created are in sync with the selection state of the tree. This method should be called whenever there is reason to believe that the selection in the tree has changed.

getNextDndId

public DndId getNextDndId()
Utility method that hands out unique IDs to use for identifying drag and drop operations. If you do not intend to do some low-level DND coding, you do not need this method.
Returns:
A new DND ID that is guaranteed to be unique for this instance of Instrumenter. Note that the unique id is implemented as a long, so the potential for a wrap-around and following non-uniqueness of the ids is present.

finishDndOperation

public void finishDndOperation(long op_id,
                               boolean source)
Finishes a Drag And Drop operation. If you do not intend to do some low-level DND coding, you do not need this method.
Parameters:
op_id - Operation ID of DND operation to finish
source - Set to true if the source is done handling the DND operation, false if it is not done.

doDndCompoundAdd

public void doDndCompoundAdd(long op_id,
                             javax.swing.tree.DefaultMutableTreeNode parent,
                             javax.swing.tree.DefaultMutableTreeNode node,
                             int index)
                      throws VetoException
The purpose and workings of this method are shrouded in the mists of time. It is, however, vital to make drag and drop behave correctly. It will be investigated and documented as time permits.

doDndCompoundDelete

public void doDndCompoundDelete(long op_id,
                                javax.swing.tree.DefaultMutableTreeNode node)
                         throws VetoException
The purpose and workings of this method are shrouded in the mists of time. It is, however, vital to make drag and drop behave correctly. It will be investigated and documented as time permits.

cutNode

public void cutNode()
Deletes the selected nodes and puts them into the local clipboard. Does not put them into the system clipboard. Expects nodes to be of type DefaultMutableTreeNode.
See Also:
#m_arrCopiedNodes

copyNode

public void copyNode()
Puts the selected nodes into the local clipboard. Does not put them into the system clipboard. Expects nodes to be of type DefaultMutableTreeNode.
See Also:
#m_arrCopiedNodes

pasteNode

public void pasteNode()
Makes copies of the nodes in the local clipboard (not the system clipboard) in the currently focused location. Expects nodes to be of type DefaultMutableTreeNode.
See Also:
#m_arrCopiedNodes

pasteNode

public void pasteNode(org.pvv.bcd.instrument.JTree.SubTreeNode[] nodes)
Copies nodes into the currently focused location. Expects nodes to be of type DefaultMutableTreeNode.
Parameters:
nodes - Nodes to be inserted.
See Also:
pasteNode()

createFromXml

public java.lang.String createFromXml(java.io.InputStream is)

Reads text from the given inputstream, parses it according to infobank.dtd and creates a new tree based upon the information. The existing tree is deleted unconditionally.

Note for this to work, you need to make the JDOM package available in your distribution. Consult http://www.jdom.org for latest releases etc.

Parameters:
is - Inputstream to read XML from
Returns:
Error message, or null if no error

makeNodeFromXMLRecursive

protected javax.swing.tree.MutableTreeNode makeNodeFromXMLRecursive(org.jdom.Element xml_elem,
                                                                    boolean is_root)

outputXml

public void outputXml(java.io.OutputStream os)
               throws java.io.IOException

Builds an XML representation of the tree, as defined by infobank.dtd. Sends the textual data to the outputstream given.

Note for this to work, you need to make the JDOM package available in your distribution. Consult http://www.jdom.org for latest releases etc.

Parameters:
os - Outputstrem to send XML to

makeXMLNodeRecursive

protected org.jdom.Element makeXMLNodeRecursive(java.lang.Object node,
                                                boolean is_root)

getAddAboveAction

public javax.swing.Action getAddAboveAction()
Returns:
Action object suitable for triggering an "add node above"

getAddBelowAction

public javax.swing.Action getAddBelowAction()
Returns:
Action object suitable for triggering an "add node below"

getAddChildAction

public javax.swing.Action getAddChildAction()
Returns:
Action object suitable for triggering an "add child node"

getDeleteAction

public javax.swing.Action getDeleteAction()
Returns:
Action object suitable for triggering a "delete node"

getMakeAncestorAction

public javax.swing.Action getMakeAncestorAction()
Returns:
Action object suitable for triggering a "move node left"

getMakeChildAction

public javax.swing.Action getMakeChildAction()
Returns:
Action object suitable for triggering a "move node right"

getMoveDownAction

public javax.swing.Action getMoveDownAction()
Returns:
Action object suitable for triggering a "move node down"

getMoveUpAction

public javax.swing.Action getMoveUpAction()
Returns:
Action object suitable for triggering a "move node up"

getUndoAction

public javax.swing.Action getUndoAction()
Returns:
Action object suitable for triggering an "undo"

getRedoAction

public javax.swing.Action getRedoAction()
Returns:
Action object suitable for triggering a "redo last undo"

getCopyAction

public javax.swing.Action getCopyAction()
Returns:
Action object suitable for triggering a "copy selection"

getCutAction

public javax.swing.Action getCutAction()
Returns:
Action object suitable for triggering a "cut selection"

getPasteAction

public javax.swing.Action getPasteAction()
Returns:
Action object suitable for triggering a "paste"

getStartEditAction

public javax.swing.Action getStartEditAction()
Returns:
Action object suitable for triggering an "change node name"

getNextInstrumentId

public static long getNextInstrumentId()
Generates a unique ID. The main purpose is to generate unique instrument IDs for each instantiated instrument for use with Drag And Drop operations.
Returns:
A new unique instrument ID (unless we have wrapped the long)
See Also:
getMyInstrumentId()

getMyInstrumentId

public long getMyInstrumentId()
Retrieves my unique instrument ID
Returns:
Unique instrument ID (unless we have wrapped the long)
See Also:
getNextInstrumentId()

removeVetoableTreeStructureChangeListener

public void removeVetoableTreeStructureChangeListener(VetoableTreeStructureChangeListener l)
Removes a tree structure change listener.
Parameters:
l - Listener to remove

addVetoableTreeStructureChangeListener

public void addVetoableTreeStructureChangeListener(VetoableTreeStructureChangeListener l)
Adds a listener to changes in the tree structure. The listener can veto any changes.
Parameters:
l - Listener to add

fireNodeCreation

protected void fireNodeCreation(VetoableTreeStructureChangeEvent e)
                         throws VetoException
Fires a Node Creation event
Parameters:
Event - to send
Throws:
VetoException - if one of the listeners didn't like the change. In this case, the change should not take place.

fireNodeDeletion

protected void fireNodeDeletion(VetoableTreeStructureChangeEvent e)
                         throws VetoException
Fires a Node Deletion event
Parameters:
Event - to send
Throws:
VetoException - if one of the listeners didn't like the change. In this case, the change should not take place.

fireNodeMove

protected void fireNodeMove(VetoableTreeStructureChangeEvent e)
                     throws VetoException
Fires a Node Move event
Parameters:
Event - to send
Throws:
VetoException - if one of the listeners didn't like the change. In this case, the change should not take place.

fireNodeRename

protected void fireNodeRename(VetoableTreeStructureChangeEvent e)
                       throws VetoException
Fires a Node Rename event
Parameters:
Event - to send
Throws:
VetoException - if one of the listeners didn't like the change. In this case, the change should not take place.

instrument/JTree API Documentation