de.cau.cs.kieler.synccharts.viewmanagement
Class StateActivityObserver

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.synccharts.viewmanagement.StateActivityObserver
All Implemented Interfaces:
IDataComponent, IJSONObjectDataComponent, IExecutableExtension

public class StateActivityObserver
extends JSONObjectDataComponent
implements IJSONObjectDataComponent

Rating red

Field Summary
protected  IWorkbenchPage activePage
           
protected  boolean activePageFlag
           
static StateActivityObserver INSTANCE
          FIXME: haf workaround: Singleton pattern to get simple access to the rootEditPart
 
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
StateActivityObserver()
           
 
Method Summary
 void bringToFront()
          This method brings the VM view to the front.
 void checkProperties(KiemProperty[] properties)
          This method is intended to check if the properties are set correctly.
protected  IWorkbenchPage getActivePage()
          Gets the active page (blocking) from the UI thread.
 EditPart getEditPart(String elementURIFragment, EditPart parent)
           
 String getElementURIFragment(EditPart editPart)
          This method searches recursively for an EditPart using the modelElement URIFragment provided.
 EditPart getRootEditPart()
           
 void initialize()
          Initialize.
 boolean isDeltaObserver()
          Checks if component is a delta observer.
 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.
 KiemProperty[] provideProperties()
          Provide properties for this component.
 JSONObject step(JSONObject data)
          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
finalize, getConfigurationElement, getDataComponentId, getName, getPluginId, getProperties, isHistoryStep, isInvisible, isMacroStepDone, isMaster, isMasterImplementingGUI, isMultiInstantiable, masterCommand, masterGetAimedStepDuration, masterGUI, masterGUIisEnabled, masterIsPaused, masterIsRunning, masterSetAimedStepDuration, masterSetKIEMInstance, notifyEvent, provideEventOfInterest, provideFilterKeys, setConfigurationElemenet, setHistoryStep, setInitializationData, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static StateActivityObserver INSTANCE
FIXME: haf workaround: Singleton pattern to get simple access to the rootEditPart


activePage

protected IWorkbenchPage activePage

activePageFlag

protected boolean activePageFlag
Constructor Detail

StateActivityObserver

public StateActivityObserver()
Method Detail

bringToFront

public void bringToFront()
This method brings the VM view to the front.


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

getActivePage

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

Returns:
the active page

getEditPart

public EditPart getEditPart(String elementURIFragment,
                            EditPart parent)

getElementURIFragment

public String getElementURIFragment(EditPart editPart)
This method searches recursively for an EditPart using the modelElement URIFragment provided. The latter can be obtained by calling: myEObject.eResource().getURIFragment(myEObject).toString(); This returns the URI fragment that, when passed to getEObject will return the given object.

Parameters:
elementURIFragment - the URIFragment of the EObject to search for
parent - the parent EditPart
Returns:
the EditPart of the EObject

getRootEditPart

public EditPart getRootEditPart()
Returns:
the rootEditPart

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

isDeltaObserver

public boolean isDeltaObserver()
Description copied from class: AbstractDataComponent
Checks if component is a delta observer. Delta values are all changed values that exist in the present tick (and in the past ticks when this component may have been skipped).
If a component wants all (accumulated & updated) values of the present tick, it should return false.

Example:

Step...........|..1..|..2..|..3..|..4..|..5..|
-----------------------------------------------------
Producer.......|..A..|../..|..B..|..C..|..D..|
-----------------------------------------------------
Observer.......|.A...|.skip|.skip|.ABC.|.ABCD|
-----------------------------------------------------
DeltaObserver..|.A...|.skip|.skip|.BC..|.D...|
-----------------------------------------------------

The above figure shows an execution of 5 steps with three participating DataComponents. One producer generates (different) data at steps 1, 3, 4, and 5. It does not produce any data in step 2. Both observers get skipped in steps 2 and 3 (e. g., because they might be a little slow). In step 1 both observers get the A data. Because there is no data in the pool, both inputs (their parameter values) are the same. In steps 2 and 3 both get skipped. Their step() method is not called in these steps. In step 4 the DeltaObserver gets only the B and the D data, produced in steps 3 and 4 (these are the delta values to the last time it was not skipped, i. e., step 1). The other observer gets the whole data of the pool, namely the A, B, and the C data. In step 5 the recently produced D data are the only ones that arrive at the DeltaObserver while the other observer gets all ever produced data A, B, C and D.

Overrides:
isDeltaObserver in class AbstractDataComponent
Returns:
true, if is delta observer

isHistoryObserver

public boolean isHistoryObserver()
Description copied from class: AbstractDataComponent
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

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

provideProperties

public 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

step

public JSONObject step(JSONObject data)
                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:
data - 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()
Description copied from interface: IDataComponent
Wrap-up. Do some wrapping-up after execution has finished. If an error occurs during wrap up, the DataComponent should raise a KiemInitializationException.

Specified by:
wrapup in interface IDataComponent