de.cau.cs.kieler.kiml.ui.layout
Class EclipseLayoutServices

java.lang.Object
  extended by de.cau.cs.kieler.kiml.LayoutServices
      extended by de.cau.cs.kieler.kiml.ui.layout.EclipseLayoutServices

public class EclipseLayoutServices
extends LayoutServices

This class is responsible for reading all extension point elements for layout services.

Rating proposed yellow
(2009-12-11) msp

Nested Class Summary
 
Nested classes/interfaces inherited from class de.cau.cs.kieler.kiml.LayoutServices
LayoutServices.Registry
 
Field Summary
static String ATTRIBUTE_APPLIESTO
          name of the 'appliesTo' attribute in the extension points.
static String ATTRIBUTE_CATEGORY
          name of the 'category' attribute in the extension points.
static String ATTRIBUTE_CLASS
          name of the 'class' attribute in the extension points.
static String ATTRIBUTE_DESCRIPTION
          name of the 'description' attribute in the extension points.
static String ATTRIBUTE_ID
          name of the 'id' attribute in the extension points.
static String ATTRIBUTE_NAME
          name of the 'name' attribute in the extension points.
static String ATTRIBUTE_OPTION
          name of the 'option' attribute in the extension points.
static String ATTRIBUTE_PARAMETER
          name of the 'parameter' attribute in the extension points.
static String ATTRIBUTE_PRIORITY
          name of the 'priority' attribute in the extension points.
static String ATTRIBUTE_TYPE
          name of the 'type' attribute in the extension points.
static String ATTRIBUTE_VALUE
          name of the 'value' attribute in the extension points.
static String DEFAULT_OPTION_NAME
          default name for layout options for which no name is given.
static String DEFAULT_PROVIDER_NAME
          default name for layout providers for which no name is given.
static String ELEMENT_BINDING
          name of the 'binding' element in the 'layout info' extension point.
static String ELEMENT_CATEGORY
          name of the 'category' element in the 'layout providers' extension point.
static String ELEMENT_DIAGRAM_TYPE
          name of the 'diagramType' element in the 'layout info' extension point.
static String ELEMENT_KNOWN_OPTION
          name of the 'knownOption' element in the 'layout providers' extension point.
static String ELEMENT_LAYOUT_LISTENER
          name of the 'layoutListener' element in the 'layout listeners' extension point.
static String ELEMENT_LAYOUT_OPTION
          name of the 'layoutOption' element in the 'layout providers' extension point.
static String ELEMENT_LAYOUT_PROVIDER
          name of the 'layoutProvider' element in the 'layout providers' extension point.
static String ELEMENT_LAYOUT_TYPE
          name of the 'layoutType' element in the 'layout providers' extension point.
static String ELEMENT_MANAGER
          name of the 'manager' element in the 'layout managers' extension point.
static String ELEMENT_OPTION
          name of the 'option' element in the 'layout info' extension point.
static String ELEMENT_SUPPORTED_DIAGRAM
          name of the 'supportedDiagram' element in the 'layout providers' extension point.
static String EXTP_ID_LAYOUT_INFO
          identifier of the extension point for layout info.
static String EXTP_ID_LAYOUT_LISTENERS
          identifier of the extension point for layout listeners.
static String EXTP_ID_LAYOUT_MANAGERS
          identifier of the extension point for layout managers.
static String EXTP_ID_LAYOUT_PROVIDERS
          identifier of the extension point for layout providers.
static String PREF_OBLIQUE_ROUTE
          preference identifier for oblique edge routing.
static String PREF_REG_ELEMENTS
          preference identifier for the list of registered diagram elements.
 
Fields inherited from class de.cau.cs.kieler.kiml.LayoutServices
DIAGRAM_TYPE_GENERAL
 
Constructor Summary
EclipseLayoutServices()
           
 
Method Summary
 ICachedLayout cacheLayout(IEditorPart editorPart, EditPart editPart, boolean animate, boolean progressBar)
          Performs layout on the given editor by choosing an appropriate layout manager instance and caches the layout result.
static void createLayoutServices()
          Builds the layout services for the Eclipse platform.
 Object getDefault(LayoutOptionData optionData, LayoutProviderData providerData, EditPart editPart, EditPart containerEditPart, boolean hasChildren)
          Retrieves the default value for the given layout option.
 Object getDefault(String className, String optionId)
          Retrieves the default value for the given element class and option identifier from the extension point.
 ILayoutInspector getInspector(EditPart editPart)
          Retrieve an inspector for the given edit part using the most suitable layout manager.
static EclipseLayoutServices getInstance()
          Returns the singleton instance as Eclipse layout services.
 DiagramLayoutManager getLastManager()
          Returns the last used layout manager instance.
 DiagramLayoutManager getManager(IEditorPart editorPart, EditPart editPart)
          Returns the most suitable layout manager for the given editor and edit part.
 LayoutOptionData getOptionData(LayoutProviderData providerData, String optionName)
          Returns the layout option data that matches the given user-friendly name and is known by the given layout provider.
static String getPreferenceName(String id1, String id2)
          Returns the preference name associated with the two identifiers.
 Set<String> getRegisteredElements()
          Returns the set of registered diagram elements.
 void layout(IEditorPart editorPart, EditPart editPart, boolean animate, boolean progressBar)
          Performs layout on the given editor by choosing an appropriate layout manager instance.
 void layout(IEditorPart editorPart, EditPart editPart, boolean animate, boolean progressBar, boolean layoutAncestors)
          Performs layout on the given editor by choosing an appropriate layout manager instance.
 void loadDefaultOptions()
          Loads the default layout options from the extension point.
static void readSupportPriorities(int[][] priorityData, String[] layoutProviders, String[] diagramTypes)
          Fills the given table of priorities with data from the extension point.
 void storeOption(EditPart editPart, LayoutOptionData optionData, String valueString, boolean storeDomainModel)
          Stores the layout option with given value for the edit part.
 void storeOption(String diagramType, LayoutOptionData optionData, String valueString)
          Stores the layout option with given value for the diagram type.
 void storePreferences()
          Stores preferences for KIML.
 
Methods inherited from class de.cau.cs.kieler.kiml.LayoutServices
createLayoutServices, getCategoryName, getDiagramTypeName, getDiagramTypes, getLayoutOptionData, getLayoutOptionData, getLayoutOptions, getLayoutProvider, getLayoutProviderData, getLayoutProviderData, getLayoutProviderData, getLayoutTypeName, getLayoutTypes, getOption, getOptions, getRegistry, layoutPerformed, layoutRequested, registry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXTP_ID_LAYOUT_PROVIDERS

public static final String EXTP_ID_LAYOUT_PROVIDERS
identifier of the extension point for layout providers.

See Also:
Constant Field Values

EXTP_ID_LAYOUT_LISTENERS

public static final String EXTP_ID_LAYOUT_LISTENERS
identifier of the extension point for layout listeners.

See Also:
Constant Field Values

EXTP_ID_LAYOUT_INFO

public static final String EXTP_ID_LAYOUT_INFO
identifier of the extension point for layout info.

See Also:
Constant Field Values

EXTP_ID_LAYOUT_MANAGERS

public static final String EXTP_ID_LAYOUT_MANAGERS
identifier of the extension point for layout managers.

See Also:
Constant Field Values

ELEMENT_LAYOUT_PROVIDER

public static final String ELEMENT_LAYOUT_PROVIDER
name of the 'layoutProvider' element in the 'layout providers' extension point.

See Also:
Constant Field Values

ELEMENT_LAYOUT_TYPE

public static final String ELEMENT_LAYOUT_TYPE
name of the 'layoutType' element in the 'layout providers' extension point.

See Also:
Constant Field Values

ELEMENT_CATEGORY

public static final String ELEMENT_CATEGORY
name of the 'category' element in the 'layout providers' extension point.

See Also:
Constant Field Values

ELEMENT_MANAGER

public static final String ELEMENT_MANAGER
name of the 'manager' element in the 'layout managers' extension point.

See Also:
Constant Field Values

ELEMENT_LAYOUT_OPTION

public static final String ELEMENT_LAYOUT_OPTION
name of the 'layoutOption' element in the 'layout providers' extension point.

See Also:
Constant Field Values

ELEMENT_KNOWN_OPTION

public static final String ELEMENT_KNOWN_OPTION
name of the 'knownOption' element in the 'layout providers' extension point.

See Also:
Constant Field Values

ELEMENT_SUPPORTED_DIAGRAM

public static final String ELEMENT_SUPPORTED_DIAGRAM
name of the 'supportedDiagram' element in the 'layout providers' extension point.

See Also:
Constant Field Values

ELEMENT_DIAGRAM_TYPE

public static final String ELEMENT_DIAGRAM_TYPE
name of the 'diagramType' element in the 'layout info' extension point.

See Also:
Constant Field Values

ELEMENT_BINDING

public static final String ELEMENT_BINDING
name of the 'binding' element in the 'layout info' extension point.

See Also:
Constant Field Values

ELEMENT_OPTION

public static final String ELEMENT_OPTION
name of the 'option' element in the 'layout info' extension point.

See Also:
Constant Field Values

ELEMENT_LAYOUT_LISTENER

public static final String ELEMENT_LAYOUT_LISTENER
name of the 'layoutListener' element in the 'layout listeners' extension point.

See Also:
Constant Field Values

ATTRIBUTE_APPLIESTO

public static final String ATTRIBUTE_APPLIESTO
name of the 'appliesTo' attribute in the extension points.

See Also:
Constant Field Values

ATTRIBUTE_CATEGORY

public static final String ATTRIBUTE_CATEGORY
name of the 'category' attribute in the extension points.

See Also:
Constant Field Values

ATTRIBUTE_CLASS

public static final String ATTRIBUTE_CLASS
name of the 'class' attribute in the extension points.

See Also:
Constant Field Values

ATTRIBUTE_DESCRIPTION

public static final String ATTRIBUTE_DESCRIPTION
name of the 'description' attribute in the extension points.

See Also:
Constant Field Values

ATTRIBUTE_ID

public static final String ATTRIBUTE_ID
name of the 'id' attribute in the extension points.

See Also:
Constant Field Values

ATTRIBUTE_NAME

public static final String ATTRIBUTE_NAME
name of the 'name' attribute in the extension points.

See Also:
Constant Field Values

ATTRIBUTE_OPTION

public static final String ATTRIBUTE_OPTION
name of the 'option' attribute in the extension points.

See Also:
Constant Field Values

ATTRIBUTE_PARAMETER

public static final String ATTRIBUTE_PARAMETER
name of the 'parameter' attribute in the extension points.

See Also:
Constant Field Values

ATTRIBUTE_PRIORITY

public static final String ATTRIBUTE_PRIORITY
name of the 'priority' attribute in the extension points.

See Also:
Constant Field Values

ATTRIBUTE_TYPE

public static final String ATTRIBUTE_TYPE
name of the 'type' attribute in the extension points.

See Also:
Constant Field Values

ATTRIBUTE_VALUE

public static final String ATTRIBUTE_VALUE
name of the 'value' attribute in the extension points.

See Also:
Constant Field Values

DEFAULT_PROVIDER_NAME

public static final String DEFAULT_PROVIDER_NAME
default name for layout providers for which no name is given.

See Also:
Constant Field Values

DEFAULT_OPTION_NAME

public static final String DEFAULT_OPTION_NAME
default name for layout options for which no name is given.

See Also:
Constant Field Values

PREF_REG_ELEMENTS

public static final String PREF_REG_ELEMENTS
preference identifier for the list of registered diagram elements.

See Also:
Constant Field Values

PREF_OBLIQUE_ROUTE

public static final String PREF_OBLIQUE_ROUTE
preference identifier for oblique edge routing.

See Also:
Constant Field Values
Constructor Detail

EclipseLayoutServices

public EclipseLayoutServices()
Method Detail

createLayoutServices

public static void createLayoutServices()
Builds the layout services for the Eclipse platform.


getInstance

public static EclipseLayoutServices getInstance()
Returns the singleton instance as Eclipse layout services.

Returns:
the singleton instance, or null if the instance is not of Eclipse layout services

getManager

public DiagramLayoutManager getManager(IEditorPart editorPart,
                                       EditPart editPart)
Returns the most suitable layout manager for the given editor and edit part.

Parameters:
editorPart - the editor for which the layout manager should be fetched, or null
editPart - the edit part for which the layout manager should be fetched, or null
Returns:
the most suitable diagram layout manager

getInspector

public ILayoutInspector getInspector(EditPart editPart)
Retrieve an inspector for the given edit part using the most suitable layout manager.

Parameters:
editPart - the edit part for which the inspector should be fetched
Returns:
an inspector for the edit part

getLastManager

public DiagramLayoutManager getLastManager()
Returns the last used layout manager instance.

Returns:
the last used instance

getDefault

public Object getDefault(LayoutOptionData optionData,
                         LayoutProviderData providerData,
                         EditPart editPart,
                         EditPart containerEditPart,
                         boolean hasChildren)
Retrieves the default value for the given layout option.

Parameters:
optionData - a layout option data
providerData - the active layout provider data
editPart - the current edit part
containerEditPart - the container edit part that is valid for the option
hasChildren - indicates whether the given edit part has children in the layout graph
Returns:
an object with the default value

layout

public void layout(IEditorPart editorPart,
                   EditPart editPart,
                   boolean animate,
                   boolean progressBar)
Performs layout on the given editor by choosing an appropriate layout manager instance. Animation and a progress bar can be optionally turned on.

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
animate - if true, Draw2D animation is activated
progressBar - if true, a progress bar is displayed

cacheLayout

public ICachedLayout cacheLayout(IEditorPart editorPart,
                                 EditPart editPart,
                                 boolean animate,
                                 boolean progressBar)
Performs layout on the given editor by choosing an appropriate layout manager instance and caches the layout result. Animation and a progress bar can be optionally turned on.

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
animate - if true, Draw2D animation is activated
progressBar - if true, a progress bar is displayed
Returns:
the cached layout result

layout

public void layout(IEditorPart editorPart,
                   EditPart editPart,
                   boolean animate,
                   boolean progressBar,
                   boolean layoutAncestors)
Performs layout on the given editor by choosing an appropriate layout manager instance. Animation, a progress bar, and layout of ancestors can be optionally turned on.

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
animate - if true, Draw2D animation is activated
progressBar - if true, a progress bar is displayed
layoutAncestors - if true, layout is not only performed for the selected edit part, but also for its ancestors

getPreferenceName

public static String getPreferenceName(String id1,
                                       String id2)
Returns the preference name associated with the two identifiers.

Parameters:
id1 - first identifier
id2 - second identifier
Returns:
a preference name for the combination of both identifiers

readSupportPriorities

public static void readSupportPriorities(int[][] priorityData,
                                         String[] layoutProviders,
                                         String[] diagramTypes)
Fills the given table of priorities with data from the extension point. The number of rows in the table must be equal to the number of layout providers, and the number of columns must be equal to the number of diagram types.

Parameters:
priorityData - two dimensional array that is filled with data
layoutProviders - array of layout provider identifiers
diagramTypes - array of diagram type identifiers

storeOption

public void storeOption(String diagramType,
                        LayoutOptionData optionData,
                        String valueString)
Stores the layout option with given value for the diagram type.

Parameters:
diagramType - a diagram type identifier
optionData - a layout option data
valueString - the value to store for the diagram type and option

storeOption

public void storeOption(EditPart editPart,
                        LayoutOptionData optionData,
                        String valueString,
                        boolean storeDomainModel)
Stores the layout option with given value for the edit part.

Parameters:
editPart - an edit part
optionData - a layout option data
valueString - the value to store for the edit part and option
storeDomainModel - if true, the option is stored for the domain model element associated with the edit part, else for the edit part itself

loadDefaultOptions

public void loadDefaultOptions()
Loads the default layout options from the extension point.


getDefault

public Object getDefault(String className,
                         String optionId)
Retrieves the default value for the given element class and option identifier from the extension point.

Parameters:
className - name of a diagram element class
optionId - layout option identifier
Returns:
the default option value for the element class

getOptionData

public LayoutOptionData getOptionData(LayoutProviderData providerData,
                                      String optionName)
Returns the layout option data that matches the given user-friendly name and is known by the given layout provider.

Parameters:
providerData - a layout provider data
optionName - user-friendly name of a layout option
Returns:
the corresponding layout option data

storePreferences

public void storePreferences()
Stores preferences for KIML.


getRegisteredElements

public Set<String> getRegisteredElements()
Returns the set of registered diagram elements.

Returns:
the set of registered diagram elements