de.cau.cs.kieler.kiml.service
Class LayoutInfoService

java.lang.Object
  extended by de.cau.cs.kieler.kiml.service.LayoutInfoService
Direct Known Subclasses:
EclipseLayoutInfoService

public abstract class LayoutInfoService
extends Object

Service class for layout information such as registered diagram types and pre-configured layout option values.

Rating red

Field Summary
static String ATTRIBUTE_CLASS
          name of the 'class' attribute in the extension points.
static String ATTRIBUTE_CONFIG
          name of the 'config' 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_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_DIAGRAM_TYPE
          name of the 'diagram type' element in the 'layout info' 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.
 
Constructor Summary
protected LayoutInfoService()
          Protected constructor to enforce instantiation in subclasses.
 
Method Summary
protected  void addDiagramType(String id, String name)
          Registers the given diagram type.
 void addOptionValue(String id, String optionId, Object value)
          Adds the given layout option value as default for an object identifier.
protected  void addSemanticConfig(String clazzName, SemanticLayoutConfig config)
          Registers the given semantic layout configuration.
 String getDiagramTypeName(String id)
          Returns the name of the given diagram type.
 List<Pair<String,String>> getDiagramTypes()
          Returns a collection of registered diagram types.
static LayoutInfoService getInstance()
          Returns the singleton instance of the layout info service.
 Object getOptionValue(EClass clazz, String optionId)
          Retrieves a layout option value for a domain model class.
 Object getOptionValue(String objectId, String optionId)
          Retrieves a layout option value for an object identifier.
 Map<String,Object> getOptionValues(EClass clazz)
          Returns a map that contains all layout option values for a domain model class.
 Map<String,Object> getOptionValues(String objectId)
          Returns a map that contains all layout option values for an object identifier.
 List<ILayoutConfig> getSemanticConfigs(EClass clazz)
          Return the semantic layout configurations that are associated with the given domain model class.
protected  void loadLayoutInfoExtensions()
          Loads and registers all layout info extensions from the extension point.
 void removeOptionValue(String id, String optionId)
          Remove the value of the given layout option.
protected abstract  void reportError(CoreException exception)
          Report an error that occurred while reading extensions.
protected abstract  void reportError(String extensionPoint, IConfigurationElement element, String attribute, Throwable exception)
          Report an error that occurred while reading extensions.
 
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

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_DIAGRAM_TYPE

public static final String ELEMENT_DIAGRAM_TYPE
name of the 'diagram type' 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_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_CLASS

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

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_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_VALUE

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

See Also:
Constant Field Values
Constructor Detail

LayoutInfoService

protected LayoutInfoService()
Protected constructor to enforce instantiation in subclasses.

Method Detail

getInstance

public static LayoutInfoService getInstance()
Returns the singleton instance of the layout info service.

Returns:
the singleton instance

reportError

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

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 abstract void reportError(CoreException exception)
Report an error that occurred while reading extensions.

Parameters:
exception - a core exception holding a status with further information

loadLayoutInfoExtensions

protected void loadLayoutInfoExtensions()
Loads and registers all layout info extensions from the extension point.


addDiagramType

protected final void addDiagramType(String id,
                                    String name)
Registers the given diagram type.

Parameters:
id - identifier of the diagram type
name - user friendly name of the diagram type

addOptionValue

public final void addOptionValue(String id,
                                 String optionId,
                                 Object value)
Adds the given layout option value as default for an object identifier.

Parameters:
id - identifier of the object to register
optionId - identifier of a layout option
value - value for the layout option

removeOptionValue

public final void removeOptionValue(String id,
                                    String optionId)
Remove the value of the given layout option.

Parameters:
id - identifier of the object for which an option shall be removed
optionId - identifier of a layout option

addSemanticConfig

protected final void addSemanticConfig(String clazzName,
                                       SemanticLayoutConfig config)
Registers the given semantic layout configuration.

Parameters:
clazzName - domain model class name for which to register the configuration
config - a semantic layout configuration

getDiagramTypeName

public final String getDiagramTypeName(String id)
Returns the name of the given diagram type.

Parameters:
id - identifier of the diagram type
Returns:
user friendly name of the diagram type, or null if there is no diagram type with the given identifier

getDiagramTypes

public final List<Pair<String,String>> getDiagramTypes()
Returns a collection of registered diagram types. The first element of each returned entry is a diagram type identifier, the second element is the corresponding name.

Returns:
the registered diagram types

getOptionValues

public final Map<String,Object> getOptionValues(String objectId)
Returns a map that contains all layout option values for an object identifier.

Parameters:
objectId - an object identifier, such as an edit part class name, a domain model class name, or a diagram type id
Returns:
a map of layout option identifiers to their values

getOptionValue

public final Object getOptionValue(String objectId,
                                   String optionId)
Retrieves a layout option value for an object identifier.

Parameters:
objectId - an object identifier, such as an edit part class name, a domain model class name, or a diagram type id
optionId - a layout option identifier
Returns:
the preconfigured value of the option, or null if the option is not set for the given object

getOptionValues

public final Map<String,Object> getOptionValues(EClass clazz)
Returns a map that contains all layout option values for a domain model class. This involves options that are set for any superclass of the given one.

Parameters:
clazz - a domain model class
Returns:
a map of layout option identifiers to their values

getOptionValue

public final Object getOptionValue(EClass clazz,
                                   String optionId)
Retrieves a layout option value for a domain model class. This involves options that are set for any superclass of the given one.

Parameters:
clazz - a domain model class
optionId - a layout option identifier
Returns:
the option value for the class or a superclass, or null if the option is not set for the class

getSemanticConfigs

public final List<ILayoutConfig> getSemanticConfigs(EClass clazz)
Return the semantic layout configurations that are associated with the given domain model class. This involves configurations that are set for any superclass of the given one.

Parameters:
clazz - a domain model class
Returns:
the semantic layout configurations for the class or a superclass