de.cau.cs.kieler.sim.kiem.ui.datacomponent
Class JSONObjectSimulationDataComponent

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.sim.kiem.ui.datacomponent.JSONObjectSimulationDataComponent
All Implemented Interfaces:
IDataComponent, IJSONObjectDataComponent, IExecutableExtension
Direct Known Subclasses:
AbstractAutomatedComponent, DataComponent, SyncchartsSimDataComponent

public abstract class JSONObjectSimulationDataComponent
extends JSONObjectDataComponent
implements IJSONObjectDataComponent

The Class JSONObjectDataComponent. Implementation for the extension point JSONObjectDataComponent that implements the interface IJSONObjectDataComponent.

Rating yellow
(2010-08-15)

Nested Class Summary
protected  class JSONObjectSimulationDataComponent.M2MProgressMonitor
           
 
Field Summary
protected  IWorkbenchPage activePage
           
protected  boolean activePageFlag
           
protected  Exception exception
          The initialization exception that can be possibly thrown.
protected  IEditorPart modelEditor
          The editor of the model being simulated.
 
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
JSONObjectSimulationDataComponent()
          Instantiates a new JSONObjectDataComponent.
 
Method Summary
 void bringProblemsViewToFront()
           
 boolean checkModelValidation(EObject rootEObject)
          Check the model validation.
 void checkProperties(KiemProperty[] properties)
          This method is intended to check if the properties are set correctly.
 void doModel2ModelTransform(KielerProgressMonitor monitor)
          Implementation of model 2 model transformation.
 JSONObject doProvideInitialVariables()
          Performs the normal provide initial variables method.
 KiemProperty[] doProvideProperties()
           
 JSONObject doStep(JSONObject jSONObject)
          Implements the real step method for this simulation datacomponent.
protected  IWorkbenchPage getActivePage()
          Gets the active page (blocking) from the UI thread.
protected  IEditorPart getEditor(String kiemEditorProperty)
           
protected  IEditorPart getInputEditor()
           
protected  String getInputModel()
           
protected  URI getInputModelAsURI()
           
protected  EObject getInputModelEObject(IEditorPart editorPart)
           
protected  ResourceSet getInputResourceSet()
           
protected  String getInputWorkspaceModel()
           
 EObject getModelRootElement()
          Gets the models root element, an EObject.
protected  View getNotationElement(IEditorPart diagramEditor)
           
 void initialize()
          Initialize.
 boolean isObserver()
          To check whether the DataComponent is an observer.
 boolean isProducer()
          To check whether the DataComponent is a producer.
protected  boolean isTransformationCompleted()
          Checks whether transformation completed is true.
protected  boolean isTransformationError()
          Checks whether transformation error is true.
 JSONObject provideFilterKeysJSON()
          Provide filter keys and default values as a JSONObject.
 JSONObject provideInitialVariables()
          Provide (local) interface variables and possible initial values.
 KiemProperty[] provideProperties()
          Provide properties for this component.
 URL resolveBundelFile(String relativePath)
           
 JSONObject step(JSONObject jSONObject)
          Step method for a DataObserver and a DataPrroducer.
 
Methods inherited from class de.cau.cs.kieler.sim.kiem.JSONObjectDataComponent
getInitialVariables, setInitialVariables
 
Methods inherited from class de.cau.cs.kieler.sim.kiem.internal.AbstractDataComponent
finalize, getConfigurationElement, getCurrentComponentID, getDataComponentId, getName, getPluginId, getProperties, getShell, isDeltaObserver, isHistoryObserver, isHistoryStep, isInvisible, isMacroStepDone, isMaster, isMasterImplementingGUI, isMultiInstantiable, masterCommand, masterGetAimedStepDuration, masterGUI, masterGUIisEnabled, masterIsPaused, masterIsRunning, masterSetAimedStepDuration, masterSetKIEMInstance, notifyEvent, provideEventOfInterest, provideFilterKeys, setConfigurationElemenet, setCurrentComponentID, setHistoryStep, setInitializationData, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.cau.cs.kieler.sim.kiem.IDataComponent
wrapup
 

Field Detail

modelEditor

protected IEditorPart modelEditor
The editor of the model being simulated.


exception

protected Exception exception
The initialization exception that can be possibly thrown.


activePage

protected IWorkbenchPage activePage

activePageFlag

protected boolean activePageFlag
Constructor Detail

JSONObjectSimulationDataComponent

public JSONObjectSimulationDataComponent()
Instantiates a new JSONObjectDataComponent.

Method Detail

provideFilterKeysJSON

public JSONObject provideFilterKeysJSON()
Provide filter keys and default values as a JSONObject.

Overrides:
provideFilterKeysJSON in class JSONObjectDataComponent
Returns:
the JSONObject

isTransformationCompleted

protected boolean isTransformationCompleted()
Checks whether transformation completed is true.

Returns:
true, if is transformation completed

isTransformationError

protected boolean isTransformationError()
Checks whether transformation error is true.

Returns:
true, if is transformation error

doModel2ModelTransform

public void doModel2ModelTransform(KielerProgressMonitor monitor)
                            throws Exception
Implementation of model 2 model transformation.

Parameters:
monitor - the monitor
Throws:
Exception - the exception

doStep

public JSONObject doStep(JSONObject jSONObject)
                  throws KiemExecutionException
Implements the real step method for this simulation datacomponent.

Parameters:
jSONObject - the j son object
Returns:
the jSON object
Throws:
KiemExecutionException - the kiem execution exception

step

public final JSONObject step(JSONObject jSONObject)
                      throws KiemExecutionException
Description copied from interface: IJSONObjectDataComponent
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.

Specified by:
step in interface IJSONObjectDataComponent
Parameters:
jSONObject - the concrete JSONObject of input data (if observer)
Returns:
the JSONObject with the output data (if producer)
Throws:
KiemExecutionException - a KiemExecutionException

checkModelValidation

public boolean checkModelValidation(EObject rootEObject)
Check the model validation. Should return true if the model is valid, false otherwise.

Example:
Region syncChart = (de.cau.cs.kieler.synccharts.Region) rootEObject;
Diagnostic diagnostic = diagnostician.validate(syncChart);
int serenity = diagnostic.getSeverity();
return (serenity == Diagnostic.OK);

Returns:
true, if successful

doProvideInitialVariables

public JSONObject doProvideInitialVariables()
                                     throws KiemInitializationException
Performs the normal provide initial variables method.

Returns:
the jSON object
Throws:
KiemInitializationException - the kiem initialization exception

getModelRootElement

public final EObject getModelRootElement()
Gets the models root element, an EObject.

Returns:
the model root element

provideInitialVariables

public final JSONObject provideInitialVariables()
                                         throws KiemInitializationException
Description copied from class: JSONObjectDataComponent
Provide (local) interface variables and possible initial values. This is an optional method that will provide some interface variable keys and values that can be used by other DataComponents within and after the initialization phase every DataComponent may receive the union of all those variable keys by calling the JSONObjectDataComponent.getInitialVariables() method.

Overrides:
provideInitialVariables in class JSONObjectDataComponent
Returns:
the local initial variables as a JSONObject
Throws:
KiemInitializationException - if a property prevents the execution of this DataComponent this error should be thrown

getActivePage

protected IWorkbenchPage getActivePage()
Gets the active page (blocking) from the UI thread.

Returns:
the active page

getInputEditor

protected IEditorPart getInputEditor()

getInputModelAsURI

protected URI getInputModelAsURI()

getInputWorkspaceModel

protected String getInputWorkspaceModel()

getInputModel

protected String getInputModel()

getInputModelEObject

protected EObject getInputModelEObject(IEditorPart editorPart)

getNotationElement

protected View getNotationElement(IEditorPart diagramEditor)

getInputResourceSet

protected ResourceSet getInputResourceSet()

resolveBundelFile

public URL resolveBundelFile(String relativePath)

initialize

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

Specified by:
initialize in interface IDataComponent
Throws:
KiemInitializationException - a KiemInitializationException

bringProblemsViewToFront

public void bringProblemsViewToFront()

isObserver

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

Specified by:
isObserver in interface IDataComponent
Returns:
true, if is observer

isProducer

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

Specified by:
isProducer in interface IDataComponent
Returns:
true, if is producer

doProvideProperties

public KiemProperty[] doProvideProperties()

provideProperties

public final KiemProperty[] provideProperties()
Description copied from class: AbstractDataComponent
Provide properties for this component. The component may create and publicize its properties with this method. They will be set/modified by the execution manager during the user edits them. Whenever the user decides to run/start the execution the properties are tested (see below) and the component may use there settings.

The following lists a simple example for such properties:
\ATOverride
public KiemProperty[] provideProperties() {
KiemProperty[] properties = new KiemProperty[7];
properties[0] = new KiemProperty(
"state name",
"state");
properties[1] = new KiemProperty(
"some bool",
true);
properties[2] = new KiemProperty(
"an integer",
2);
properties[3] = new KiemProperty(
"a file",
new KiemPropertyTypeFile(),
"c:/nothing.txt");
String[] items = {"trace 1","trace 2", "trace 3", "trace 4"};
properties[4] = new KiemProperty(
"a choice",
new KiemPropertyTypeChoice(items),
items[2]);
properties[5] = new KiemProperty(
"workspace file",
new KiemPropertyTypeWorkspaceFile(),
"/nothing.txt");
properties[6] = new KiemProperty(
"editor",
new KiemPropertyTypeEditor(),
"");
return properties;
}

These are built-in types that can always be extended using the KiemProperty class.

Overrides:
provideProperties in class AbstractDataComponent
Returns:
the KiemProperty[] or null if no properties are provided

checkProperties

public void checkProperties(KiemProperty[] properties)
                     throws KiemPropertyException
Description copied from class: AbstractDataComponent
This method is intended to check if the properties are set correctly. Here a component may check for required and optional properties and their settings. Also an KiemPropertyError can be raised if some property prevents the execution of this component.

Overrides:
checkProperties in class AbstractDataComponent
Parameters:
properties - the properties with the current user settings
Throws:
KiemPropertyException - if a property prevents the execution of this DataComponent this error should be thrown

getEditor

protected IEditorPart getEditor(String kiemEditorProperty)