de.cau.cs.kieler.kiml.ui.diagram
Class LayoutEffect

java.lang.Object
  extended by de.cau.cs.kieler.core.kivi.AbstractEffect
      extended by de.cau.cs.kieler.kiml.ui.diagram.LayoutEffect
All Implemented Interfaces:
IEffect

public class LayoutEffect
extends AbstractEffect

Performs automatic layout on a diagram editor for a given selection. The layout can be customized using #setOption(EObject, IProperty, Object), which sets specific layout options only for this instance of the layout effect.

Rating red

Constructor Summary
LayoutEffect(IWorkbenchPart workbenchPart, EObject object)
          Create a new layout effect for the given diagram editor and EObject.
LayoutEffect(IWorkbenchPart workbenchPart, EObject object, boolean zoomToFit)
          Create a new layout effect for the given diagram editor and EObject.
LayoutEffect(IWorkbenchPart workbenchPart, EObject object, boolean zoomToFit, boolean progressBar)
          Create a new layout effect for the given diagram editor and EObject.
LayoutEffect(IWorkbenchPart workbenchPart, EObject object, boolean zoomToFit, boolean progressBar, boolean ancestors)
          Create a new layout effect for the given diagram editor and EObject.
LayoutEffect(IWorkbenchPart workbenchPart, EObject object, boolean zoomToFit, boolean progressBar, boolean ancestors, boolean animation)
          Create a new layout effect for the given diagram editor and EObject.
 
Method Summary
 void dontMerge()
          Constrain this layout effect not to be merged with any other effect.
 void execute()
          Execute the effect.
 LayoutMapping<?> getMapping()
          Returns the layout mapping that was used for this layout effect, or null if the effect has not been executed yet.
 boolean isMergeable()
          Determines whether this effect can be merged with previously scheduled effects.
 IEffect merge(IEffect otherEffect)
          Merge this effect with another effect.
 void setOption(Object object, IProperty<?> option, Object value)
          Set a layout option value for this layout effect.
 void undo()
          Undo a layout effect.
 
Methods inherited from class de.cau.cs.kieler.core.kivi.AbstractEffect
schedule, scheduleUndo, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LayoutEffect

public LayoutEffect(IWorkbenchPart workbenchPart,
                    EObject object)
Create a new layout effect for the given diagram editor and EObject. If null is given as top-level object, layout is performed for the whole diagram.

Parameters:
workbenchPart - the workbench part containing the diagram to layout
object - the top-level domain model object to layout, or null
Throws:
UnsupportedPartException - if layout is not supported for the given workbench part

LayoutEffect

public LayoutEffect(IWorkbenchPart workbenchPart,
                    EObject object,
                    boolean zoomToFit)
Create a new layout effect for the given diagram editor and EObject. If null is given as top-level object, layout is performed for the whole diagram.

Parameters:
workbenchPart - the workbench part containing the diagram to layout
object - the top-level domain model object to layout, or null
zoomToFit - whether zoom to fit shall be performed
Throws:
UnsupportedPartException - if layout is not supported for the given workbench part

LayoutEffect

public LayoutEffect(IWorkbenchPart workbenchPart,
                    EObject object,
                    boolean zoomToFit,
                    boolean progressBar)
Create a new layout effect for the given diagram editor and EObject. If null is given as top-level object, layout is performed for the whole diagram.

Parameters:
workbenchPart - the workbench part containing the diagram to layout
object - the top-level domain model object to layout, or null
zoomToFit - whether zoom to fit shall be performed
progressBar - whether a progress bar shall be displayed
Throws:
UnsupportedPartException - if layout is not supported for the given workbench part

LayoutEffect

public LayoutEffect(IWorkbenchPart workbenchPart,
                    EObject object,
                    boolean zoomToFit,
                    boolean progressBar,
                    boolean ancestors)
Create a new layout effect for the given diagram editor and EObject. If null is given as top-level object, layout is performed for the whole diagram.

Parameters:
workbenchPart - the workbench part containing the diagram to layout
object - the top-level domain model object to layout, or null
zoomToFit - whether zoom to fit shall be performed
progressBar - whether a progress bar shall be displayed
ancestors - whether to include the ancestors in the layout process
Throws:
UnsupportedPartException - if layout is not supported for the given workbench part

LayoutEffect

public LayoutEffect(IWorkbenchPart workbenchPart,
                    EObject object,
                    boolean zoomToFit,
                    boolean progressBar,
                    boolean ancestors,
                    boolean animation)
Create a new layout effect for the given diagram editor and EObject. If null is given as top-level object, layout is performed for the whole diagram.

Parameters:
workbenchPart - the workbench part containing the diagram to layout
object - the top-level domain model object to layout, or null
zoomToFit - whether zoom to fit shall be performed
progressBar - whether a progress bar shall be displayed
ancestors - whether to include the ancestors in the layout process
animation - whether the layout shall be animated
Throws:
UnsupportedPartException - if layout is not supported for the given workbench part
Method Detail

dontMerge

public void dontMerge()
Constrain this layout effect not to be merged with any other effect.


setOption

public void setOption(Object object,
                      IProperty<?> option,
                      Object value)
Set a layout option value for this layout effect. The value is only applied for this layout run and is thrown away afterwards.

Parameters:
object - the domain model element or edit part for which the option shall be set
option - the layout option to set (see LayoutOptions)
value - the value for the layout option

execute

public void execute()
Execute the effect.


undo

public void undo()
Undo a layout effect. For now, only a new layout is executed. This leads to correct behavior if a list of effects is undone sequentially and the last one was a layout effect. However, this is not really undoing that layout. TODO: implement real undoing of layout, best with animation. Using the standard command undo functionality will not do any animation.

Specified by:
undo in interface IEffect
Overrides:
undo in class AbstractEffect

getMapping

public LayoutMapping<?> getMapping()
Returns the layout mapping that was used for this layout effect, or null if the effect has not been executed yet.

Returns:
the diagram layout manager

isMergeable

public boolean isMergeable()
Determines whether this effect can be merged with previously scheduled effects.

Specified by:
isMergeable in interface IEffect
Overrides:
isMergeable in class AbstractEffect
Returns:
true if it can be merged, false if no search through the effect queue is necessary

merge

public IEffect merge(IEffect otherEffect)
Merge this effect with another effect. Will return null if the effects can not be merged.

Specified by:
merge in interface IEffect
Overrides:
merge in class AbstractEffect
Parameters:
otherEffect - the effect to merge with
Returns:
the newly merged effect, or null if no merge was possible.