de.cau.cs.kieler.core.model.transformation.xtend
Class XtendTransformationFramework

java.lang.Object
  extended by de.cau.cs.kieler.core.model.transformation.xtend.XtendTransformationFramework
All Implemented Interfaces:
ITransformationFramework

public class XtendTransformationFramework
extends Object
implements ITransformationFramework

An implementation of the ITransformationFramework interface for the use with the Xtend framework.

Rating proposed yellow
(2010-01-08)

Constructor Summary
XtendTransformationFramework()
          Creates a new Xtend component.
 
Method Summary
 List<Object> createParameterMapping(List<EObject> parametersToMap, String... parameter)
          Creates a mapping between the selected diagram elements and the given list of formal parameters.
 Object executeTransformation()
          Executes a transformation.
 String getFileExtension()
          The default file extension for Xtend is 'ext'.
 boolean initializeTransformation(String fileName, String operation, String... basePackages)
          Initializes a transformation using the XtendFacade.
 List<AbstractTransformation> parseTransformations(URL fileName, boolean inplaceOnly)
          Parses a transformation file and returns the existing transformations.
 void reset()
          Resets the framework.
 boolean setParameters(List<EObject> parametersToMap, String... parameter)
          Sets the transformation parameters by matching the current selection with the given list of types.
 void setParameters(Object[] parameter)
          Sets the actual parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XtendTransformationFramework

public XtendTransformationFramework()
Creates a new Xtend component.

Method Detail

setParameters

public void setParameters(Object[] parameter)
Sets the actual parameters.

Specified by:
setParameters in interface ITransformationFramework
Parameters:
parameter - The parameters.

createParameterMapping

public List<Object> createParameterMapping(List<EObject> parametersToMap,
                                           String... parameter)
Creates a mapping between the selected diagram elements and the given list of formal parameters.

Specified by:
createParameterMapping in interface ITransformationFramework
Parameters:
parametersToMap - The list of parameters that should be mapped. If this is null, the parameters are retrieved from the current selection
parameter - The list of formal parameters
Returns:
The parameters or null if the mapping could not achieved

setParameters

public boolean setParameters(List<EObject> parametersToMap,
                             String... parameter)
Sets the transformation parameters by matching the current selection with the given list of types.

Specified by:
setParameters in interface ITransformationFramework
Parameters:
parametersToMap - The list of parameters that should be mapped. If this is null, the parameters are retrieved from the current selection
parameter - The list of parameter types.
Returns:
True if all parameters could be matched

reset

public void reset()
Resets the framework. This needs to be called if a transformation is initialized but not executed.

Specified by:
reset in interface ITransformationFramework

initializeTransformation

public boolean initializeTransformation(String fileName,
                                        String operation,
                                        String... basePackages)
Initializes a transformation using the XtendFacade.

Specified by:
initializeTransformation in interface ITransformationFramework
Parameters:
fileName - The extension file name
operation - The extension to execute
basePackages - The class name of the editors EPackage
Returns:
False if an error occurred.

executeTransformation

public Object executeTransformation()
                             throws TransformationException
Executes a transformation.

Specified by:
executeTransformation in interface ITransformationFramework
Returns:
The return value from XtendFacade.call()
Throws:
TransformationException - if executing the transformation failed

parseTransformations

public List<AbstractTransformation> parseTransformations(URL fileName,
                                                         boolean inplaceOnly)
Parses a transformation file and returns the existing transformations.

Specified by:
parseTransformations in interface ITransformationFramework
Parameters:
fileName - a URL to the transformation file
inplaceOnly - indicates if only in-place transformations should be parsed. If this flag is set to 'false' in-place transformations will be ignored!
Returns:
a list of abstract transformations.

getFileExtension

public String getFileExtension()
The default file extension for Xtend is 'ext'.

Specified by:
getFileExtension in interface ITransformationFramework
Returns:
'ext'