org.merlotxml.merlot
Class DOMTreeTableAdapter
java.lang.Object
|
+--com.sun.javax.swing.AbstractTreeTableModel
|
+--org.merlotxml.merlot.DNDJTreeTableModel
|
+--org.merlotxml.merlot.DOMTreeTableAdapter
- Direct Known Subclasses:
- MerlotLibraryTreeTableModel
- public class DOMTreeTableAdapter
- extends DNDJTreeTableModel
- implements MerlotNodeListener, MerlotConstants
Adapts a DOM Document object into a TreeTableModel
- Version:
- $Id: DOMTreeTableAdapter.java,v 1.13 2000/08/21 01:04:38 camk Exp $
- Author:
- Kelly A. Campbell
Fields inherited from class com.sun.javax.swing.AbstractTreeTableModel |
listenerList,
root |
Fields inherited from interface org.merlotxml.merlot.MerlotConstants |
ACTION_MENU_ACCELERATOR,
ACTION_MENU_ICON,
ACTION_NAME,
ACTION_SHORT_DESCRIPTION,
ACTION_SMALL_ICON,
AFTER,
BEFORE,
ERR,
INTO,
UI,
XML |
Method Summary |
void |
addStatusListener(StatusListener listener)
|
void |
cacheReset(MerlotDOMNode parent)
|
void |
childrenChanged(MerlotDOMNode nd)
reset the cache for a given node |
boolean |
dropOnRow(int row,
java.lang.Object data,
int where)
called by DNDJTreeTable when an object is dropped somewhere. |
protected java.util.Vector |
filterChildNodes(MerlotDOMNode nd)
This gets the set of child nodes for a given node, and filters
out stuff we don't want to display in the table (like #text nodes) |
void |
fireStatusChanged(StatusEvent evt)
|
void |
fireTreeStructureChanged(java.lang.Object source,
java.lang.Object[] path)
|
java.lang.Object |
getChild(java.lang.Object node,
int n)
|
int |
getChildCount(java.lang.Object node)
|
java.lang.Class |
getColumnClass(int column)
|
int |
getColumnCount()
|
java.lang.String |
getColumnName(int column)
|
MerlotDOMDocument |
getDocument()
|
int[] |
getLocationPathForNode(MerlotDOMNode nd)
This gets the location of a node specified by the indices of the
nodes in the path within their parent containers. |
MerlotDOMNode |
getNodeAtRow(int row)
|
java.lang.String |
getPCDATA(org.w3c.dom.Node nd)
Returns any PCDATA as a string if it exists as a "#text" child node of
the given node or null |
java.awt.datatransfer.Transferable |
getTransferable(javax.swing.tree.TreePath[] paths)
returns a MerlotDOMFragment containing the nodes in the paths |
java.lang.Object[] |
getTreePathForNode(MerlotDOMNode nd)
builds the path from this object up to the root and then make an array with
it in correct traversal order i.e. |
java.lang.Object |
getValueAt(java.lang.Object node,
int column)
|
javax.swing.undo.UndoableEdit |
importFragment(int row,
MerlotDOMFragment frag,
int where,
boolean paste)
Imports a fragment into the current document tree. |
javax.swing.undo.UndoableEdit |
importFragment(int row,
MerlotDOMFragment frag,
int where,
boolean paste,
boolean pruneLibItems)
|
void |
nodeChanged(MerlotDOMNode parent,
int[] i,
MerlotDOMNode[] children)
|
void |
nodeDeleted(MerlotDOMNode nd)
|
protected void |
nodeEvent(int event,
MerlotDOMNode parent,
int[] childIndices,
MerlotDOMNode[] children)
|
void |
nodeInserted(MerlotDOMNode parent,
int[] i,
MerlotDOMNode[] children)
triggers the proper event to notify a node of a child being added
in the tree display |
void |
nodeRemoved(MerlotDOMNode parent,
int[] i,
MerlotDOMNode[] children)
notifies the listener that one or more nodes under the given parent
were deleted. |
void |
removeStatusListener(StatusListener listener)
|
void |
setColumns(java.lang.String[] attr,
java.lang.String[] names)
|
void |
setJTreeTable(com.sun.javax.swing.JTreeTable table)
|
void |
setUndoManager(javax.swing.undo.UndoManager m)
|
Methods inherited from class com.sun.javax.swing.AbstractTreeTableModel |
addTreeModelListener,
fireTreeNodesChanged,
fireTreeNodesInserted,
fireTreeNodesRemoved,
fireTreeStructureChanged,
getIndexOfChild,
getRoot,
isCellEditable,
isLeaf,
removeTreeModelListener,
setValueAt,
valueForPathChanged |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
NODE_INSERTED_EVENT
protected static final int NODE_INSERTED_EVENT
NODE_REMOVED_EVENT
protected static final int NODE_REMOVED_EVENT
NODE_CHANGED_EVENT
protected static final int NODE_CHANGED_EVENT
ELEMENT
public static final java.lang.String ELEMENT
_children_of_the_nodes
protected java.util.Hashtable _children_of_the_nodes
_root
protected MerlotDOMNode _root
_undoManager
protected javax.swing.undo.UndoManager _undoManager
_file
protected XMLFile _file
_statusListeners
protected java.util.Vector _statusListeners
_table
protected com.sun.javax.swing.JTreeTable _table
- The tree whcih we need to have a ref to when inserting new nodes so we can select the new row
DOMTreeTableAdapter
public DOMTreeTableAdapter(XMLFile file)
DOMTreeTableAdapter
public DOMTreeTableAdapter(MerlotDOMNode root)
getDocument
public MerlotDOMDocument getDocument()
setUndoManager
public void setUndoManager(javax.swing.undo.UndoManager m)
getColumnCount
public int getColumnCount()
- Overrides:
- getColumnCount in class com.sun.javax.swing.AbstractTreeTableModel
getColumnClass
public java.lang.Class getColumnClass(int column)
- Overrides:
- getColumnClass in class com.sun.javax.swing.AbstractTreeTableModel
getColumnName
public java.lang.String getColumnName(int column)
- Overrides:
- getColumnName in class com.sun.javax.swing.AbstractTreeTableModel
setColumns
public void setColumns(java.lang.String[] attr,
java.lang.String[] names)
getValueAt
public java.lang.Object getValueAt(java.lang.Object node,
int column)
- Overrides:
- getValueAt in class com.sun.javax.swing.AbstractTreeTableModel
getChild
public java.lang.Object getChild(java.lang.Object node,
int n)
- Overrides:
- getChild in class com.sun.javax.swing.AbstractTreeTableModel
getChildCount
public int getChildCount(java.lang.Object node)
- Overrides:
- getChildCount in class com.sun.javax.swing.AbstractTreeTableModel
filterChildNodes
protected java.util.Vector filterChildNodes(MerlotDOMNode nd)
- This gets the set of child nodes for a given node, and filters
out stuff we don't want to display in the table (like #text nodes)
- Returns:
- a vector of Node's
childrenChanged
public void childrenChanged(MerlotDOMNode nd)
- reset the cache for a given node
nodeEvent
protected void nodeEvent(int event,
MerlotDOMNode parent,
int[] childIndices,
MerlotDOMNode[] children)
nodeInserted
public void nodeInserted(MerlotDOMNode parent,
int[] i,
MerlotDOMNode[] children)
- triggers the proper event to notify a node of a child being added
in the tree display
- Specified by:
- nodeInserted in interface MerlotNodeListener
nodeRemoved
public void nodeRemoved(MerlotDOMNode parent,
int[] i,
MerlotDOMNode[] children)
- Description copied from interface: MerlotNodeListener
- notifies the listener that one or more nodes under the given parent
were deleted. Their previous indices are given.
- Specified by:
- nodeRemoved in interface MerlotNodeListener
nodeChanged
public void nodeChanged(MerlotDOMNode parent,
int[] i,
MerlotDOMNode[] children)
- Specified by:
- nodeChanged in interface MerlotNodeListener
nodeDeleted
public void nodeDeleted(MerlotDOMNode nd)
- Specified by:
- nodeDeleted in interface MerlotNodeListener
cacheReset
public void cacheReset(MerlotDOMNode parent)
getLocationPathForNode
public int[] getLocationPathForNode(MerlotDOMNode nd)
- This gets the location of a node specified by the indices of the
nodes in the path within their parent containers. This creates a
snapshot of where a node was located at a certain time specifically
for undoing operations
getTreePathForNode
public java.lang.Object[] getTreePathForNode(MerlotDOMNode nd)
- builds the path from this object up to the root and then make an array with
it in correct traversal order i.e. root down
fireTreeStructureChanged
public void fireTreeStructureChanged(java.lang.Object source,
java.lang.Object[] path)
getPCDATA
public java.lang.String getPCDATA(org.w3c.dom.Node nd)
- Returns any PCDATA as a string if it exists as a "#text" child node of
the given node or null
setJTreeTable
public void setJTreeTable(com.sun.javax.swing.JTreeTable table)
dropOnRow
public boolean dropOnRow(int row,
java.lang.Object data,
int where)
- called by DNDJTreeTable when an object is dropped somewhere.
Hands off the object to importFragment.
- Overrides:
- dropOnRow in class DNDJTreeTableModel
- Tags copied from class: DNDJTreeTableModel
- Parameters:
row
- the row affecteddata
- the data being droppedwhere
- INTO, BEFORE, or AFTER
getNodeAtRow
public MerlotDOMNode getNodeAtRow(int row)
importFragment
public javax.swing.undo.UndoableEdit importFragment(int row,
MerlotDOMFragment frag,
int where,
boolean paste)
- Imports a fragment into the current document tree. If the fragment is from
another document, then it is copied. If it is from the current document,
and this is not a paste operation, then it is moved.
(Actually imported, and the old one is deleted).
- Returns:
- an undoable edit if successfull, null otherwise
importFragment
public javax.swing.undo.UndoableEdit importFragment(int row,
MerlotDOMFragment frag,
int where,
boolean paste,
boolean pruneLibItems)
getTransferable
public java.awt.datatransfer.Transferable getTransferable(javax.swing.tree.TreePath[] paths)
- returns a MerlotDOMFragment containing the nodes in the paths
- Overrides:
- getTransferable in class DNDJTreeTableModel
addStatusListener
public void addStatusListener(StatusListener listener)
removeStatusListener
public void removeStatusListener(StatusListener listener)
fireStatusChanged
public void fireStatusChanged(StatusEvent evt)