| java.lang.Object javax.swing.tree.DefaultTreeModel com.jgraph.editor.JGraphEditorModel
JGraphEditorModel | public class JGraphEditorModel extends DefaultTreeModel (Code) | | Default document model for JGraph editors. This class is in charge of
preparing the bean info classes and has a map of persistence delegate for XML
encoding. You should use the writeObject and readObject method of this class
for file I/O to properly use the registered peristence delegates.
Note: The API refers to the children of the
JGraphEditorModel.rootNode as roots.
|
Constructor Summary | |
public | JGraphEditorModel() Constructs a new JGraph editor model adding persistence delegates for the
DefaultGraphModel, GraphLayoutCache and DefaultEdge.DefaultRouting
classes. |
Method Summary | |
public MutableTreeNode | addChild(MutableTreeNode child, MutableTreeNode parent) Adds the specified child to parent . | public Object | addFile(String uri) Reads the specified URI and adds it as a root.
Parameters: uri - The URI to read the object from. | public Object | addPersistenceDelegate(Class clazz, PersistenceDelegate delegate) Associates the specified persistence delegate with clazz
for XML encoding.
Parameters: clazz - The class to associate the delegate with. | public MutableTreeNode | addRoot(MutableTreeNode node) Adds the specified root as a child to
JGraphEditorModel.rootNode . | protected void | configureEncoder(XMLEncoder enc) Hook for subclassers to configure a new XML encoder for writing an
object. | public JGraphEditorFile | getFileByFilename(String filename) Returns the file for the specified filename if it is in the model or
null if no such file exists.
Parameters: filename - The filename to return the file for. | public InputStream | getInputStream(String uri) Hook for subclassers to create an input stream for the specified URI.
This implementation creates an input stream using
JGraphEditorResources.getInputStream(String) and wraps it in a
GZIPInputStream if the URI ends with .gz .
Parameters: uri - The URI to return the input stream for. | public OutputStream | getOutputStream(String uri) Hook for subclassers to create an output stream for the specified URI.
This implementation creates an output stream using
JGraphEditorResources.getOutputStream(String) and wraps it in a
java.util.zip.GZIPOutputStream if the URI ends with
.gz .
Parameters: uri - The URI to return the output stream for. | public static JGraphEditorFile | getParentFile(TreeNode node) Returns the parent file for node or the node itself, if it
is a file. | public PersistenceDelegate | getPersistenceDelegate(Class clazz) Returns the associated persistence delegate for clazz or
null if no association exists.
Parameters: clazz - The clazz to return the delegate for. | protected void | installDiagramListeners(JGraphEditorDiagram diagram) Installs the listeners required to update the modified state of the
parent file node to diagram . | protected void | installListeners(TreeNode node) Hook for subclassers to install the required listeners in new tree nodes. | public static void | makeCellViewFieldsTransient(Class clazz) Makes all fields but cell and attributes
transient in the bean info of clazz . | public static void | makeTransient(Class clazz, String field) Makes the specified field transient in the bean info of
clazz . | public Object | readObject(InputStream in) Returns a new object from the specified stream using a new XML decoder.
This method does nothing special. | public Enumeration | roots() Returns the first generation of childs, aka roots. | public void | setFilename(JGraphEditorFile file, String filename) Sets the filename of the specified file and dispatches a notification
event. | public void | setModified(JGraphEditorFile file, boolean modified) Sets the modified state of the specified file and dispatches a
notification event. | public void | setName(JGraphEditorDiagram diagram, String name) Sets the name of the specified diagram and dispatches a notification
event. | public void | setUserObject(TreeNode node, Object userObject) Sets the user object of the specified node and dispatches a notification
event. | public void | writeObject(Object object, OutputStream out) Writes the specified object to the output stream using an xml encoder
which was configured using
JGraphEditorModel.configureEncoder(XMLEncoder) . |
persistenceDelegates | protected Map persistenceDelegates(Code) | | Holds the (class, persistence delegate) pairs.
|
JGraphEditorModel | public JGraphEditorModel()(Code) | | Constructs a new JGraph editor model adding persistence delegates for the
DefaultGraphModel, GraphLayoutCache and DefaultEdge.DefaultRouting
classes. This also adds a tree model listener to this model to update the
modified state of parent files for child changes.
|
addPersistenceDelegate | public Object addPersistenceDelegate(Class clazz, PersistenceDelegate delegate)(Code) | | Associates the specified persistence delegate with clazz
for XML encoding.
Parameters: clazz - The class to associate the delegate with. Returns the previous delegate for clazz . |
configureEncoder | protected void configureEncoder(XMLEncoder enc)(Code) | | Hook for subclassers to configure a new XML encoder for writing an
object. This implementation sets all registered persistence delegates and
installs default mappings for classes (eg. it assigns the list
persistence delegates to array lists).
Parameters: enc - The encoder to be configured. |
getFileByFilename | public JGraphEditorFile getFileByFilename(String filename)(Code) | | Returns the file for the specified filename if it is in the model or
null if no such file exists.
Parameters: filename - The filename to return the file for. Returns the file for filename or null . |
getParentFile | public static JGraphEditorFile getParentFile(TreeNode node)(Code) | | Returns the parent file for node or the node itself, if it
is a file. This method returns null if no parent file is
found for node .
Parameters: node - The node to find the parent file for. Returns the parent file for node, the node itself ornull . |
getPersistenceDelegate | public PersistenceDelegate getPersistenceDelegate(Class clazz)(Code) | | Returns the associated persistence delegate for clazz or
null if no association exists.
Parameters: clazz - The clazz to return the delegate for. Returns the persistence delegate for clazz ornull . |
installDiagramListeners | protected void installDiagramListeners(JGraphEditorDiagram diagram)(Code) | | Installs the listeners required to update the modified state of the
parent file node to diagram . This implementation adds a
graph layout cache listener and a graph model listener.
Parameters: diagram - The diagram to install the listeners to. |
makeCellViewFieldsTransient | public static void makeCellViewFieldsTransient(Class clazz)(Code) | | Makes all fields but cell and attributes
transient in the bean info of clazz .
Parameters: clazz - The cell view class who fields should be made transient. |
makeTransient | public static void makeTransient(Class clazz, String field)(Code) | | Makes the specified field transient in the bean info of
clazz .
Parameters: clazz - The class whos field should be made transient. Parameters: field - The name of the field that should be made transient. |
readObject | public Object readObject(InputStream in)(Code) | | Returns a new object from the specified stream using a new XML decoder.
This method does nothing special. Subclassers can override this method if
they need to do anything special with opened files.
Note: You should use this method as a global hook to read all XML files.
Returns a new object from the specified stream. |
roots | public Enumeration roots()(Code) | | Returns the first generation of childs, aka roots. This usually returns
the documents and repositories, eg files that are currently open.
Returns the children of JGraphEditorModel.rootNode. |
setFilename | public void setFilename(JGraphEditorFile file, String filename)(Code) | | Sets the filename of the specified file and dispatches a notification
event.
Parameters: file - The file to change the filename for. Parameters: filename - The new filename. |
setModified | public void setModified(JGraphEditorFile file, boolean modified)(Code) | | Sets the modified state of the specified file and dispatches a
notification event.
Parameters: file - The file to change the modified state for. Parameters: modified - The new modified state. |
setName | public void setName(JGraphEditorDiagram diagram, String name)(Code) | | Sets the name of the specified diagram and dispatches a notification
event.
Parameters: diagram - The diagram to change the name for. Parameters: name - The new name. |
setUserObject | public void setUserObject(TreeNode node, Object userObject)(Code) | | Sets the user object of the specified node and dispatches a notification
event.
Parameters: node - The node to change the user object for. Parameters: userObject - The new user object. |
writeObject | public void writeObject(Object object, OutputStream out)(Code) | | Writes the specified object to the output stream using an xml encoder
which was configured using
JGraphEditorModel.configureEncoder(XMLEncoder) . The
exceptions that are thrown during encoding are caught by a local handler
and passed to the caller as a RuntimeException with description of the
encoding problems.
Note: You should use this method as a global hook to write all XML files.
Parameters: object - The object to be written. Parameters: out - The output strem to write to. throws: RuntimeException - If there are problems during encoding. |
Methods inherited from javax.swing.tree.DefaultTreeModel | public void addTreeModelListener(TreeModelListener l)(Code)(Java Doc) public boolean asksAllowsChildren()(Code)(Java Doc) protected void fireTreeNodesChanged(Object source, Object[] path, int[] childIndices, Object[] children)(Code)(Java Doc) protected void fireTreeNodesInserted(Object source, Object[] path, int[] childIndices, Object[] children)(Code)(Java Doc) protected void fireTreeNodesRemoved(Object source, Object[] path, int[] childIndices, Object[] children)(Code)(Java Doc) protected void fireTreeStructureChanged(Object source, Object[] path, int[] childIndices, Object[] children)(Code)(Java Doc) public Object getChild(Object parent, int index)(Code)(Java Doc) public int getChildCount(Object parent)(Code)(Java Doc) public int getIndexOfChild(Object parent, Object child)(Code)(Java Doc) public T[] getListeners(Class<T> listenerType)(Code)(Java Doc) public TreeNode[] getPathToRoot(TreeNode aNode)(Code)(Java Doc) protected TreeNode[] getPathToRoot(TreeNode aNode, int depth)(Code)(Java Doc) public Object getRoot()(Code)(Java Doc) public TreeModelListener[] getTreeModelListeners()(Code)(Java Doc) public void insertNodeInto(MutableTreeNode newChild, MutableTreeNode parent, int index)(Code)(Java Doc) public boolean isLeaf(Object node)(Code)(Java Doc) public void nodeChanged(TreeNode node)(Code)(Java Doc) public void nodeStructureChanged(TreeNode node)(Code)(Java Doc) public void nodesChanged(TreeNode node, int[] childIndices)(Code)(Java Doc) public void nodesWereInserted(TreeNode node, int[] childIndices)(Code)(Java Doc) public void nodesWereRemoved(TreeNode node, int[] childIndices, Object[] removedChildren)(Code)(Java Doc) public void reload()(Code)(Java Doc) public void reload(TreeNode node)(Code)(Java Doc) public void removeNodeFromParent(MutableTreeNode node)(Code)(Java Doc) public void removeTreeModelListener(TreeModelListener l)(Code)(Java Doc) public void setAsksAllowsChildren(boolean newValue)(Code)(Java Doc) public void setRoot(TreeNode root)(Code)(Java Doc) public void valueForPathChanged(TreePath path, Object newValue)(Code)(Java Doc)
|
|
|