de.cau.cs.kieler.ksbase.core
Class EditorTransformationSettings

java.lang.Object
  extended by de.cau.cs.kieler.ksbase.core.EditorTransformationSettings
All Implemented Interfaces:
Serializable

public class EditorTransformationSettings
extends Object
implements Serializable

Stores the KSBasE settings for one specific editor. This class is used by the TransformationManager to store settings that have been defined using the KSBasE extension point or the KSBasE preference pages. This class may be serialized.

See Also:
Serialized Form
Rating yellow
(2010-01-22) review by msp, skn

Constructor Summary
EditorTransformationSettings(String editorClass)
          Creates a new transformation setting with the given fully qualified editor name.
 
Method Summary
 void addMenuContribution(KSBasEMenuContribution contribution)
          Adds a menu contribution to this editor.
 void addOutPlaceTransformation(KSBasETransformation t)
          Adds a single transformation to the transformations list.
 void addTransformation(KSBasETransformation t)
          Adds a single transformation to the transformations list.
 void addTransformationClass(Object classObject)
           
 boolean equals(Object obj)
          Two editor settings are the same if they have the same target editor and the same source contributor.
 String getCommandHandler()
          Returns the command handler, may return an empty string but never null.
 String getContext()
          Returns the defined diagram context.
 IContributor getContributor()
          Gets the contributor.
 String getDefaultIcon()
          Returns the path to the default icon.
 String getEditorId()
          Gets the ID of the assigned editor.
 ITransformationFramework getFramework()
          Gets the transformation framework for this editor.
 LinkedList<KSBasEMenuContribution> getMenuContributions()
          Gets the list of existing menu contributions.
 List<String> getModelPackages()
          Gets the model package class name.
 AbstractTransformation getOutPlaceTransformationById(String tid)
          Tries to find a transformation by its identity string.
 AbstractTransformation getOutPlaceTransformationByName(String transformation)
          Tries to find a transformation with a given name.
 Collection<AbstractTransformation> getOutPlaceTransformations()
          Gets the list of defined out-place transformations.
 KSBasETransformation getTransformationById(String tid)
          Tries to find a transformation by its identity string.
 KSBasETransformation getTransformationByName(String transformation)
          Tries to find a transformation with a given name.
 List<Object> getTransformationClasses()
           
 String getTransformationFile()
          Returns the absolute path to the transformation file.
 Collection<KSBasETransformation> getTransformations()
          Gets the list of defined transformations.
 int hashCode()
          The hashcode is calculated from the editors hash and the hashCode of the contributor, if existing.
 boolean isCheckVisibility()
          Visibility checks enabled?
 void parseTransformations(boolean createTransformations, URL fileURL)
          Parses the transformation file to read transformations and parameters.
 void setCheckVisibility(boolean flag)
          Set visibility checks.
 void setCommandHandler(String handlerClass)
          Sets the command handler for this editor.
 void setContext(String contxt)
          Sets the diagram context.
 void setContributor(IContributor contrib)
          Sets the editors contributor project.
 void setDefaultIcon(String icon)
          Sets the path to the default icon.
 void setEditor(String editorid)
          Sets the editor class.
 void setFramework(ITransformationFramework theFramework)
          Sets the transformation framework for this editor.
 void setMenuContributions(List<KSBasEMenuContribution> contributionList)
          Sets the menu contributions for this editor and removes any existing contributions.
 void setTransformationFile(String absolutePath)
          Sets the path to the transformation file.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EditorTransformationSettings

public EditorTransformationSettings(String editorClass)
Creates a new transformation setting with the given fully qualified editor name.

Parameters:
editorClass - The fqn of the diagram editor
Method Detail

setEditor

public final void setEditor(String editorid)
Sets the editor class.

Parameters:
editorid - The id of the diagram editor

getEditorId

public final String getEditorId()
Gets the ID of the assigned editor.

Returns:
The ID of the editor

getModelPackages

public final List<String> getModelPackages()
Gets the model package class name.

Returns:
The fqn of the model package class

getMenuContributions

public final LinkedList<KSBasEMenuContribution> getMenuContributions()
Gets the list of existing menu contributions.

Returns:
The list of menu contributions for this editor

setMenuContributions

public final void setMenuContributions(List<KSBasEMenuContribution> contributionList)
Sets the menu contributions for this editor and removes any existing contributions.

Parameters:
contributionList - The list of menu contributions to use

addMenuContribution

public final void addMenuContribution(KSBasEMenuContribution contribution)
Adds a menu contribution to this editor.

Parameters:
contribution - The contribution to append to the list of menu contributions.

getDefaultIcon

public final String getDefaultIcon()
Returns the path to the default icon.

Returns:
Path to the default icon

setDefaultIcon

public final void setDefaultIcon(String icon)
Sets the path to the default icon.

Parameters:
icon - Icon path

getTransformations

public final Collection<KSBasETransformation> getTransformations()
Gets the list of defined transformations.

Returns:
A LinkedList containing all transformations

getOutPlaceTransformations

public final Collection<AbstractTransformation> getOutPlaceTransformations()
Gets the list of defined out-place transformations.

Returns:
A linkedList containing all transformations

getTransformationByName

public final KSBasETransformation getTransformationByName(String transformation)
Tries to find a transformation with a given name.

Parameters:
transformation - The name to find
Returns:
The first transformation found or null

getOutPlaceTransformationByName

public final AbstractTransformation getOutPlaceTransformationByName(String transformation)
Tries to find a transformation with a given name.

Parameters:
transformation - The name to find
Returns:
The first transformation found or null

getTransformationById

public final KSBasETransformation getTransformationById(String tid)
Tries to find a transformation by its identity string.

Parameters:
tid - The id to find
Returns:
The first transformation with the given id or null if no transformation has been found

getOutPlaceTransformationById

public final AbstractTransformation getOutPlaceTransformationById(String tid)
Tries to find a transformation by its identity string.

Parameters:
tid - The id to find
Returns:
The first transformation with the given id or null if no transformation has been found

addTransformation

public final void addTransformation(KSBasETransformation t)
Adds a single transformation to the transformations list.

Parameters:
t - a transformation definition

addOutPlaceTransformation

public final void addOutPlaceTransformation(KSBasETransformation t)
Adds a single transformation to the transformations list.

Parameters:
t - a transformation definition

getTransformationFile

public final String getTransformationFile()
Returns the absolute path to the transformation file.

Returns:
An abolute path.

setTransformationFile

public final void setTransformationFile(String absolutePath)
Sets the path to the transformation file.

Parameters:
absolutePath - An absolute path

getContributor

public final IContributor getContributor()
Gets the contributor. May return null if the editor has been added via the preference pages.

Returns:
The editors contributor project.

setContributor

public final void setContributor(IContributor contrib)
Sets the editors contributor project.

Parameters:
contrib - The contribution that is assigned with this editor. May be null if the editor has been defined by the user or the plug-in project does not have a contributor.

getContext

public final String getContext()
Returns the defined diagram context.

Returns:
A contextID used to bind keyboard shortcuts to commands

setContext

public final void setContext(String contxt)
Sets the diagram context.

Parameters:
contxt - the contextID to bind keyboard shortcuts

getCommandHandler

public String getCommandHandler()
Returns the command handler, may return an empty string but never null.

Returns:
The string containing the class name of the command handler.

setCommandHandler

public void setCommandHandler(String handlerClass)
Sets the command handler for this editor.

Parameters:
handlerClass - The name of the command handler class, must not be null

getFramework

public ITransformationFramework getFramework()
Gets the transformation framework for this editor.

Returns:
an implementation of ITransformationFramework

setFramework

public void setFramework(ITransformationFramework theFramework)
Sets the transformation framework for this editor.

Parameters:
theFramework - an implementation of ITransformationFramework

isCheckVisibility

public boolean isCheckVisibility()
Visibility checks enabled?

Returns:
true if checks are enabled

setCheckVisibility

public void setCheckVisibility(boolean flag)
Set visibility checks.

Parameters:
flag - new option

parseTransformations

public final void parseTransformations(boolean createTransformations,
                                       URL fileURL)
Parses the transformation file to read transformations and parameters.

Parameters:
createTransformations - If this flag is set the transformations are created while parsing. If not, the parameters of the existing transformations are matched with the file.
fileURL - a valid URL to an transformation file.

equals

public boolean equals(Object obj)
Two editor settings are the same if they have the same target editor and the same source contributor. So we will have an implicit distinction between extension point and user defined settings, because user defined settings will have 'null' as contributor.

Overrides:
equals in class Object
Parameters:
obj - The Object to compare
Returns:
True if the given Object is an EditorTransformationSetting and has the same contributor

hashCode

public int hashCode()
The hashcode is calculated from the editors hash and the hashCode of the contributor, if existing.

Overrides:
hashCode in class Object
Returns:
The hashCode

addTransformationClass

public void addTransformationClass(Object classObject)

getTransformationClasses

public List<Object> getTransformationClasses()
Returns:
A list of transformation classes. This will likely be generated xtend2 transformation classes.