com.alveole.studio.web.data
Class Project

java.lang.Object
  extended by com.alveole.studio.web.data.Project

public class Project
extends java.lang.Object

This represents the whole project. A project contains some properties, some features, and a list of linked nodes, organized in packages.

Author:
sylvain

Nested Class Summary
static class Project.MyNamespaceContext
          Namespace context.
 
Field Summary
protected  java.lang.String description
          Contains project description.
protected  java.util.ArrayList<java.lang.String> enabledFeatures
          List of enables features on this project.
protected  java.util.ArrayList<NodeLink> links
          The list of all links.
protected  java.util.ArrayList<ProjectChangeListener> listeners
          List of all project listeners.
protected  java.lang.String name
          The project name.
protected  ProjectContext projectContext
          Reference to this project's context.
protected  org.w3c.dom.Document projectProperties
          Contains project properties.
protected  NodePackage rootPackage
          Root package.
static java.lang.String version
          Current version.
static java.lang.String[] versions
          All managed versions.
static java.lang.String xmlns
          Default namespace.
 
Constructor Summary
Project(ProjectContext projectContext)
          Project's contructor.
 
Method Summary
 void addFeature(java.lang.String feature)
          Add a feature on this project.
 void addLink(NodeLink link)
          Add a new link in project.
 void addProjectChangeListener(ProjectChangeListener pcl)
          Add a project's listener.
static org.w3c.dom.Element copyNode(org.w3c.dom.Element source)
          Copy DOM nodes from document.
static void copyTree(org.w3c.dom.Element source, org.w3c.dom.Node target)
          Copy DOM nodes from one document to another.
static ProjectContext createEmptyProject(org.eclipse.core.resources.IResource resource, java.lang.String projectName, java.lang.String description)
          Create a new project.
 void fireChangeEvent(ProjectChangeListener.EventType eventType, java.lang.Object evt)
          Fire change event.
 void fireChangeEvent(ProjectChangeListener.EventType eventType, java.lang.Object evt, java.lang.Object parameter)
          Fire change event.
 java.util.ArrayList<NodeAction> getAllActions()
          This method returns ALL actions from this project.
 void getAllActions(java.util.ArrayList<NodeAction> retOut, NodePackage pack)
          This method returns ALL actions from this package.
 java.util.ArrayList<NodePackage> getAllPackages()
          This method returns ALL packages from this project.
 void getAllPackages(java.util.ArrayList<NodePackage> retOut, NodePackage pack)
          This method returns ALL packages from this package excluding this pack.
 java.util.ArrayList<NodeView> getAllViews()
          This method returns ALL actions from this project.
 void getAllViews(java.util.ArrayList<NodeView> retOut, NodePackage pack)
          This method returns ALL views from this package.
static java.lang.String getAttributeNS(org.w3c.dom.Element elt, java.lang.String ns, java.lang.String localname)
          Tool to get an attribute, with its namespace.
 java.lang.String getDescription()
          Get project's description.
 java.util.ArrayList<java.lang.String> getEnabledFeatures()
          Get a list of enabled features.
 java.util.Collection<NodeLink> getLinks()
          Get all links.
 java.util.ArrayList<NodeLink> getLinksFrom(NodeContainer container)
          Get all links from a node.
 java.util.ArrayList<NodeLink> getLinksTo(NodeContainer container)
          Get all links to a node.
 java.lang.String getName()
          Get project's name.
 NodeContainer getNodeByID(java.lang.String id)
          Find a node given its ID.
static javax.xml.namespace.NamespaceContext getNSContext()
          Get default NS resolver.
 org.w3c.dom.Element getPluginProperties(java.lang.String id)
          Get the plugin properties' root node.
 ProjectContext getProjectContext()
          Get this project's context.
 NodePackage getRootPackage()
          Get root package for thid project.
 boolean isChildNode(NodeContainer child)
          Check if a node is inside this project.
protected  void loadLinks(org.w3c.dom.Document document)
          Load links.
static Project loadProject(ProjectContext ctx, org.eclipse.core.resources.IFile file)
          Loads a project.
static Project loadProject(ProjectContext ctx, java.io.InputStream is)
          Loads a project.
 void performCopy(java.util.List<NodeContainer> selection, NodePackage target)
          Performs a copy from a selection of nodes, to a new package.
 void removeLink(NodeLink link)
          Remove a new link in project.
 void removeProjectChangeListener(ProjectChangeListener pcl)
          Remove project's listener.
 byte[] saveProject(org.w3c.dom.Document document)
          Converts this project to bytes array (to store it in a file).
 org.w3c.dom.Document saveProject(org.eclipse.core.resources.IFile projectFile, org.eclipse.core.runtime.IProgressMonitor monitor)
          Save project to file.
 org.w3c.dom.Document saveProject(org.eclipse.core.resources.IFile projectFile, org.eclipse.core.runtime.IProgressMonitor monitor, boolean fireEvent)
          Save project to file.
 org.w3c.dom.Document saveProjectToXML()
          Save document to XML.
static void setAttributeNS(org.w3c.dom.Element elt, java.lang.String attributeNS, java.lang.String attributePrefix, java.lang.String attributeName, java.lang.String value)
          Sets an attribute with NS and prefix.
 void setDescription(java.lang.String description)
          Set project's description.
 void setEnabledFeatures(java.util.ArrayList<java.lang.String> enabledFeatures)
          Set a list of enabled features.
 void setName(java.lang.String name)
          Set project's name.
 void setProjectContext(ProjectContext projectContext)
          Set this project's context.
 void setRootPackage(NodePackage rootPackage)
          Sets root package for this project.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmlns

public static final java.lang.String xmlns
Default namespace.

See Also:
Constant Field Values

versions

public static final java.lang.String[] versions
All managed versions.


version

public static final java.lang.String version
Current version.

See Also:
Constant Field Values

name

protected java.lang.String name
The project name. [WARNING]: Should only contain simple characters [a-zA-Z0-9_.-].


description

protected java.lang.String description
Contains project description.


projectProperties

protected org.w3c.dom.Document projectProperties
Contains project properties.


rootPackage

protected NodePackage rootPackage
Root package.


projectContext

protected ProjectContext projectContext
Reference to this project's context.


links

protected java.util.ArrayList<NodeLink> links
The list of all links.


listeners

protected java.util.ArrayList<ProjectChangeListener> listeners
List of all project listeners.


enabledFeatures

protected java.util.ArrayList<java.lang.String> enabledFeatures
List of enables features on this project.

Constructor Detail

Project

public Project(ProjectContext projectContext)
Project's contructor.

Parameters:
projectContext - The associated context.
Method Detail

getDescription

public java.lang.String getDescription()
Get project's description.

Returns:
description the description.

setDescription

public void setDescription(java.lang.String description)
Set project's description.

Parameters:
description - The description.

getName

public java.lang.String getName()
Get project's name.

Returns:
the project name.

setName

public void setName(java.lang.String name)
Set project's name.

Parameters:
name - The project name.

getNodeByID

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

Parameters:
id - The Node ID.
Returns:
the node or null if not found.

isChildNode

public boolean isChildNode(NodeContainer child)
Check if a node is inside this project.

Parameters:
child - The node to search.
Returns:
true If the node is found.

saveProject

public org.w3c.dom.Document saveProject(org.eclipse.core.resources.IFile projectFile,
                                        org.eclipse.core.runtime.IProgressMonitor monitor,
                                        boolean fireEvent)
Save project to file.

Parameters:
projectFile - The file where XML DOM must be stored.
monitor - A monitor.

saveProject

public org.w3c.dom.Document saveProject(org.eclipse.core.resources.IFile projectFile,
                                        org.eclipse.core.runtime.IProgressMonitor monitor)
Save project to file.

Parameters:
projectFile - The file where XML DOM must be stored.
monitor - A monitor.

saveProjectToXML

public org.w3c.dom.Document saveProjectToXML()
Save document to XML. Create a DOM document for the whole project's contents.

Returns:
The create Document.

saveProject

public byte[] saveProject(org.w3c.dom.Document document)
Converts this project to bytes array (to store it in a file).

Parameters:
document - The XML document.
Returns:
the bytes.

loadProject

public static Project loadProject(ProjectContext ctx,
                                  org.eclipse.core.resources.IFile file)
Loads a project.

Parameters:
ctx - The context.
file - The project's file.
Returns:
a new Project instance.

createEmptyProject

public static ProjectContext createEmptyProject(org.eclipse.core.resources.IResource resource,
                                                java.lang.String projectName,
                                                java.lang.String description)
Create a new project.

Parameters:
resource - The target IResource.
projectName - The project's name.
description - The project's description.
Returns:
The project context.

copyTree

public static void copyTree(org.w3c.dom.Element source,
                            org.w3c.dom.Node target)
Copy DOM nodes from one document to another.

Parameters:
source - The DOM element source.
target - The target DOM Node.

copyNode

public static org.w3c.dom.Element copyNode(org.w3c.dom.Element source)
Copy DOM nodes from document. The resulting element is not automatically added to document.

Parameters:
source - The DOM element source.

loadProject

public static Project loadProject(ProjectContext ctx,
                                  java.io.InputStream is)
Loads a project.

Parameters:
ctx - The project context.
is - The input Stream for reading data.

getNSContext

public static final javax.xml.namespace.NamespaceContext getNSContext()
Get default NS resolver.


loadLinks

protected void loadLinks(org.w3c.dom.Document document)
                  throws java.lang.Exception
Load links.

Parameters:
document - The XML DOM document.
Throws:
java.lang.Exception

getLinksFrom

public java.util.ArrayList<NodeLink> getLinksFrom(NodeContainer container)
Get all links from a node.

Parameters:
container - The node.
Returns:
The list of all links.

getLinksTo

public java.util.ArrayList<NodeLink> getLinksTo(NodeContainer container)
Get all links to a node.

Parameters:
container - The node.
Returns:
The list of all links.

getLinks

public java.util.Collection<NodeLink> getLinks()
Get all links.

Returns:
The list of all raw links.

getRootPackage

public NodePackage getRootPackage()
Get root package for thid project.

Returns:
The root package.

setRootPackage

public void setRootPackage(NodePackage rootPackage)
Sets root package for this project.

Parameters:
rootPackage - The root package.

fireChangeEvent

public void fireChangeEvent(ProjectChangeListener.EventType eventType,
                            java.lang.Object evt)
Fire change event. On Node removal, also remove all links from removed node.

Parameters:
eventType - The event type.
evt - A specific object on which the event applies.

fireChangeEvent

public void fireChangeEvent(ProjectChangeListener.EventType eventType,
                            java.lang.Object evt,
                            java.lang.Object parameter)
Fire change event. On Node removal, also remove all links from removed node.

Parameters:
eventType - The event type.
evt - A specific object on which the event applies.
parameter - A specific parameter for this events.

addProjectChangeListener

public void addProjectChangeListener(ProjectChangeListener pcl)
Add a project's listener.

Parameters:
pcl - the listener.

removeProjectChangeListener

public void removeProjectChangeListener(ProjectChangeListener pcl)
Remove project's listener.

Parameters:
pcl - The listener.

addLink

public void addLink(NodeLink link)
Add a new link in project.

Parameters:
link - The link.

removeLink

public void removeLink(NodeLink link)
Remove a new link in project.

Parameters:
link - The removed link.

getProjectContext

public ProjectContext getProjectContext()
Get this project's context.

Returns:
The context.

setProjectContext

public void setProjectContext(ProjectContext projectContext)
Set this project's context.

Parameters:
projectContext - The context.

getPluginProperties

public org.w3c.dom.Element getPluginProperties(java.lang.String id)
Get the plugin properties' root node. Create it if necessary. [WARNING]: id should not contain special char (no space, just [a-zA-Z0-9_.-]).

Parameters:
id - A plugin ID.
Returns:
The XML properties root Node.

performCopy

public void performCopy(java.util.List<NodeContainer> selection,
                        NodePackage target)
Performs a copy from a selection of nodes, to a new package.

Parameters:
selection - A selection of nodes.
target - The target package where to drop nodes.

getEnabledFeatures

public java.util.ArrayList<java.lang.String> getEnabledFeatures()
Get a list of enabled features.

Returns:
Tle list of features.

setEnabledFeatures

public void setEnabledFeatures(java.util.ArrayList<java.lang.String> enabledFeatures)
Set a list of enabled features.

Parameters:
enabledFeatures - List of features.

addFeature

public void addFeature(java.lang.String feature)
Add a feature on this project.

Parameters:
feature - The feature to be added.

setAttributeNS

public static void setAttributeNS(org.w3c.dom.Element elt,
                                  java.lang.String attributeNS,
                                  java.lang.String attributePrefix,
                                  java.lang.String attributeName,
                                  java.lang.String value)
Sets an attribute with NS and prefix.

Parameters:
elt - The target element.
attributeNS - The namespace.
attributePrefix - The attribute prefix (must belong to namespace).
attributeName - The attribute localname.
value - The attribute value;

getAttributeNS

public static java.lang.String getAttributeNS(org.w3c.dom.Element elt,
                                              java.lang.String ns,
                                              java.lang.String localname)
Tool to get an attribute, with its namespace.


getAllActions

public void getAllActions(java.util.ArrayList<NodeAction> retOut,
                          NodePackage pack)
This method returns ALL actions from this package.


getAllActions

public java.util.ArrayList<NodeAction> getAllActions()
This method returns ALL actions from this project.


getAllViews

public void getAllViews(java.util.ArrayList<NodeView> retOut,
                        NodePackage pack)
This method returns ALL views from this package.


getAllViews

public java.util.ArrayList<NodeView> getAllViews()
This method returns ALL actions from this project.


getAllPackages

public void getAllPackages(java.util.ArrayList<NodePackage> retOut,
                           NodePackage pack)
This method returns ALL packages from this package excluding this pack.


getAllPackages

public java.util.ArrayList<NodePackage> getAllPackages()
This method returns ALL packages from this project.