de.cau.cs.kieler.kies.transformation
Class AbstractTransformationDataComponent

java.lang.Object
  extended by de.cau.cs.kieler.sim.kiem.internal.AbstractDataComponent
      extended by de.cau.cs.kieler.sim.kiem.JSONObjectDataComponent
          extended by de.cau.cs.kieler.kies.transformation.AbstractTransformationDataComponent
All Implemented Interfaces:
IDataComponent, IJSONObjectDataComponent, IExecutableExtension
Direct Known Subclasses:
EsterelToSyncChartDataComponent, SyncChartsOptimizationDataComponent

public abstract class AbstractTransformationDataComponent
extends JSONObjectDataComponent

Abstract implementation of a TransformationDataComponent.

Rating red

Field Summary
protected  ITransformationContext currentContext
          the current transformation context.
protected  TransformationDescriptor currentDescriptor
          the current transformation descriptor.
protected  org.eclipse.xtend.XtendFacade facade
          currently used facade.
protected  Map<String,org.eclipse.xtend.expression.Variable> globalVars
          global variables for the certain transformation.
protected  boolean headless
          headless execution omits checks for an opened editor.
protected  boolean kiviMode
          is the transformation executed by KiVi?
protected  Region rootRegion
          root region of the current resource.
protected  State rootState
          root state of the current resource.
 
Fields inherited from class de.cau.cs.kieler.sim.kiem.internal.AbstractDataComponent
MASTER_CMD_MACROSTEP, MASTER_CMD_PAUSE, MASTER_CMD_RUN, MASTER_CMD_STEP, MASTER_CMD_STEPBACK, MASTER_CMD_STOP
 
Constructor Summary
AbstractTransformationDataComponent(Map<String,org.eclipse.xtend.expression.Variable> globVars, boolean abusemode)
          Any extending class has to provide a map with global Variables.
 
Method Summary
abstract  void doPostTransformation()
          this method is called if there are no further steps to do and the transformation will terminate.
protected  void fetchRootRegionAndState()
          fetches the root region and root state of the currently active synccharts editor.
protected  void finished()
          mark this transformation finished and throw a new KiemExecutionException in order to terminate the current execution.
protected  TransactionalEditingDomain getActiveEditorEditingDomain()
           
abstract  String[] getBasePackages()
           
 ITransformationContext getCurrentContext()
           
 TransformationDescriptor getCurrentDescriptor()
           
 TransactionalEditingDomain getDomain()
           
protected  TransactionalEditingDomain getEditingDomainForResourceSet(ResourceSet rs)
           
abstract  TransformationDescriptor getNextTransformation()
           
 State getRootState()
           
abstract  String getTransformationFile()
           
 org.eclipse.xtend.XtendFacade getXtendFacade()
           
 void initialize()
          Initialize.
 boolean isFinished()
           
 boolean isHistoryObserver()
          Flags that this component can handle past, already computed history values.
 boolean isObserver()
          To check whether the DataComponent is an observer.
 boolean isProducer()
          To check whether the DataComponent is a producer.
 boolean setGlobalVariable(String globalVar, boolean value)
          set the value of a global variable.
 void setHeadless(boolean headless)
           
 void setRootState(State rootState)
           
 JSONObject step(JSONObject arg0)
          Step method for a DataObserver and a DataPrroducer.
 void wrapup()
          Wrap-up.
 
Methods inherited from class de.cau.cs.kieler.sim.kiem.JSONObjectDataComponent
getInitialVariables, provideFilterKeysJSON, provideInitialVariables, setInitialVariables
 
Methods inherited from class de.cau.cs.kieler.sim.kiem.internal.AbstractDataComponent
checkProperties, finalize, getConfigurationElement, getCurrentComponentID, getDataComponentId, getName, getPluginId, getProperties, getShell, isDeltaObserver, isHistoryStep, isInvisible, isMacroStepDone, isMaster, isMasterImplementingGUI, isMultiInstantiable, masterCommand, masterGetAimedStepDuration, masterGUI, masterGUIisEnabled, masterIsPaused, masterIsRunning, masterSetAimedStepDuration, masterSetKIEMInstance, notifyEvent, provideEventOfInterest, provideFilterKeys, provideProperties, setConfigurationElemenet, setCurrentComponentID, setHistoryStep, setInitializationData, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

facade

protected org.eclipse.xtend.XtendFacade facade
currently used facade.


globalVars

protected Map<String,org.eclipse.xtend.expression.Variable> globalVars
global variables for the certain transformation.


kiviMode

protected boolean kiviMode
is the transformation executed by KiVi?


currentContext

protected ITransformationContext currentContext
the current transformation context.


currentDescriptor

protected TransformationDescriptor currentDescriptor
the current transformation descriptor.


headless

protected boolean headless
headless execution omits checks for an opened editor.


rootState

protected State rootState
root state of the current resource.


rootRegion

protected Region rootRegion
root region of the current resource.

Constructor Detail

AbstractTransformationDataComponent

public AbstractTransformationDataComponent(Map<String,org.eclipse.xtend.expression.Variable> globVars,
                                           boolean abusemode)
Any extending class has to provide a map with global Variables.

Parameters:
globVars - Map with global Variables for the XtendFacade.
abusemode - pass true if this data component is used in a way that does not use KIEM.
Method Detail

initialize

public void initialize()
                throws KiemInitializationException
Initialize. Do some initializing prior to execution. If an error occurs during initialization, the DataComponent should raise a KiemInitializationException.

Throws:
KiemInitializationException - a KiemInitializationException

step

public JSONObject step(JSONObject arg0)
                throws KiemExecutionException
Step method for a DataObserver and a DataPrroducer.

For a producer only the argument will always be null. For an observer only this method will be called asynchronous. This may mean that in case the observer is slow, it may be skipped at some consecutive steps until it becomes ready again. If this is not desired and the observer MUST NOT be skipped, then the DataComponent should also be a DataProducer but return just null.

If an error occurs during the execution of the step method, a DataComponent should raise a KiemExecutionException that is then catched by the execution manager an brought to the user's attention.

Parameters:
arg0 - the concrete JSONObject of input data (if observer)
Returns:
the JSONObject with the output data (if producer)
Throws:
KiemExecutionException - a KiemExecutionException

wrapup

public void wrapup()
            throws KiemInitializationException
Wrap-up. Do some wrapping-up after execution has finished. If an error occurs during wrap up, the DataComponent should raise a KiemInitializationException.

Throws:
KiemInitializationException - a KiemInitializationException

isObserver

public boolean isObserver()
To check whether the DataComponent is an observer. If the DataComponent is an observer the arguments in its step() method will be != null.

Returns:
true, if is observer

isProducer

public boolean isProducer()
To check whether the DataComponent is a producer. If the DataComponent is a producer it should return != null in its step() method.

Returns:
true, if is producer

isHistoryObserver

public boolean isHistoryObserver()
Flags that this component can handle past, already computed history values. Overwrite this if this component can explicitly handle past recorded history values.
In case the user makes steps back into the history, only observers that return true in this method will get any (recorded) history data. Components that return false (default) will not get any data, while the the user navigates within the recorded tick area.

Overrides:
isHistoryObserver in class AbstractDataComponent
Returns:
a boolean indicating that the component is recorded observer

setGlobalVariable

public boolean setGlobalVariable(String globalVar,
                                 boolean value)
set the value of a global variable. As identifier for globalVar only use the GLOBVAR constants defined by the specific transformation data component.

Parameters:
globalVar - variable to change
value - new value
Returns:
true if successful

getXtendFacade

public org.eclipse.xtend.XtendFacade getXtendFacade()
Returns:
the current XtendFacade

getBasePackages

public abstract String[] getBasePackages()
Returns:
all base packages needed for the transformations planned.

getTransformationFile

public abstract String getTransformationFile()
Returns:
the actual transformation file (.ext)

getNextTransformation

public abstract TransformationDescriptor getNextTransformation()
Returns:
either the next transformation or null if nothing can be transformed anymore.

doPostTransformation

public abstract void doPostTransformation()
this method is called if there are no further steps to do and the transformation will terminate.


finished

protected void finished()
                 throws KiemExecutionException
mark this transformation finished and throw a new KiemExecutionException in order to terminate the current execution.

Throws:
KiemExecutionException - a exception letting the user know that the current execution finished.

getActiveEditorEditingDomain

protected TransactionalEditingDomain getActiveEditorEditingDomain()
Returns:
currently active editor's editing domain

getEditingDomainForResourceSet

protected TransactionalEditingDomain getEditingDomainForResourceSet(ResourceSet rs)
Parameters:
rs - some resource set.
Returns:
an editing domain for this resource set.

fetchRootRegionAndState

protected void fetchRootRegionAndState()
fetches the root region and root state of the currently active synccharts editor.


getDomain

public TransactionalEditingDomain getDomain()
Returns:
the editing domain

isFinished

public boolean isFinished()
Returns:
the finished

getCurrentContext

public ITransformationContext getCurrentContext()
Returns:
the currentContext

getCurrentDescriptor

public TransformationDescriptor getCurrentDescriptor()
Returns:
the currentDescriptor

setHeadless

public void setHeadless(boolean headless)
Parameters:
headless - the headless to set

setRootState

public void setRootState(State rootState)
Parameters:
rootState - the rootState to set

getRootState

public State getRootState()
Returns:
the rootState