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

java.lang.Object
  extended by de.cau.cs.kieler.kiml.LayoutDataService
      extended by de.cau.cs.kieler.kiml.service.ExtensionLayoutDataService
          extended by de.cau.cs.kieler.kiml.ui.layout.EclipseLayoutDataService

public class EclipseLayoutDataService
extends ExtensionLayoutDataService

A special layout data service for use in an Eclipse instance.

Rating proposed yellow
(2009-12-11) msp

Nested Class Summary
 
Nested classes/interfaces inherited from class de.cau.cs.kieler.kiml.LayoutDataService
LayoutDataService.Registry
 
Field Summary
static String ATTRIBUTE_CONFIG
          name of the 'config' attribute in the extension points.
static String ATTRIBUTE_PREVIEW
          name of the 'preview' attribute in the extension points.
static String ATTRIBUTE_VALUE
          name of the 'value' attribute in the extension points.
static String ELEMENT_BINDING
          name of the 'binding' element in the 'layout info' 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_SEMANTIC_OPTION
          name of the 'semantic option' element in the 'layout info' extension point.
static String EXTP_ID_LAYOUT_INFO
          identifier of the extension point for layout info.
static String EXTP_ID_LAYOUT_MANAGERS
          identifier of the extension point for layout managers.
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.service.ExtensionLayoutDataService
ATTRIBUTE_ADVANCED, ATTRIBUTE_APPLIESTO, ATTRIBUTE_CATEGORY, ATTRIBUTE_CLASS, ATTRIBUTE_DEFAULT, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_ID, ATTRIBUTE_NAME, ATTRIBUTE_OPTION, ATTRIBUTE_PARAMETER, ATTRIBUTE_PRIORITY, ATTRIBUTE_TYPE, ELEMENT_CATEGORY, ELEMENT_DIAGRAM_TYPE, ELEMENT_KNOWN_OPTION, ELEMENT_LAYOUT_ALGORITHM, ELEMENT_LAYOUT_OPTION, ELEMENT_LAYOUT_TYPE, ELEMENT_SUPPORTED_DIAGRAM, EXTP_ID_LAYOUT_PROVIDERS
 
Fields inherited from class de.cau.cs.kieler.kiml.LayoutDataService
DIAGRAM_TYPE_GENERAL
 
Constructor Summary
EclipseLayoutDataService()
           
 
Method Summary
 ICachedLayout cacheLayout(IWorkbenchPart workbenchPart, EditPart editPart, boolean animate, boolean progressBar)
          Performs layout on the given editor by choosing an appropriate layout manager instance and caches the layout result.
protected  LayoutAlgorithmData createLayoutAlgorithmData(IConfigurationElement element)
          Create a layout algorithm data instance and configure it with platform-specific extensions.
static void createLayoutServices()
          Builds the layout services for the Eclipse platform.
 Object getDefault(String className, String optionId)
          Retrieves the default value for the given element class and option identifier from the extension point.
 IGraphicalFrameworkBridge getFrameworkBridge(EditPart editPart)
          Retrieve an editing framework bridge for the given edit part using the most suitable layout manager.
static EclipseLayoutDataService getInstance()
          Returns the singleton instance as Eclipse layout services.
 ILayoutConfig getLayoutConfig(EditPart editPart)
          Retrieve a layout configuration for the given edit part using the most suitable layout manager.
 ILayoutConfig getLayoutConfig(IWorkbenchPart workbenchPart)
          Retrieve a layout configuration for the given editor using the most suitable layout manager.
 DiagramLayoutManager getManager(IWorkbenchPart workbenchPart, EditPart editPart)
          Returns the most suitable layout manager for the given editor and edit part.
 LayoutOptionData<?> getOptionData(LayoutAlgorithmData 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.
 DiagramLayoutManager layout(IWorkbenchPart workbenchPart, EditPart editPart, boolean animate, boolean progressBar)
          Performs layout on the given editor by choosing an appropriate layout manager instance.
 DiagramLayoutManager layout(IWorkbenchPart workbenchPart, 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.
protected  void reportError(CoreException exception)
          Report an error that occurred while reading extensions.
protected  void reportError(String extensionPoint, IConfigurationElement element, String attribute, Throwable exception)
          Report an error that occurred while reading extensions.
 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.service.ExtensionLayoutDataService
createLayoutProvider, loadClass, loadLayoutProviderExtensions
 
Methods inherited from class de.cau.cs.kieler.kiml.LayoutDataService
createLayoutServices, getAlgorithmData, getAlgorithmData, getCategoryName, getDiagramTypeName, getDiagramTypes, getInstanceOf, getMode, getOption, getOption, getOptionData, getOptionData, getOptionData, getOptions, getOptions, getRegistry, getSemanticConfigs, getTypeData, getTypeData, removeLayoutServices, removeLayoutServices, setMode, setMode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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_BINDING

public static final String ELEMENT_BINDING
name of the 'binding' element in the 'layout info' 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_OPTION

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

See Also:
Constant Field Values

ELEMENT_SEMANTIC_OPTION

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

See Also:
Constant Field Values

ATTRIBUTE_CONFIG

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

See Also:
Constant Field Values

ATTRIBUTE_PREVIEW

public static final String ATTRIBUTE_PREVIEW
name of the 'preview' 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

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

EclipseLayoutDataService

public EclipseLayoutDataService()
Method Detail

createLayoutServices

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


getInstance

public static EclipseLayoutDataService 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(IWorkbenchPart workbenchPart,
                                       EditPart editPart)
Returns the most suitable layout manager for the given editor and edit part.

Parameters:
workbenchPart - the workbench part 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

getFrameworkBridge

public IGraphicalFrameworkBridge getFrameworkBridge(EditPart editPart)
Retrieve an editing framework bridge for the given edit part using the most suitable layout manager.

Parameters:
editPart - the edit part for which the bridge should be fetched
Returns:
an editing framework bridge for the edit part, or null

getLayoutConfig

public ILayoutConfig getLayoutConfig(IWorkbenchPart workbenchPart)
Retrieve a layout configuration for the given editor using the most suitable layout manager.

Parameters:
workbenchPart - the workbench part for which the configuration should be fetched
Returns:
a layout configuration for the editor, or null

getLayoutConfig

public ILayoutConfig getLayoutConfig(EditPart editPart)
Retrieve a layout configuration for the given edit part using the most suitable layout manager.

Parameters:
editPart - the edit part for which the configuration should be fetched
Returns:
a layout configuration for the edit part, or null

layout

public DiagramLayoutManager layout(IWorkbenchPart workbenchPart,
                                   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:
workbenchPart - the workbench part 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 diagram layout manager that was used for layout

cacheLayout

public ICachedLayout cacheLayout(IWorkbenchPart workbenchPart,
                                 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:
workbenchPart - the workbench part 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 DiagramLayoutManager layout(IWorkbenchPart workbenchPart,
                                   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:
workbenchPart - the workbench part 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
Returns:
the diagram layout manager that was used for layout

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(LayoutAlgorithmData 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

reportError

protected void reportError(String extensionPoint,
                           IConfigurationElement element,
                           String attribute,
                           Throwable exception)
Report an error that occurred while reading extensions.

Specified by:
reportError in class ExtensionLayoutDataService
Parameters:
extensionPoint - the identifier of the extension point
element - the configuration element
attribute - the attribute that contains an invalid entry
exception - an optional exception that was caused by the invalid entry

reportError

protected void reportError(CoreException exception)
Report an error that occurred while reading extensions.

Specified by:
reportError in class ExtensionLayoutDataService
Parameters:
exception - a core exception holding a status with further information

createLayoutAlgorithmData

protected LayoutAlgorithmData createLayoutAlgorithmData(IConfigurationElement element)
Create a layout algorithm data instance and configure it with platform-specific extensions.

Overrides:
createLayoutAlgorithmData in class ExtensionLayoutDataService
Parameters:
element - a configuration element to use for configuration
Returns:
a new layout algorithm data instance

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