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

java.lang.Object
  extended by de.cau.cs.kieler.kiml.DefaultLayoutConfig
      extended by de.cau.cs.kieler.kiml.ui.layout.EclipseLayoutConfig
          extended by de.cau.cs.kieler.kiml.gmf.GmfLayoutConfig
All Implemented Interfaces:
IPropertyHolder, ILayoutConfig

public class GmfLayoutConfig
extends EclipseLayoutConfig

A layout configuration that stores layout options in the notation model of GMF diagrams.

Rating red

Constructor Summary
GmfLayoutConfig()
          Create a stand-alone layout configuration for GMF.
GmfLayoutConfig(ILayoutConfig externalConfig)
          Create a layout configuration for GMF with embedded external configuration.
 
Method Summary
protected  void addProperties(Map<IProperty<?>,Object> options)
          Add all notation model values to the given map of layout options.
 void clearProperties()
          Clear all stored layout options for the selected element.
protected
<T> T
doGetProperty(LayoutOptionData<T> optionData)
          Retrieve the value that is stored in the notation model or the default value for a layout option.
<T> T
getDiagramDefault(LayoutOptionData<T> optionData)
          Returns the default value for the selected diagram.
static KOption getKOption(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart editPart, String optionId)
          Returns the KOption with given key that is stored for the edit part.
 void initialize(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart editPart)
          Initialize the configuration for a graphical edit part.
 boolean isDefault(LayoutOptionData<?> optionData)
          Determines whether the given layout option is already stored in the notation view of the selected element.
static boolean isNoLayout(EditPart editPart)
          Determines whether the given edit part should not be layouted.
static void removeKOption(LayoutOptionStyle style, LayoutOptionData<?> optionData)
          Removes an option from the given style container.
static void removeOptionStyle(View view)
          Removes the LayoutOptionStyle from the notation view, if it exists.
 void setDiagramDefault(LayoutOptionData<?> optionData, Object value)
          Sets a default value for the selected diagram.
 void setFocus(Object element)
          Set the focus of the layout configuration on a specific edit part.
 void setProperty(IProperty<?> property, Object value)
          Stores the given value in the notation view of the selected element.
 
Methods inherited from class de.cau.cs.kieler.kiml.ui.layout.EclipseLayoutConfig
getAllProperties, getEditPart, getExternalConfig, getOption, getOption, getProperty, initialize
 
Methods inherited from class de.cau.cs.kieler.kiml.DefaultLayoutConfig
copyProperties, getContainerLayouterData, getContentLayouterData, getLayouterData, getOptionData, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GmfLayoutConfig

public GmfLayoutConfig()
Create a stand-alone layout configuration for GMF.


GmfLayoutConfig

public GmfLayoutConfig(ILayoutConfig externalConfig)
Create a layout configuration for GMF with embedded external configuration.

Parameters:
externalConfig - an external configuration
Method Detail

getKOption

public static KOption getKOption(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart editPart,
                                 String optionId)
Returns the KOption with given key that is stored for the edit part.

Parameters:
editPart - the edit part for which the option shall be fetched
optionId - the identifier of the option
Returns:
the corresponding option, or null if there is no such option

removeKOption

public static void removeKOption(LayoutOptionStyle style,
                                 LayoutOptionData<?> optionData)
Removes an option from the given style container.

Parameters:
style - a layout option style
optionData - a layout option data

removeOptionStyle

public static void removeOptionStyle(View view)
Removes the LayoutOptionStyle from the notation view, if it exists.

Parameters:
view - the notation view from which to remove the layout option style

isNoLayout

public static boolean isNoLayout(EditPart editPart)
Determines whether the given edit part should not be layouted.

Parameters:
editPart - an edit part
Returns:
true if no layout should be performed for the edit part

setFocus

public void setFocus(Object element)
Set the focus of the layout configuration on a specific edit part. The domain model element of the edit part is passed to the super-class as well. This can be done without initializing the layout configuration in order to use EclipseLayoutConfig.getAllProperties() efficiently, since the same configuration instance can be reused multiple times.

Specified by:
setFocus in interface ILayoutConfig
Overrides:
setFocus in class EclipseLayoutConfig
Parameters:
element - an instance of IGraphicalEditPart

initialize

public final void initialize(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart editPart)
Initialize the configuration for a graphical edit part.

Parameters:
editPart - an edit part

doGetProperty

protected <T> T doGetProperty(LayoutOptionData<T> optionData)
Retrieve the value that is stored in the notation model or the default value for a layout option.

Overrides:
doGetProperty in class EclipseLayoutConfig
Type Parameters:
T - type of option
Parameters:
optionData - a layout option
Returns:
the stored or default value for the layout option

setProperty

public void setProperty(IProperty<?> property,
                        Object value)
Stores the given value in the notation view of the selected element. This requires initialize to be called first in order to work properly.

Specified by:
setProperty in interface IPropertyHolder
Overrides:
setProperty in class DefaultLayoutConfig
Parameters:
property - a layout option
value - an option value

isDefault

public boolean isDefault(LayoutOptionData<?> optionData)
Determines whether the given layout option is already stored in the notation view of the selected element. This requires initialize to be called first in order to work properly.

Specified by:
isDefault in interface ILayoutConfig
Overrides:
isDefault in class DefaultLayoutConfig
Parameters:
optionData - a layout option
Returns:
whether the option has its default value or not

clearProperties

public void clearProperties()
Clear all stored layout options for the selected element.

Specified by:
clearProperties in interface ILayoutConfig
Overrides:
clearProperties in class DefaultLayoutConfig

getDiagramDefault

public <T> T getDiagramDefault(LayoutOptionData<T> optionData)
Returns the default value for the selected diagram.

Type Parameters:
T - type of option
Parameters:
optionData - a layout option
Returns:
the current diagram-default value

setDiagramDefault

public void setDiagramDefault(LayoutOptionData<?> optionData,
                              Object value)
Sets a default value for the selected diagram.

Specified by:
setDiagramDefault in interface ILayoutConfig
Overrides:
setDiagramDefault in class DefaultLayoutConfig
Parameters:
optionData - a layout option
value - the new default value

addProperties

protected void addProperties(Map<IProperty<?>,Object> options)
Add all notation model values to the given map of layout options.

Overrides:
addProperties in class EclipseLayoutConfig
Parameters:
options - a map of layout option values