com.alveole.studio.web.data
Class NodePackage

java.lang.Object
  extended by com.alveole.studio.web.data.NodeContainer
      extended by com.alveole.studio.web.data.NodePackage

public class NodePackage
extends NodeContainer

This class represents a package. A package is a node that can contain other nodes. This kind of node is used to group parts of graph under a package (look like a directory). This enables a more readable graph.

Author:
sylvain

Field Summary
protected  org.w3c.dom.Document extensions
          A document to store plugins's specific extensions, that apply on this package.
protected  boolean forceLayout
          Check if layout should be forced, after any import for example.
protected  java.util.ArrayList<NodeContainer> subNodes
          List of all sub-nodes.
 
Fields inherited from class com.alveole.studio.web.data.NodeContainer
ID, label, parent, project, uiPreferences
 
Constructor Summary
NodePackage(Project project, NodePackage parent)
          Constructor.
 
Method Summary
<T> T
getAdapter(java.lang.Class<T> cls)
          Gets an adapter.
 NodeContainer getNodeByID(java.lang.String id)
          Find a node given its ID.
 org.w3c.dom.Element getPluginElement(java.lang.String name)
          Get plugin specific node (to store specific settings for that plugin on package).
 java.util.ArrayList<NodeContainer> getSubNodes()
          Get a list of all sub-nodes.
 boolean isChildNode(NodeContainer child)
          Check if a node is under this package (any descendants).
 boolean isForceLayout()
           
static void readNodes(Project project, NodePackage parent, org.w3c.dom.Element current, java.util.ArrayList<NodeContainer> subNodes)
          Unserialize some sub-nodes contained in this package.
 void serialize(org.w3c.dom.Element parent)
          Stored this package contents in XML node.
 void setForceLayout(boolean forceLayout)
           
 void setSubNodes(java.util.ArrayList<NodeContainer> subNodes)
          Sets a list of sub-nodes.
 void unserialize(org.w3c.dom.Element element)
          Read package contents from XML.
 
Methods inherited from class com.alveole.studio.web.data.NodeContainer
getID, getLabel, getParent, getProject, getUiPreferences, serializeUiPrefs, setID, setLabel, setParent, setProject, setUiPreferences, unserializeUiPrefs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

subNodes

protected java.util.ArrayList<NodeContainer> subNodes
List of all sub-nodes.


extensions

protected org.w3c.dom.Document extensions
A document to store plugins's specific extensions, that apply on this package.


forceLayout

protected boolean forceLayout
Check if layout should be forced, after any import for example.

Constructor Detail

NodePackage

public NodePackage(Project project,
                   NodePackage parent)
Constructor.

Parameters:
project - The project.
parent - A parent package.
Method Detail

serialize

public void serialize(org.w3c.dom.Element parent)
Stored this package contents in XML node.

Specified by:
serialize in class NodeContainer
Parameters:
parent - The parent XML node.

readNodes

public static void readNodes(Project project,
                             NodePackage parent,
                             org.w3c.dom.Element current,
                             java.util.ArrayList<NodeContainer> subNodes)
                      throws javax.xml.xpath.XPathException
Unserialize some sub-nodes contained in this package.

Parameters:
project - The current project.
parent - The current package to read in.
current - The current XML element in DOM document.
subNodes - List of returned sub-nodes for this package.
Throws:
javax.xml.xpath.XPathException

getPluginElement

public org.w3c.dom.Element getPluginElement(java.lang.String name)
Get plugin specific node (to store specific settings for that plugin on package).


unserialize

public void unserialize(org.w3c.dom.Element element)
                 throws javax.xml.xpath.XPathException
Read package contents from XML.

Specified by:
unserialize in class NodeContainer
Parameters:
element - The current XMl tag.
Throws:
javax.xml.xpath.XPathException - If XPath error.

getNodeByID

public NodeContainer getNodeByID(java.lang.String id)
Find a node given its ID.

Parameters:
id - A unique ID to find in sub-nodes.
Returns:
a node or null.

isChildNode

public boolean isChildNode(NodeContainer child)
Check if a node is under this package (any descendants).

Parameters:
child - The child node.
Returns:
true if the node is a descendant of thid package.

getSubNodes

public java.util.ArrayList<NodeContainer> getSubNodes()
Get a list of all sub-nodes.

Returns:
The list.

setSubNodes

public void setSubNodes(java.util.ArrayList<NodeContainer> subNodes)
Sets a list of sub-nodes.

Parameters:
subNodes - direct descendants.

getAdapter

public <T> T getAdapter(java.lang.Class<T> cls)
Gets an adapter. Not implemented for packages.

Specified by:
getAdapter in class NodeContainer
Parameters:
cls - A target class.
Returns:
null.

isForceLayout

public boolean isForceLayout()
Returns:
the forceLayout

setForceLayout

public void setForceLayout(boolean forceLayout)
Parameters:
forceLayout - the forceLayout to set