com.alveole.studio.web.designer.graph
Class PackageNavigatorModel

java.lang.Object
  extended by com.alveole.studio.web.designer.graph.PackageNavigatorModel
All Implemented Interfaces:
ProjectChangeListener

public class PackageNavigatorModel
extends java.lang.Object
implements ProjectChangeListener

This class is the model, for the PackageNavigatorEditor.

Author:
sylvain

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.alveole.studio.web.data.ProjectChangeListener
ProjectChangeListener.EventType
 
Constructor Summary
PackageNavigatorModel(PackageNavigatorEditor editor)
          constructor.
 
Method Summary
 void appendBackHistory()
          Adds current package element to back history.
 void appendFwdHistory(NodePackage p)
          Adds an element to fwd history.
 boolean canBack()
          Check if back button should be enabled.
 boolean canForward()
          Check if forward button should be enabled.
 void clearFwdHistory()
          Clears fwd history.
 void createAction(ActionManager manager)
          Creates a action using the given manager.
 void createCurrentPackageLink(NodeContainer node2)
          Create a link between current package and a target node.
protected  void createGraphModel()
          Creates the graph model.
 void createLink(NodeContainer node1, NodeContainer node2)
          Create a ling between two nodes.
 void createNewPackage()
          Create a new package: display a form, and create new package on OK.
 void createView(ViewManager manager)
          Creates a view using the given manager.
 void deleteCurrentPackageLink(NodeContainer node2)
          Create a link between current package and a target node.
protected  void deleteSelection(java.util.List<NodeLink> selectedLinks, java.util.List<NodeContainer> selectedNodes)
          Perform deleting selection.
 void displayPackage(NodePackage pack)
          Create Vertices and edges given a package to display.
 void doCopyCutSelection(java.util.List<NodeLink> links, java.util.List<NodeContainer> nodes)
          Create clipboard on action "cut".
 void doCopySelection(java.util.List<NodeLink> links, java.util.List<NodeContainer> nodes)
          Create clipboard on action "copy".
protected  void doSave(org.eclipse.ui.IEditorInput editorInput, org.eclipse.core.runtime.IProgressMonitor monitor)
          Save to XML.
protected  void editActionSettings(NodeAction action, boolean shortView)
          Edit action settings.
 void editLink(NodeLink link, boolean shortView)
          Edit the selected link.
protected  void editPackageSettings(NodePackage pack)
          Edit package settings.
protected  void editViewSettings(NodeView view, boolean shortView)
          Edit view settings.
 NodePackage getBackPackage(boolean pop)
          Go to back directory or null if root.
 CurrentClipboard getClipboard()
           
 NodePackage getCurrentPackage()
          Get current edited package.
 java.util.Properties getCurrentPackageUIPreferences()
          Get package UI preferences.
protected  edu.uci.ics.jung.graph.Edge getEdge(NodeLink link)
          Get an Edge given a NodeLink.
 NodePackage getFwdPackage(boolean pop)
          Go to next directory or null if root.
protected  java.util.List<NodeContainer> getLinkedNodes(java.util.List<NodeContainer> current)
          Get a list of nodes that are linked to current package.
protected  java.util.List<NodeContainer> getLinkedNodes(NodeContainer current)
          Get a list of nodes that are linked to current package.
 PackageNavigatorEditor getNavigator()
          Get the associated view.
 java.util.List<NodeContainer> getPackageLinkableNodes(NodePackage targetPackage)
          Get a liste of nodes inside the given package, and remove those that are already linked to current package.
 ProjectContext getProjectContext()
          Gets the current project context.
 NodePackage getUpperPackage()
          Get upper directory or null if root.
 void init(org.eclipse.ui.IEditorInput input, org.eclipse.swt.widgets.Shell shell)
          Initialize this model.
 boolean isAllLinkedNodesVisible()
          Return wether linked nodes must be displayed.
 boolean isDirty()
           
 boolean isFeatureEnabled(java.lang.String name)
          Check if the given feature is enabled on project.
 boolean isPackageLinkedNodesVisible()
          Return wether current package's linked nodes must be displayed.
 boolean isPackageLinkedToNode(NodeContainer target)
          Check if a target is linked to currentPackage.
protected  void moveClipboard()
          Move clipboard to this package.
protected  void pasteClipboard()
          Paste clipboard copy to this package.
 void projectChanged(Project project2, ProjectChangeListener.EventType eventType, java.lang.Object change, java.lang.Object parameter)
          Handle change events and redraw graph locally.
protected  void purgeHistory()
          Limits history size.
 void setAllLinkedNodesVisible(boolean visible)
          Display or not, nodes that are linked to current package inner nodes.
 void setClipboard(CurrentClipboard clipboard)
           
 CurrentClipboard setClipboard(java.util.List<NodeLink> links, java.util.List<NodeContainer> nodes, boolean cut)
          Store a selection in clipboard.
 void setCurrentPackage(NodePackage currentPackage)
          Set current edited package.
 void setDirty(boolean value)
          Fire event about status dirty of this project.
 void setNavigator(PackageNavigatorEditor navigator)
          Set the associated view.
 void setPackageLinkedNodesVisible(boolean visible)
          Display or not, nodes that are linked to current package.
 void setProject(Project p)
          Change project's contents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PackageNavigatorModel

public PackageNavigatorModel(PackageNavigatorEditor editor)
constructor.

Parameters:
editor - The associated view.
Method Detail

getNavigator

public PackageNavigatorEditor getNavigator()
Get the associated view.

Returns:
The view.

setNavigator

public void setNavigator(PackageNavigatorEditor navigator)
Set the associated view.

Parameters:
navigator - the view.

getEdge

protected edu.uci.ics.jung.graph.Edge getEdge(NodeLink link)
Get an Edge given a NodeLink.


isPackageLinkedNodesVisible

public boolean isPackageLinkedNodesVisible()
Return wether current package's linked nodes must be displayed.


isAllLinkedNodesVisible

public boolean isAllLinkedNodesVisible()
Return wether linked nodes must be displayed. This concerns only nodes that are directly linked to nodes insite this package.


setPackageLinkedNodesVisible

public void setPackageLinkedNodesVisible(boolean visible)
Display or not, nodes that are linked to current package. Must be called on SWING thread.


getPackageLinkableNodes

public java.util.List<NodeContainer> getPackageLinkableNodes(NodePackage targetPackage)
Get a liste of nodes inside the given package, and remove those that are already linked to current package. This method is called by view to display a menu list of nodes that could be linked to current package.


isPackageLinkedToNode

public boolean isPackageLinkedToNode(NodeContainer target)
Check if a target is linked to currentPackage.


setAllLinkedNodesVisible

public void setAllLinkedNodesVisible(boolean visible)
Display or not, nodes that are linked to current package inner nodes. Warning: if package links are not displayed, remote linked package will not be displayed, event if the target package is linked to an inner node. This exception makes graph more readable: when package links are hidden and inner links are displayed, we only want to see links from one object to its real target. Must be called on SWING thread.


getLinkedNodes

protected java.util.List<NodeContainer> getLinkedNodes(NodeContainer current)
Get a list of nodes that are linked to current package.


getLinkedNodes

protected java.util.List<NodeContainer> getLinkedNodes(java.util.List<NodeContainer> current)
Get a list of nodes that are linked to current package.


createGraphModel

protected void createGraphModel()
Creates the graph model. Must be called on Swing thread.


getCurrentPackageUIPreferences

public java.util.Properties getCurrentPackageUIPreferences()
Get package UI preferences.


deleteSelection

protected void deleteSelection(java.util.List<NodeLink> selectedLinks,
                               java.util.List<NodeContainer> selectedNodes)
Perform deleting selection. MUST be called on SWT thread.


init

public void init(org.eclipse.ui.IEditorInput input,
                 org.eclipse.swt.widgets.Shell shell)
Initialize this model.


setDirty

public void setDirty(boolean value)
Fire event about status dirty of this project.

Parameters:
value -

getCurrentPackage

public NodePackage getCurrentPackage()
Get current edited package.

Returns:

setCurrentPackage

public void setCurrentPackage(NodePackage currentPackage)
Set current edited package.

Parameters:
currentPackage -

getProjectContext

public ProjectContext getProjectContext()
Gets the current project context.

Returns:

moveClipboard

protected void moveClipboard()
Move clipboard to this package. MUST be called in SWT thread.


pasteClipboard

protected void pasteClipboard()
Paste clipboard copy to this package. MUST be called in SWT thread.


doCopyCutSelection

public void doCopyCutSelection(java.util.List<NodeLink> links,
                               java.util.List<NodeContainer> nodes)
Create clipboard on action "cut".


doCopySelection

public void doCopySelection(java.util.List<NodeLink> links,
                            java.util.List<NodeContainer> nodes)
Create clipboard on action "copy".


setClipboard

public CurrentClipboard setClipboard(java.util.List<NodeLink> links,
                                     java.util.List<NodeContainer> nodes,
                                     boolean cut)
Store a selection in clipboard.


editLink

public void editLink(NodeLink link,
                     boolean shortView)
Edit the selected link.


displayPackage

public void displayPackage(NodePackage pack)
Create Vertices and edges given a package to display.

Parameters:
pack -

editActionSettings

protected void editActionSettings(NodeAction action,
                                  boolean shortView)
Edit action settings. MUST be called in SWT thread.


editViewSettings

protected void editViewSettings(NodeView view,
                                boolean shortView)
Edit view settings. MUST be called in SWT thread.


editPackageSettings

protected void editPackageSettings(NodePackage pack)
Edit package settings. MUST be called in SWT thread.


doSave

protected void doSave(org.eclipse.ui.IEditorInput editorInput,
                      org.eclipse.core.runtime.IProgressMonitor monitor)
Save to XML.


getClipboard

public CurrentClipboard getClipboard()

setClipboard

public void setClipboard(CurrentClipboard clipboard)

projectChanged

public void projectChanged(Project project2,
                           ProjectChangeListener.EventType eventType,
                           java.lang.Object change,
                           java.lang.Object parameter)
Handle change events and redraw graph locally.

Specified by:
projectChanged in interface ProjectChangeListener
Parameters:
project2 - The project.
eventType - The event type.
change - The event source.
parameter - The optional parameter.

isDirty

public boolean isDirty()

isFeatureEnabled

public boolean isFeatureEnabled(java.lang.String name)
Check if the given feature is enabled on project.


createAction

public void createAction(ActionManager manager)
Creates a action using the given manager.


createView

public void createView(ViewManager manager)
Creates a view using the given manager.


getUpperPackage

public NodePackage getUpperPackage()
Get upper directory or null if root.


purgeHistory

protected void purgeHistory()
Limits history size.


getBackPackage

public NodePackage getBackPackage(boolean pop)
Go to back directory or null if root.


getFwdPackage

public NodePackage getFwdPackage(boolean pop)
Go to next directory or null if root.


appendFwdHistory

public void appendFwdHistory(NodePackage p)
Adds an element to fwd history.


clearFwdHistory

public void clearFwdHistory()
Clears fwd history.


appendBackHistory

public void appendBackHistory()
Adds current package element to back history.


canForward

public boolean canForward()
Check if forward button should be enabled.


canBack

public boolean canBack()
Check if back button should be enabled.


createNewPackage

public void createNewPackage()
Create a new package: display a form, and create new package on OK. MUST be called on SWT thread.


createLink

public void createLink(NodeContainer node1,
                       NodeContainer node2)
Create a ling between two nodes.


createCurrentPackageLink

public void createCurrentPackageLink(NodeContainer node2)
Create a link between current package and a target node.


deleteCurrentPackageLink

public void deleteCurrentPackageLink(NodeContainer node2)
Create a link between current package and a target node.


setProject

public void setProject(Project p)
Change project's contents.