de.cau.cs.kieler.kies.transformation.util
Class TransformationUtil

java.lang.Object
  extended by de.cau.cs.kieler.kies.transformation.util.TransformationUtil

public final class TransformationUtil
extends Object

Utility class providing convenient methods for the esterel to synccharts transformation and the pure synccharts optimization.

Rating red

Nested Class Summary
static class TransformationUtil.TransformationType
          The enumeration is used to determine which type of headless transformation should be performed.
 
Field Summary
static Logger logger
          KIES's own logger.
 
Method Summary
static void addToFrontOfList(List<State> list1, List<State> list2)
          Adds all elements of list2 to the front of list1.
static boolean compareTrigger(Action t1, Action t2)
          Compares the triggers of two transitions.
static Expression convertConstantExpression(ConstantExpression cexpr)
          Converts an Esterel ConstantExpression into an equivalent Expression.
static IFile createSyncchartDiagram(IFile kixsFile)
          Creates a new synccharts diagram at the passed location.
static void debug(Object obj)
          may be used to print some debug information.
static void doInitialEsterelTransformation(IFile strlFile, IFile kixsFile)
          Fill the root esterel elements into a new syncchart.
static IEditorPart getActiveEditor()
           
static List<EObject> getCurrentEditorSelection()
           
static String getSerializedString(EObject e)
          Returns the textual representation of the passed esterel object.
static org.eclipse.xtend.expression.Variable getXtendVarBoolean(boolean bool)
           
static boolean isEsterelElement(EObject obj)
           
static void openKidsInEditor(IFile file)
           
static boolean performHeadlessTransformation(IFile kixsFile, TransformationUtil.TransformationType type)
          Performs a headless transformation on the passed kixsFile.
static boolean performHeadlessTransformation(IFile kixsFile, TransformationUtil.TransformationType type, Map<String,Boolean> globalVars)
          Performs a headless transformation on the passed kixsFile.
static void raiseStatus(String message)
          call this method from xtend in order to open a new status information window.
static void refreshEditPolicies()
          In case the active editor is a IDiagramWorkbenchPart all of its EditPolicies will be refreshed.
static void setBodyReference(State s, EObject obj)
          Convenient method for setting the body reference for a state.
static IFile strlToKixs(IFile strlFile)
          Performs initial transformation of the passed Esterel file into a SyncCharts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static Logger logger
KIES's own logger.

Method Detail

getSerializedString

public static String getSerializedString(EObject e)
Returns the textual representation of the passed esterel object.

Parameters:
e - esterel object
Returns:
serialized string

isEsterelElement

public static boolean isEsterelElement(EObject obj)
Parameters:
obj - the EObject to test
Returns:
true if obj is an esterel element, false otherwise. Passing null will result in false being returned.

setBodyReference

public static void setBodyReference(State s,
                                    EObject obj)
Convenient method for setting the body reference for a state. A new TextualCode element is created and added to the passed state. The state's type is set to StateType.TEXTUAL

Parameters:
s - the parent state
obj - any EObject

convertConstantExpression

public static Expression convertConstantExpression(ConstantExpression cexpr)
Converts an Esterel ConstantExpression into an equivalent Expression. This is in unambiguous order: IntValue, FloatValue, BooleanValue or an TextExpression for a string constant or a referenced constant.

Parameters:
cexpr - constant expression to convert
Returns:
equivalent kexpression

compareTrigger

public static boolean compareTrigger(Action t1,
                                     Action t2)
Compares the triggers of two transitions. Any delay is ignored as it does not matter here. The same applies for any effects of the second transition. Used in context of optimization rule3.

Parameters:
t1 - chronologically first transition
t2 - chronologically second transition
Returns:
true if the triggers of both transitions match, false otherwise.

addToFrontOfList

public static void addToFrontOfList(List<State> list1,
                                    List<State> list2)
Adds all elements of list2 to the front of list1.

Parameters:
list1 - - end of the new list
list2 - - front of the new list

getActiveEditor

public static IEditorPart getActiveEditor()
Returns:
the currently active editor.

getCurrentEditorSelection

public static List<EObject> getCurrentEditorSelection()
Returns:
the current selection within the currently active editor.

doInitialEsterelTransformation

public static void doInitialEsterelTransformation(IFile strlFile,
                                                  IFile kixsFile)
Fill the root esterel elements into a new syncchart.

Parameters:
strlFile - esterel file to add to the synccharts
kixsFile - synccharts model file

createSyncchartDiagram

public static IFile createSyncchartDiagram(IFile kixsFile)
Creates a new synccharts diagram at the passed location. If the file already exists, a dialog is opened asking the user if he wants to overwrite the file or specify a new name. Furthermore, if the corresponding .kids file is already opened, it is closed and deleted first in order to avoid any graphical relicts.

Parameters:
kixsFile - file location
Returns:
the created kixsFile, or null in case the action was canceled by the user.

strlToKixs

public static IFile strlToKixs(IFile strlFile)
Performs initial transformation of the passed Esterel file into a SyncCharts.

Parameters:
strlFile - esterel file to transform
Returns:
The created kixs IFile. null if nothing was created.

refreshEditPolicies

public static void refreshEditPolicies()
In case the active editor is a IDiagramWorkbenchPart all of its EditPolicies will be refreshed.


performHeadlessTransformation

public static boolean performHeadlessTransformation(IFile kixsFile,
                                                    TransformationUtil.TransformationType type)
Performs a headless transformation on the passed kixsFile. The transformation can either be a Esterel to SyncCharts transformation or a SyncCharts optimization depending on the type parameter.

Parameters:
kixsFile - the file to transform.
type - TransformationUtil.TransformationType determining the type of this transformation.
Returns:
true if the transformation was successful, false otherwise.

performHeadlessTransformation

public static boolean performHeadlessTransformation(IFile kixsFile,
                                                    TransformationUtil.TransformationType type,
                                                    Map<String,Boolean> globalVars)
Performs a headless transformation on the passed kixsFile. The transformation can either be a Esterel to SyncCharts transformation or a SyncCharts optimization depending on the type parameter.

Parameters:
kixsFile - the file to transform.
type - TransformationUtil.TransformationType determining the type of this transformation.
globalVars - a map containing global variables that are me passed to the created data component.
Returns:
true if the transformation was successful, false otherwise.

openKidsInEditor

public static void openKidsInEditor(IFile file)
Parameters:
file - the IFile that should be opened in a new SyncCharts editor. Either the *.kids or the *.kixs file can be passed. In case the *.kixs file is passed, a kids file with the same name is tried to be opened.

getXtendVarBoolean

public static org.eclipse.xtend.expression.Variable getXtendVarBoolean(boolean bool)
Parameters:
bool - desired value
Returns:
a new boolean xtend Variable.

raiseStatus

public static void raiseStatus(String message)
call this method from xtend in order to open a new status information window.

Parameters:
message - the message to display

debug

public static void debug(Object obj)
may be used to print some debug information.

Parameters:
obj - any obj