de.cau.cs.kieler.kiml.gmf
Class GmfDiagramLayoutManager

java.lang.Object
  extended by de.cau.cs.kieler.kiml.ui.layout.DiagramLayoutManager
      extended by de.cau.cs.kieler.kiml.gmf.GmfDiagramLayoutManager
Direct Known Subclasses:
MultiPartDiagramLayoutManager

public class GmfDiagramLayoutManager
extends DiagramLayoutManager

Diagram layout manager that is able to generically layout diagrams generated by GMF. The internal KGraph graph structure is built from the structure of edit parts in the diagram. The new layout is applied to the diagram using GmfLayoutEditPolicy, which creates a GmfLayoutCommand to directly manipulate data in the GMF notation model, where layout information is stored persistently.

Rating proposed yellow
(2009-12-11) msp

Field Summary
 
Fields inherited from class de.cau.cs.kieler.kiml.ui.layout.DiagramLayoutManager
MAX_PROGRESS_LEVELS
 
Constructor Summary
GmfDiagramLayoutManager()
           
 
Method Summary
 void addChangeListener(IEditorPart editorPart, IEditorChangeListener listener)
          Register a listener for change of the active editor or active selection.
protected  void applyLayout()
          Applies the transferred layout to the original diagram.
 KNode buildLayoutGraph(IEditorPart editorPart, EditPart editPart, boolean layoutAncestors)
          Builds a KGraph instance for the given editor or edit part.
protected  ICachedLayout getCachedLayout()
          Returns the cached layout for the last layout run.
 EditPart getCurrentEditPart()
          Returns the currently processed top level edit part.
 ILayoutInspector getInspector(EditPart editPart)
          Returns a layout inspector for the given edit part.
 KNode getLayoutGraph()
          Returns the last built layout graph.
 ISelection getSelection(IEditorPart editorPart)
          Returns the current selection for the given editor part.
 void removeChangeListener(IEditorChangeListener listener)
          Remove a change listener from all editors for which it has registered.
protected  boolean supports(EditPart editPart)
          Determines whether this layout manager is able to perform layout for the given edit part.
protected  boolean supports(IEditorPart editorPart)
          Determines whether this layout manager is able to perform layout for the given editor.
protected  void transferLayout(boolean cacheLayout)
          Transfers all layout data from the last created KGraph instance to the original diagram.
 
Methods inherited from class de.cau.cs.kieler.kiml.ui.layout.DiagramLayoutManager
calcAnimationTime, getPriority, layout, layout, setPriority
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GmfDiagramLayoutManager

public GmfDiagramLayoutManager()
Method Detail

supports

protected boolean supports(IEditorPart editorPart)
Determines whether this layout manager is able to perform layout for the given editor.

Specified by:
supports in class DiagramLayoutManager
Parameters:
editorPart - an editor part
Returns:
true if this layout manager supports the editor part

supports

protected boolean supports(EditPart editPart)
Determines whether this layout manager is able to perform layout for the given edit part.

Specified by:
supports in class DiagramLayoutManager
Parameters:
editPart - an edit part
Returns:
true if this layout manager supports the edit part

addChangeListener

public void addChangeListener(IEditorPart editorPart,
                              IEditorChangeListener listener)
Register a listener for change of the active editor or active selection. The default implementation does nothing.

Specified by:
addChangeListener in class DiagramLayoutManager
Parameters:
editorPart - editor to register to
listener - listener to register

removeChangeListener

public void removeChangeListener(IEditorChangeListener listener)
Remove a change listener from all editors for which it has registered. The default implementation does nothing.

Specified by:
removeChangeListener in class DiagramLayoutManager
Parameters:
listener - listener to remove

getSelection

public ISelection getSelection(IEditorPart editorPart)
Returns the current selection for the given editor part.

Specified by:
getSelection in class DiagramLayoutManager
Parameters:
editorPart - an editor part
Returns:
the current selection, or null if the selection cannot be determined

getInspector

public ILayoutInspector getInspector(EditPart editPart)
Returns a layout inspector for the given edit part.

Specified by:
getInspector in class DiagramLayoutManager
Parameters:
editPart - an edit part
Returns:
a layout inspector for the edit part

buildLayoutGraph

public KNode buildLayoutGraph(IEditorPart editorPart,
                              EditPart editPart,
                              boolean layoutAncestors)
Builds a KGraph instance for the given editor or edit part. The resulting layout graph should reflect the structure of edit parts in the original diagram.

Specified by:
buildLayoutGraph in class DiagramLayoutManager
Parameters:
editorPart - the editor for which layout is performed, or null if the diagram is not part of an editor
editPart - the parent edit part for which layout is performed, or null if the whole diagram shall be layouted
layoutAncestors - if true, layout is not only performed for the selected edit part, but also for its ancestors
Returns:
a layout graph instance

transferLayout

protected void transferLayout(boolean cacheLayout)
Transfers all layout data from the last created KGraph instance to the original diagram. The diagram is not modified yet, but all required preparations are performed.

Specified by:
transferLayout in class DiagramLayoutManager
Parameters:
cacheLayout - if true, the layout result is cached for the underlying model

applyLayout

protected void applyLayout()
Applies the transferred layout to the original diagram. This final step is where the actual change to the diagram is done.

Specified by:
applyLayout in class DiagramLayoutManager

getLayoutGraph

public KNode getLayoutGraph()
Returns the last built layout graph.

Specified by:
getLayoutGraph in class DiagramLayoutManager
Returns:
the last built layout graph

getCachedLayout

protected ICachedLayout getCachedLayout()
Returns the cached layout for the last layout run.

Specified by:
getCachedLayout in class DiagramLayoutManager
Returns:
the last cached layout

getCurrentEditPart

public EditPart getCurrentEditPart()
Returns the currently processed top level edit part.

Specified by:
getCurrentEditPart in class DiagramLayoutManager
Returns:
the currently processed edit part