variableList = declarationInstance.
+ getVariableDeclarationInstances();
+ //reinitializes ValuesTable
+ ValuesDataProvider.removeData();
+ //sets ValuesTable with the list of variables
+ for (VariableDeclarationInstance value : variableList) {
+ ValuesData v = new ValuesData();
+ //set nomenclature value
+ v.setCurrent(getStringValue(value.getCurrentValue()));
+ v.setName(value.getVariableDeclaration().getName());
+ ValuesDataProvider.addValues(v);
+ }
+ //looks for a active ValuesView instance and call update.
+ ViewPart valuesPart = (ViewPart) wb.getActiveWorkbenchWindow().
+ getActivePage().findView("com.irtsaintexupery.fiacre.simulator"
+ + ".perspective.valuesView");
+ if (valuesPart instanceof ValuesView) {
+ valuesView = (ValuesView) valuesPart;
+ valuesView.update();
+ }
+ }
+ }
+
+ //Jorge Gutierrez 25/08/2016
+ /**
+ * Treats variable value and returns the corresponding nomenclature value.
+ *
+ * Recursive function that returns a character String by following the next rules.
+ * @param ve the valuesExpression given by Fiacre Model.
+ * @return the character String according to the embedded type.
+ */
+ public static String getStringValue(ValueExpression ve){
+ //returns false when ValueExpression is of type FalseLiteral
+ if(ve instanceof FalseLiteral){
+ return "False";
+ }
+ //returns true when ValueExpression is of type TrueLiteral
+ else if (ve instanceof TrueLiteral) {
+ return "True";
+ //returns number when ValueExpression is of type NaturaLiteral
+ }else if (ve instanceof NaturalLiteral) {
+ return ((NaturalLiteral) ve).getValue()+"";
+ //returns the ValueExpression * contained by [*] when is of type ArrayExpresion
+ }else if (ve instanceof ArrayExpression) {
+ ArrayExpression ae = (ArrayExpression)ve;
+ String text = "[";
+ for (int i = 0; i < ae.getValues().size(); i++) {
+ Expression e = ae.getValues().get(i);
+ if (i == ae.getValues().size() - 1) {
+ text = text + getStringValue((ValueExpression)e);
+ }else {
+ text = text + getStringValue((ValueExpression)e) + ", ";
+ }
+ }
+ return text + "]";
+ //returns the ValueExpression * contained by {*} when is of type RecordExpression
+ }else if (ve instanceof RecordExpression) {
+ RecordExpression re = (RecordExpression)ve;
+ String text = "{";
+ for (int i = 0; i < re.getFields().size(); i++) {
+ FieldExpression fe = re.getFields().get(i);
+ RecordFieldDeclaration rfd = (RecordFieldDeclaration)fe.getField();
+ //if it is the last element, does not add the separator ", "
+ if (i == re.getFields().size() - 1) {
+ text = text + rfd.getName() + " = " +getStringValue((ValueExpression)fe.getValue());
+ }else {
+ text = text + rfd.getName() + " = " +getStringValue((ValueExpression)fe.getValue()) + ", ";
+ }
+ }
+ return text + "}";
+ //returns the ValueExpression * contained by {|*|} when is of type QueueExpression
+ }else if (ve instanceof QueueExpression) {
+ QueueExpression qe = (QueueExpression)ve;
+ String text = "{|";
+ for (int i = 0; i < qe.getValues().size(); i++) {
+ Expression e = qe.getValues().get(i);
+ //if it is the last element, does not add the separator ", "
+ if (i == qe.getValues().size() - 1) {
+ text = text + getStringValue((ValueExpression)e);
+ }else {
+ text = text + getStringValue((ValueExpression)e) + ", ";
+ }
+ }
+ return text + "|}";
+ }else if(ve instanceof IdentifierExpression) {
+ //returns a ValueExpression contained by TagDeclaration name (*) when is of type ConstructionExpression
+ if (ve instanceof ConstructionExpression) {
+ ConstructionExpression ce = (ConstructionExpression)ve;
+ String text = "";
+ for (int i = 0; i < ce.getParameters().size(); i++) {
+ Expression e = ce.getParameters().get(i);
+ //if it is the last element, does not add the separator ", "
+ if (i == ce.getParameters().size() - 1) {
+ text = text + ((UnionTagDeclaration)ce.getDeclaration()).getName() + "(" + getStringValue((ValueExpression)e) + ")";
+ }else {
+ text = text + ((UnionTagDeclaration)ce.getDeclaration()).getName() + "(" + getStringValue((ValueExpression)e) + "), ";
+ }
+ }
+ return text;
+ //returns the TagDeclaration name when is of type IdentifierExpression
+ } else {
+ IdentifierExpression ie = (IdentifierExpression)ve;
+ ExpressionDeclarationUse edu = ie.getDeclaration();
+ UnionTagDeclaration utd = (UnionTagDeclaration)ie.getDeclaration();
+ return utd.getName();
+ }
+ }
+ return "";
+
+ }
+
+
+ /**
+ * Cleans the Values Table.
+ *
+ * Removes data from ValuesDataProvider and looks for the ValuesView instance to
+ * call an update. Show an empty table in the updating
+ */
+ public void reinitializeValuesView() {
+ ValuesDataProvider.removeData();
+ valuesView.update();
+ }
+
+ /**
+ * Makes an update to show the currents instances on instance window (views part).
+ *
+ * Calls an update by giving the Tree head (TreeObject) which contains the instances name in the root and
+ * their children from the Fiacre Model.
+ */
+ public void updateInstanceView() {
+ //updates current model.
+ djeViews = FiacreSimulator.sendDje();
+ //call update by passing a TreeObject.
+ instancesView.update(returnInstances());
+ }
+
+ //Jorge Gutierrez 17/08/2016
+ /**
+ * Adds a delay element (ActionState) in the actionStack when the DelayAction is launched
+ * @param dl The value about the delay given by the user
+ */
+ public void addDelayToAction (String dl){
+ ActionState obj = new ActionState("DELAY: " + dl, true);
+ actionStack.add(obj);
+ }
+
+ /**
+ * Adds a fire element (ActionState) in the actionStack when the FireAction is launched
+ * @param dl The value about the delay given by the user
+ */
+ public void addFireToAction (String tr_name){
+ //Jorge Gutierrez 16/08/2016
+ ActionState actionFire = new ActionState(tr_name, false);
+ actionStack.add(actionFire);
+ }
+
+ /**
+ * executes a transition selected by the user in the Fiacre Model
+ *
+ * Adds the action to the stackAction, search in the Map the StatementBlock
+ * to get the fireable Transition in the Fiacre Model, fires the transition
+ * and updates every view.
+ * @param tr_name the transition name taken from transition table, it will
+ * be used as key in transitionExecutableMap.
+ */
+ public void fireTransition(String tr_name) {
+ try {
+
+ //stores the fire action in the stakeAction
+ addFireToAction(tr_name);
+ //Maps the StatementBlock by transition name key
+ StatementBlock transition = transitionExecutableMap.get(tr_name);
+ LibTTS libtts = FiacreSimulator.getLibTTS();
+ long tr_long = -1;
+ djeViews = FiacreSimulator.sendDje();
+ //gets simulated transition
+ for (Map.Entry tr : libtts.getTTSSimulator()
+ .getAllTransitions().entrySet()) {
+ if (tr.getValue().getName().equals(transition.getName())) {
+ tr_long = tr.getKey();
+ }
+ }
+ //fires transition
+ libtts.getTTSSimulator().fireTransition(tr_long);
+
+ updateAll();
+
+ djeViews.extractExecutedStatements(libtts.getTTSSimulator()
+ .getAllTransitions().get(tr_long).name);/////////////////////////////////////
+ //update all views to show a consistent feedback.
+ //updateAll();
+ } catch (Error e) {
+ Utils.showException("Error", e);
+ // e.printStackTrace();
+ } catch (StateNotFound e) {
+ Utils.showException("StateNotFound", e);
+ // e.printStackTrace();
+ } catch (TransitionNotFound e) {
+ Utils.showException("TransitionNotFound", e);
+ // e.printStackTrace();
+ } catch (NotFireable e) {
+ Utils.showException("NotFireable", e);
+ // e.printStackTrace();
+ } catch (TException e) {
+ Utils.showException("TException", e);
+ // e.printStackTrace();
+ } catch (NullPointerException e) {
+ Utils.showException("NullPointerException", e);
+ // e.printStackTrace();
+ }
+
+ }
+
+
+
+ // Jorge Gutierrez 05/08/2016
+ /**
+ * Returns a list of executable transitions names given by executed model
+ *
+ * Takes a list of StatementsBlocks from the model and looks for the executable
+ * StatementsBlocks to put in a transition map and to put its name in a List of String
+ * @return List of character String according to executable transition name and date.
+ */
+ private ArrayList returnTransitions() {
+ //Takes all statement blocks by the instance model
+ EList statementList = djeViews.getInstanceModel()
+ .getStatementBlocks();
+ ArrayList statementListString = new ArrayList();
+ transitionExecutableMap.clear();
+ //Puts the executable statements in a List
+ for (StatementBlock s : statementList) {
+ if (s instanceof ExecutableStatementBlock) {
+ String statementAndDate = "";
+// if (s instanceof EnabledStatementBlock) {
+ statementAndDate = s.getName() + " - " + ((ExecutableStatementBlock)s).getDate();
+// }else {
+// statementAndDate = s.getName();
+// }
+ statementListString.add(statementAndDate);
+ //Maps the statements by the String key. this key is defined by statements name and time needed to execute it
+ transitionExecutableMap.put(statementAndDate, s);
+ }
+ }
+ return statementListString;
+ }
+
+ // Jorge Gutierrez 05/08/2016
+ /**
+ * Indicates if statementBlock mapped by the given string key is Fireable
+ *
+ * Function used by TransitionViews to know if a transition is fireable or not
+ * @return true
if this transition is fireable or false
, is not fireable.
+ */
+ public Boolean isFireable(String s) {
+ if (transitionExecutableMap.get(s) instanceof FireableStatementBlock){
+ return true;
+ }else {
+ return false;
+ }
+ }
+
+ // Jorge Gutierrez 22072016
+ /**
+ * Returns a TreeObject that has the model Instance root and it is connected
+ * with their children
+ *
+ * A TreeObject is a Node with a Tree structure performance that contains a instance name.
+ * When a TreeObject has children it is of type TreeParent that has a Array of TreeObject instances.
+ * The function takes all instances which are on the root and makes depth iteration for each one.
+ * @return Root with all instances as children
+ */
+ public TreeObject returnInstances() {
+ //Takes a Declaration Instance list from the simulated model.
+ EList instanceListDeclaretion = djeViews
+ .getInstanceModel().getInstance();
+ int i = 0;
+ TreeParent rootParent = new TreeParent("");
+ //clears the map that store instances objects.
+ instancesMap.clear();
+ //iterate each instances content.
+ while (i < instanceListDeclaretion.size()) {
+ iterateInstances(instanceListDeclaretion.get(i), rootParent);
+ i++;
+ }
+ return rootParent;
+ }
+
+ /**
+ * Build a Tree of block Instances and maps them to instanceMap until there are not
+ * more embedded Instances
+ *
+ * Checks if Instance is a Process then adds to Parent else checks if it is Component to
+ * iterate recursively its instances and in the same way when it is a Composition.
+ * The instance is mapped by TreeObject key containing its instance name.
+ * @param blockInstance The BlockInstance given as point reference to read through its children.
+ * @param instanceTreeParent The TreeParent given as a reference point to add its children.
+ */
+ private void iterateInstances(BlockInstance blockInstance,
+ TreeParent instanceTreeParent) {
+ //Checks if instance is a Process then adds to Parent reference and instance map.
+ if (blockInstance instanceof ProcessDeclarationInstance) {
+ String nameProcess = ((ProcessDeclarationInstance)
+ blockInstance).getProcess().getName();
+ String currentStateProcess = ((ProcessDeclarationInstance)
+ blockInstance).getCurrentState().getName();
+ TreeObject processNodeObject = new TreeObject(nameProcess + " - "
+ + currentStateProcess);
+ instanceTreeParent.addChild(processNodeObject);
+ // Jorge Gutierrez 01/08/2016 //
+ instancesMap.put(processNodeObject, blockInstance);
+ //Checks if instance is a Component then adds to Parent reference and instance map, and iterate its instances contained.
+ } else if (blockInstance instanceof ComponentDeclarationInstance) {
+ ComponentDeclarationInstance component = ((ComponentDeclarationInstance)
+ blockInstance);
+ String nameComponent = component.getComponent().getName();
+ TreeParent componentNodeParent = new TreeParent(nameComponent);
+ instanceTreeParent.addChild(componentNodeParent);
+ // Jorge Gutierrez 01/08/2016
+ instancesMap.put(componentNodeParent, component);
+ for (int i = 0; i < component.getBlockInstances().size(); i++) {
+ iterateInstances(component.getBlockInstances().get(i), componentNodeParent);
+ }
+ //Checks if instance is a Composition then adds to Parent reference and instance map, and iterate its instances contained.
+ }else {
+ CompositionInstance composition = ((CompositionInstance) blockInstance);
+ String namecomposition = new String("");
+ TreeParent compositionNodeParent = new TreeParent(namecomposition);
+ instanceTreeParent.addChild(compositionNodeParent);
+ instancesMap.put(compositionNodeParent, composition);
+ for (int i = 0; i < composition.getBlockInstances().size(); i++) {
+ iterateInstances(composition.getBlockInstances().get(i), compositionNodeParent);
+ }
+ }
+ }
+
+ // Jorge Gutierrez 05/08/2016
+ /**
+ * Updates the simulated file.
+ *
+ * the function is called by FiacreSimulator class
+ * @param newFile the File selected to be executed.
+ */
+ public void setFile(IFile newFile) {
+ file = newFile;
+ }
+
+ // Jorge Gutierrez 05/08/2016
+ /**
+ * Highlights on editor part the corresponding statement block by selected Transition.
+ *
+ * Finds a Transition Statement Block from the simulated model and marks it on code editor
+ * Selects on Instance view, the instance involved in transition statements code.
+ * @param tr_name The string allocated for a transition.
+ */
+ public void showSelectedTransition(String tr_name) {
+ //takes a Statement Transition block by its name and find stamentBlock on the simulated model.
+ StatementBlock transition = transitionExecutableMap.get(tr_name);
+ InstanceModel instanceModel = djeViews.getInstanceModel();
+ StatementBlock statementblock = null;
+ for (StatementBlock stb : instanceModel.getStatementBlocks()) {
+ if (stb.getName().equals(transition.getName())) {
+ statementblock = stb;
+ }
+ }
+ //reinitializes the marking and highlights the code fragment which are attached to statement block.
+ MarkingController.deleteMarkers(file);
+ MarkingController.highlightCode(statementblock);
+ //selects on the Instance view table, the Transitions elements which has a statement transition in common.
+ instancesView.selectInstanceObject(returnInstanceContent(statementblock));
+ }
+
+ //Jorge Gutierrez 11/08/2016
+ /**
+ * Returns the instances that contains the Statement block given
+ *
+ * Browses in all Instances Statement Blocks to find the Statements Blocks which have the same reference to
+ * Statement Block given.
+ * @param statementblock The Transition Statement Block selected by user.
+ * @return a list of Instance(TreeObject) to be selected by showSelected function
+ */
+ public ArrayList returnInstanceContent(StatementBlock
+ statementblock) {
+ ArrayList instanceList = new ArrayList();
+ for (Map.Entry iterator : instancesMap
+ .entrySet()) {
+ if (iterator.getValue() instanceof ProcessDeclarationInstance ){
+ EList listISB = (
+ (ProcessDeclarationInstance)iterator.getValue())
+ .getInstanceStatementBlocks();
+ int i = 0;
+ boolean b = true;
+ do {
+ if (listISB.size() != 0) {
+ for (InstanceStatementBlock isb : listISB) {
+ if (statementblock.getInstanceStatementBlocks()
+ .get(i) == isb) {
+ if (!instanceList.contains(iterator.getKey())) {
+ instanceList.add(iterator.getKey());
+ b = false;
+ }
+ }
+ }
+ }
+ i++;
+ } while (i < statementblock.getInstanceStatementBlocks().size()
+ && b);
+
+ }
+ }
+ return instanceList;
+ }
+
+ //Jorge Gutierrez 08/08/2016
+ /**
+ * Removes highlighted text from editor part.
+ */
+ public void deleteMarkers (){
+ try {
+ MarkingController.deleteMarkers(file);
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ }
+
+ //Jorge Gutierrez 08/08/2016
+ /**
+ * Deletes data and content from every view
+ *
+ * clearAllViews function is called by QuitSimulator class when the simulator
+ * is stopped by user.
+ */
+ public void clearAllViews (){
+ file = null;
+
+ instancesView.update(new TreeParent(""));
+
+ transitionExecutableMap.clear();
+ transitionsView.clearContent();
+
+ ValuesDataProvider.removeData();
+ valuesView.update();
+
+ actionStack.clear();
+ executedActionView.update(returnActions());
+
+ stateMap.clear();
+ activitiesStackMap.clear();
+ savedStatesView.update(returnSavedStates());
+ refresh();
+ }
+
+ //Jorge Gutierrez 12/08/2016 /////////////////TOCHANGE
+ /**
+ *
+ */
+ public void launchFeedBack() throws InvocationTargetException, InterruptedException {
+ }
+
+ //Jorge Gutierrez 16/08/2016
+ /**
+ * Makes an update to show the currents executed actions on ExecutedAction window (view part).
+ *
+ * Calls an update by giving a list of actions implemented during execution.
+ */
+ public void updateExecutedActionView() {
+ //updates current model.
+ djeViews = FiacreSimulator.sendDje();
+ //calls update by passing a list of Executed Action as parameter.
+ executedActionView.update(returnActions());
+ }
+
+ /**
+ * Creates and returns a list from the stack reserved for executed action.
+ * @return list of actions names.
+ */
+ private ArrayList returnActions() {
+ ArrayList list = new ArrayList();
+ for (ActionState t : actionStack) {
+ list.add(t.getAction());
+ }
+ Collections.reverse(list);
+ return list;
+ }
+
+ //Jorge Gutierrez 17/08/2016
+ /**
+ * Indicates if a executed action is a Delay
+ *
+ * Function used by ExecutedActionViews to know if a action searched by its name, is a delay or not
+ * @param obj the obj is the Action name given by ExecutedActionViews
+ * @return true
if this action state is a delay or false
, is not a delay or it does not exist.
+ */
+ public boolean isDelay (String obj){
+ for (ActionState t : actionStack ) {
+ if (t.getAction().equals(obj)) {
+ return t.getDelay();
+ }
+ }
+ return false;
+ }
+
+ //Jorge Gutierrez 17/08/2016
+ /**
+ * Undoes the last executed action
+ *
+ * Takes the last element from the actionStack and undoes the action in the simulated model,
+ * then makes a Feedback about all views (updateAll).
+ */
+ public void undoAction() {
+ try {
+ ActionState undo_action = actionStack.pop();
+ FiacreSimulator.getLibTTS().getTTSSimulator().undo();
+ updateAll();
+ if(undo_action.getAction().contains(" ")){
+ String tr_name= undo_action.getAction().substring(0, undo_action.getAction().indexOf(" "));
+ if(!tr_name.contentEquals("DELAY:")){
+ if(djeViews.gettr_gl_tr_ins().get(tr_name).size() == 1){
+ djeViews.getMSCModel().getSteps().remove(djeViews.getMSCModel().getSteps().size()-1);
+
+ }
+ else{
+ djeViews.getMSCModel().getSteps().remove(djeViews.getMSCModel().getSteps().size()-1);
+ djeViews.getMSCModel().getSteps().remove(djeViews.getMSCModel().getSteps().size()-1);
+ }
+ djeViews.saveMscResource();
+ }
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ }
+
+ /**
+ * Refreshes every view and reinitialize selections, values and markings.
+ */
+ private void updateAll() {
+ //djeViews.extractExecutedStatements(libtts.getTTSSimulator().getAllTransitions().get(tr_long).name);
+ djeViews.extractStates();
+ djeViews.extractExecutableStatements();
+ djeViews.extractValues();
+ //updates all views
+ updateInstanceView();
+ updateTransitionView();
+ updateExecutedActionView();
+ reinitializeValuesView();
+ MarkingController.deleteMarkers(file);
+ djeViews.saveInstanceResource();
+ }
+
+ /**
+ * Refreshes Project Explorer Part to display the launched file.
+ */
+ private void refresh(){
+ for(IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()){
+ try {
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Selects on editor code the Instances declarations selected in the instances table by the user/
+ *
+ * Gets editor instance to use the Select Service, takes a TreeObject key to get a corresponding block Instance,
+ * then checks if the block Instance is the type of Declaration, Component or Composition, to select it in the code.
+ * @param obj the TreeObject is given by InstanceView to search the Instance form the model.
+ */
+ public void showInstanceSelected(TreeObject obj) {
+
+ IEditorPart part = page.getActiveEditor();
+ if (!(part instanceof AbstractTextEditor))
+ return;
+ ITextEditor editor = (ITextEditor)part;
+
+
+ BlockInstance bi = instancesMap.get(obj);
+ EObject element = null ;
+ if (bi instanceof DeclarationInstance){
+ if(((DeclarationInstance)bi).getInstance() != null){
+ element = ((DeclarationInstance)bi).getInstance();
+ LeafNode tr_source_cn = (LeafNode) NodeModelUtils.findNodesForFeature(element, FiacrePackage.eINSTANCE.getComponentInstance_Component()).get(0);
+ editor.selectAndReveal(tr_source_cn.getOffset(), tr_source_cn.getLength());
+ }
+ else{
+ if(bi instanceof ComponentDeclarationInstance)
+ {
+ element = ((ComponentDeclarationInstance)bi).getComponent();
+ LeafNode tr_source_cn = (LeafNode) NodeModelUtils.findNodesForFeature(element, FiacrePackage.eINSTANCE.getNamedElement_Name()).get(0);
+ editor.selectAndReveal(tr_source_cn.getOffset(), tr_source_cn.getLength());
+ }
+ else
+ element = ((ProcessDeclarationInstance)bi).getProcess();
+ LeafNode tr_source_cn = (LeafNode) NodeModelUtils.findNodesForFeature(element, FiacrePackage.eINSTANCE.getNamedElement_Name()).get(0);
+ editor.selectAndReveal(tr_source_cn.getOffset(), tr_source_cn.getLength());
+ }
+ }
+ else{
+ element = ((CompositionInstance)bi).getComposition();
+ ICompositeNode tr_source_cn = NodeModelUtils.findActualNodeFor(element);
+ for (INode i: tr_source_cn.getChildren()){
+ if(i instanceof LeafNode && i.getText().equals("par"))
+ editor.selectAndReveal(i.getOffset(), i.getLength());
+ }
+
+ }
+
+
+ }
+
+
+ /**
+ * Maps a Executed Model State with Tag key and maps its activities Stack associated with the same key
+ * @param tag The Tag is a character string given by the user.
+ */
+ public void addStateToMap(String tag) { ////////////////not enough necessary
+ stateMap.put(tag, FiacreSimulator.getLibTTS().getTTSSimulator().getState());
+ Stack tagActionStack = (Stack) actionStack.clone();
+// Stack tagActionStack=new Stack();
+// for (ActionState a : actionStack) {
+// tagActionStack.push(a);
+// }
+ StateStructure ss = new StateStructure();
+ ss.interfaceStack = tagActionStack;
+ ss.modelStack = (Stack) FiacreSimulator.getLibTTS().getTTSSimulator().getPrevious_states().clone();
+ activitiesStackMap.put(tag, ss);
+ updateSavedStatesView();
+ }
+
+ /**
+ * Makes an update to show the saved States on SavedStates window (view part).
+ *
+ * Calls an update by giving a list of saved states during execution.
+ */
+ public void updateSavedStatesView() {
+ //calls update by passing a list of SavedStates as parameter.
+ savedStatesView.update(returnSavedStates());
+ }
+
+ /**
+ * Takes each element from the state map and puts it in a list
+ * @return list of Tag character string contained by stateMap
+ */
+ private ArrayList returnSavedStates() {
+ ArrayList list = new ArrayList();
+ for (Map.Entry iterator : stateMap.entrySet()){
+ list.add(iterator.getKey());
+ }
+ return list;
+ }
+
+ /**
+ * Removes a saved state chosen by user on the SavedStateView and its activities stack associated.
+ * @param tag The state that will be removed from stateMap
+ */
+ public void deleteState(String tag) {
+ stateMap.remove(tag);
+ activitiesStackMap.remove(tag);
+ updateSavedStatesView();
+
+ }
+
+ /**
+ * Returns the simulation to saved state selected and updates all views.
+ * @param tag The state that will be updated in simulator
+ */
+ public void goToState(String tag) {
+ FiacreSimulator.getLibTTS().getTTSSimulator().setState(stateMap.get(tag));
+ actionStack = (Stack) activitiesStackMap.get(tag).interfaceStack.clone();
+ FiacreSimulator.getLibTTS().getTTSSimulator().setPrevious_states((Stack) activitiesStackMap.get(tag).modelStack.clone());
+ updateAll();
+ }
+
+ /**
+ * Display a temporary label attached to the Instance Flat name.
+ * @param obj The treeObject representative of the instance selected.
+ */
+ public String returnFlatName(TreeObject obj) {
+ BlockInstance bI = instancesMap.get(obj);
+ if (bI instanceof DeclarationInstance)
+ return ((DeclarationInstance) bI).getFlatname();
+ return "Composition";
+ }
+}
diff --git a/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/ActionState.java b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/ActionState.java
new file mode 100644
index 0000000..2d21904
--- /dev/null
+++ b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/ActionState.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the LGPL 3.0
+ * which accompanies this distribution, and is available at
+ * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ *
+ * Contributors:
+ * Faiez Zalila - initial API and implementation and/or initial documentation
+ * Jorge Enrique Gutierrez Zuluaga
+ *******************************************************************************/
+package com.irtsaintexupery.fiacre.simulator.perspective.model;
+
+public class ActionState {
+ String action;
+ Boolean delay;
+
+ public ActionState() {
+ super();
+ }
+
+ public ActionState(String action, Boolean delay) {
+ super();
+ this.action = action;
+ this.delay = delay;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public Boolean getDelay() {
+ return delay;
+ }
+
+ public void setDelay(Boolean delay) {
+ this.delay = delay;
+ }
+
+
+
+}
diff --git a/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/TreeObject.java b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/TreeObject.java
new file mode 100644
index 0000000..2bd61c0
--- /dev/null
+++ b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/TreeObject.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the LGPL 3.0
+ * which accompanies this distribution, and is available at
+ * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ *
+ * Contributors:
+ * Faiez Zalila - initial API and implementation and/or initial documentation
+ * Jorge Enrique Gutierrez Zuluaga
+ *******************************************************************************/
+package com.irtsaintexupery.fiacre.simulator.perspective.model;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+public class TreeObject implements IAdaptable {
+ private String name;
+ private TreeParent parent;
+
+ public TreeObject(String name) {
+ this.name = name;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setParent(TreeParent parent) {
+ this.parent = parent;
+ }
+ public TreeParent getParent() {
+ return parent;
+ }
+ public String toString() {
+ return getName();
+ }
+ public T getAdapter(Class key) {
+ return null;
+ }
+}
diff --git a/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/TreeParent.java b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/TreeParent.java
new file mode 100644
index 0000000..d68d0ed
--- /dev/null
+++ b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/TreeParent.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the LGPL 3.0
+ * which accompanies this distribution, and is available at
+ * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ *
+ * Contributors:
+ * Faiez Zalila - initial API and implementation and/or initial documentation
+ * Jorge Enrique Gutierrez Zuluaga
+ *******************************************************************************/
+package com.irtsaintexupery.fiacre.simulator.perspective.model;
+
+import java.util.ArrayList;
+
+public class TreeParent extends TreeObject {
+ private ArrayList children;
+ public TreeParent(String name) {
+ super(name);
+ children = new ArrayList();
+ }
+ public void addChild(TreeObject child) {
+ children.add(child);
+ child.setParent(this);
+ }
+ public void removeChild(TreeObject child) {
+ children.remove(child);
+ child.setParent(null);
+ }
+ public TreeObject [] getChildren() {
+ return (TreeObject [])children.toArray(new TreeObject[children.size()]);
+ }
+ public boolean hasChildren() {
+ return children.size()>0;
+ }
+}
diff --git a/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/ValuesData.java b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/ValuesData.java
new file mode 100644
index 0000000..2fa3295
--- /dev/null
+++ b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/ValuesData.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the LGPL 3.0
+ * which accompanies this distribution, and is available at
+ * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ *
+ * Contributors:
+ * Faiez Zalila - initial API and implementation and/or initial documentation
+ * Jorge Enrique Gutierrez Zuluaga
+ *******************************************************************************/
+package com.irtsaintexupery.fiacre.simulator.perspective.model;
+
+public class ValuesData {
+ private String name;
+ private String initial;
+ private String current;
+
+ public ValuesData(){
+ name = "";
+ initial = "";
+ current = "";
+ }
+
+ public ValuesData(String n, String i, String c){
+ name = n;
+ initial = i;
+ current = c;
+ }
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getInitial() {
+ return initial;
+ }
+ public void setInitial(String initial) {
+ this.initial = initial;
+ }
+ public String getCurrent() {
+ return current;
+ }
+ public void setCurrent(String current) {
+ this.current = current;
+ }
+}
diff --git a/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/ValuesDataProvider.java b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/ValuesDataProvider.java
new file mode 100644
index 0000000..8b027bb
--- /dev/null
+++ b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/model/ValuesDataProvider.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the LGPL 3.0
+ * which accompanies this distribution, and is available at
+ * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ *
+ * Contributors:
+ * Faiez Zalila - initial API and implementation and/or initial documentation
+ * Jorge Enrique Gutierrez Zuluaga
+ *******************************************************************************/
+package com.irtsaintexupery.fiacre.simulator.perspective.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum ValuesDataProvider {
+ INSTANCE;
+
+ ///faire atention avec la privacité
+
+ private static List data = new ArrayList();
+
+ ValuesDataProvider() {
+ }
+
+ public static void addValues(ValuesData values){
+ data.add(values);
+ }
+
+ public ValuesData getValues(Integer index){
+ return data.get(index);
+ }
+
+ public List getData(){
+ return data;
+ }
+
+ public static void removeData(){
+ data.clear();
+ }
+
+
+}
diff --git a/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/ExecutedActionView.java b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/ExecutedActionView.java
new file mode 100644
index 0000000..f131b30
--- /dev/null
+++ b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/ExecutedActionView.java
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the LGPL 3.0
+ * which accompanies this distribution, and is available at
+ * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ *
+ * Contributors:
+ * Faiez Zalila - initial API and implementation and/or initial documentation
+ * Jorge Enrique Gutierrez Zuluaga
+ *******************************************************************************/
+package com.irtsaintexupery.fiacre.simulator.perspective.views;
+
+import java.util.ArrayList;
+import java.util.Vector;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import com.irtsaintexupery.fiacre.simulator.perspective.ViewsController;
+
+public class ExecutedActionView extends ViewPart {
+
+ public static final String ID = "com.irtsaintexupery.fiacre.simulator"
+ + ".perspective.executedActionView";
+
+ private TableViewer viewer;
+ private Action undo;
+
+ private Vector elementsTable = new Vector ();
+
+ class ViewLabelProvider extends LabelProvider implements ITableLabelProvider {
+ public String getColumnText(Object obj, int index) {
+ return getText(obj);
+ }
+ public Image getColumnImage(Object obj, int index) {
+ return getImage(obj);
+ }
+ public Image getImage(Object obj) {
+ if (ViewsController.INSTANCE.isDelay(getText(obj))) {
+ Image im = getImage("icons/time_add.png");
+ return im;
+ }else {
+ return PlatformUI.getWorkbench().getSharedImages()
+ .getImage(ISharedImages.IMG_OBJS_TASK_TSK);
+ }
+
+ }
+ }
+ /**
+ * The constructor.
+ */
+ public ExecutedActionView() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void createPartControl(Composite parent) {
+ viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+
+ viewer.setContentProvider(ArrayContentProvider.getInstance());
+ //TODO add elements to the table
+ viewer.setInput(elementsTable);
+ viewer.setLabelProvider(new ViewLabelProvider());
+
+ // Create the help context id for the viewer's control
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(),
+ "ExecutedActionView.viewer");
+ getSite().setSelectionProvider(viewer);
+ makeActions();
+ contributeToActionBars();
+ undo.setEnabled(false);
+ undo.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
+ .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO_DISABLED));
+ }
+
+ private void contributeToActionBars() {
+ IActionBars bars = getViewSite().getActionBars();
+ fillLocalPullDown(bars.getMenuManager());
+ fillLocalToolBar(bars.getToolBarManager());
+ }
+
+ private void fillLocalPullDown(IMenuManager manager) {
+ manager.add(new Separator());
+ manager.add(undo);
+ }
+
+ private void fillLocalToolBar(IToolBarManager manager) {
+ manager.add(undo);
+ }
+
+ private void makeActions() {
+
+ undo = new Action() {
+ public void run() {
+ if (!elementsTable.isEmpty()) {
+ ViewsController.INSTANCE.undoAction();
+ }
+ }
+ };
+ undo.setText("Undo");
+ undo.setToolTipText("Undo");
+// ImageDescriptor imageDescriptorUndo = AbstractUIPlugin
+// .imageDescriptorFromPlugin( "com.irtsaintexupery.fiacre"
+// + ".simulator.perspective", "/icons/arrow_undo.png" );
+
+ undo.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
+ .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO));
+//
+// redo = new Action() {
+// public void run() {
+// showMessage("Redo executed");
+// }
+// };
+// redo.setText("Redo");
+// redo.setToolTipText("Redo tooltip");
+// ImageDescriptor imageDescriptorRedo = AbstractUIPlugin
+// .imageDescriptorFromPlugin( "com.irtsaintexupery.fiacre"
+// + ".simulator.perspective", "/icons/arrow_redo.png" );
+// redo.setImageDescriptor(imageDescriptorRedo);
+ }
+
+ private void showMessage(String message) {
+ MessageDialog.openInformation(
+ viewer.getControl().getShell(),
+ "Executed Action View",
+ message);
+ }
+
+ @Override
+ public void setFocus() {
+ viewer.getControl().setFocus();
+
+ }
+
+ public void update(ArrayList list) {
+ elementsTable.clear();
+ for (String s : list) {
+ elementsTable.add(s);
+ }
+ if (elementsTable.isEmpty()) {
+ undo.setEnabled(false);
+ undo.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
+ .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO_DISABLED));
+ }else{
+ undo.setEnabled(true);
+ undo.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
+ .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO));
+ }
+ viewer.setContentProvider(ArrayContentProvider.getInstance());
+ viewer.setInput(elementsTable);
+ viewer.setLabelProvider(new ViewLabelProvider());
+ }
+
+}
diff --git a/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/InstancesView.java b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/InstancesView.java
new file mode 100644
index 0000000..ca8e6e7
--- /dev/null
+++ b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/InstancesView.java
@@ -0,0 +1,264 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the LGPL 3.0
+ * which accompanies this distribution, and is available at
+ * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ *
+ * Contributors:
+ * Faiez Zalila - initial API and implementation and/or initial documentation
+ * Jorge Enrique Gutierrez Zuluaga
+ *******************************************************************************/
+package com.irtsaintexupery.fiacre.simulator.perspective.views;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.*;
+
+import com.irtsaintexupery.fiacre.simulator.perspective.model.TreeObject;
+import com.irtsaintexupery.fiacre.simulator.perspective.model.TreeParent;
+import com.irtsaintexupery.fiacre.simulator.perspective.ViewsController;
+
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.graphics.Image;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.*;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.SWT;
+
+public class InstancesView extends ViewPart {
+
+ /**
+ * The ID of the view as specified by the extension.
+ */
+ public static final String ID = "com.irtsaintexupery.fiacre.simulator"
+ + ".perspective.instancesView";
+
+ private TreeViewer viewer;
+ private DrillDownAdapter drillDownAdapter;
+ private Action doubleClickAction;
+ private Action oneClickAction;
+ private TreeObject instanceTree;
+
+
+
+ class ViewContentProvider implements ITreeContentProvider {
+ @Override
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+ private TreeParent invisibleRoot;
+
+ public Object[] getElements(Object parent) {
+ if (parent.equals(getViewSite())) {
+ if (invisibleRoot==null) initialize();
+ return getChildren(invisibleRoot);
+ }
+ return getChildren(parent);
+ }
+ public Object getParent(Object child) {
+ if (child instanceof TreeObject) {
+ return ((TreeObject)child).getParent();
+ }
+ return null;
+ }
+ public Object [] getChildren(Object parent) {
+ if (parent instanceof TreeParent) {
+ return ((TreeParent)parent).getChildren();
+ }
+ return new Object[0];
+ }
+ public boolean hasChildren(Object parent) {
+ if (parent instanceof TreeParent)
+ return ((TreeParent)parent).hasChildren();
+ return false;
+ }
+
+ public void initialize() {
+ invisibleRoot = (TreeParent) instanceTree;
+ }
+
+
+ }
+
+ class ViewLabelProvider extends ColumnLabelProvider {
+ @Override
+ public String getText(Object obj) {
+ return obj.toString();
+
+ }
+ @Override
+ public Image getImage(Object obj) {
+ String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
+ if (obj instanceof TreeParent)
+ if (((TreeParent) obj).getName().equals("")) {
+ imageKey = ISharedImages.IMG_TOOL_UP_DISABLED;
+ }else {
+ imageKey = ISharedImages.IMG_TOOL_UP;
+ }
+ return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
+ }
+
+ @Override
+ public String getToolTipText(Object obj) {
+ return ViewsController.INSTANCE.returnFlatName((TreeObject) obj);
+ }
+
+ @Override
+ public int getToolTipDisplayDelayTime(Object object) {
+ return 0;
+ }
+
+ @Override
+ public int getToolTipTimeDisplayed(Object object) {
+ return 5000;
+ }
+
+
+ }
+
+/**
+ * The constructor.
+ */
+ public InstancesView() {
+ }
+
+ /**
+ * This is a callback that will allow us
+ * to create the viewer and initialize it.
+ */
+ public void createPartControl(Composite parent) {
+
+ //create the content
+ viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ drillDownAdapter = new DrillDownAdapter(viewer);
+
+ viewer.setContentProvider(new ViewContentProvider());
+
+ ColumnViewerToolTipSupport.enableFor(viewer);
+
+ viewer.setInput(getViewSite());
+ viewer.setLabelProvider(new ViewLabelProvider());
+
+ viewer.expandAll();
+
+ // Create the help context id for the viewer's control
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(),
+ "viewDemo2.viewer");
+ getSite().setSelectionProvider(viewer);
+ makeActions();
+ hookContextMenu();
+ hookDoubleClickAction();
+ hookOneClickAction();
+ contributeToActionBars();
+ }
+
+ private void hookContextMenu() {
+ MenuManager menuMgr = new MenuManager("#PopupMenu");
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ }
+ });
+ Menu menu = menuMgr.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, viewer);
+ }
+
+ private void contributeToActionBars() {
+ IActionBars bars = getViewSite().getActionBars();
+ }
+
+ private void makeActions() {
+
+ doubleClickAction = new Action() {
+ public void run() {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ //showMessage("Double-click detected on "+obj.toString());
+ if (!selection.isEmpty()) {
+ ViewsController.INSTANCE.showInstanceSelected((TreeObject)obj);
+ }
+ }
+ };
+
+ oneClickAction = new Action() {
+ public void run() {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ if (selection != null & selection instanceof IStructuredSelection
+ && obj != null) {
+ ViewsController.INSTANCE.showValuesView((TreeObject)obj);
+ }
+ }
+ };
+ }
+
+ private void hookDoubleClickAction() {
+ viewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ doubleClickAction.run();
+ }
+ });
+ }
+
+ private void hookOneClickAction() {
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ oneClickAction.run();
+ }
+ });
+ }
+
+ private void showMessage(String message) {
+ MessageDialog.openInformation(
+ viewer.getControl().getShell(),
+ "Instances View",
+ message);
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
+
+
+ public void update(TreeObject rood) {
+ instanceTree = rood;
+ viewer.setContentProvider(new ViewContentProvider());
+ viewer.setInput(getViewSite());
+ viewer.setLabelProvider(new ViewLabelProvider());
+
+ viewer.expandAll();
+ }
+
+ public void selectInstanceObject(TreeObject obj) {
+ viewer.setSelection(new StructuredSelection(obj), true);
+ }
+
+ public void selectInstanceObject(ArrayList instanceList) {
+
+ TreeObject[] array = new TreeObject[instanceList.size()];
+ for (int i = 0; i < instanceList.size(); i++) {
+ array[i] = instanceList.get(i);
+ }
+ viewer.setSelection(new StructuredSelection(array), true);
+ }
+
+
+}
+
diff --git a/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/SavedStatesView.java b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/SavedStatesView.java
new file mode 100644
index 0000000..e6eac5e
--- /dev/null
+++ b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/SavedStatesView.java
@@ -0,0 +1,286 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the LGPL 3.0
+ * which accompanies this distribution, and is available at
+ * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ *
+ * Contributors:
+ * Faiez Zalila - initial API and implementation and/or initial documentation
+ * Jorge Enrique Gutierrez Zuluaga
+ *******************************************************************************/
+package com.irtsaintexupery.fiacre.simulator.perspective.views;
+
+import java.util.ArrayList;
+import java.util.Vector;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Dialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import com.irtsaintexupery.fiacre.simulator.perspective.ViewsController;
+import com.irtsaintexupery.fiacre.simulator.perspective.views.ExecutedActionView.ViewLabelProvider;
+
+public class SavedStatesView extends ViewPart {
+
+ public static final String ID = "com.irtsaintexupery.fiacre.simulator"
+ + ".perspective.SavedStatesView";
+
+ private TableViewer viewer;
+ private Action save;
+ private Action goTo;
+ private Action delete;
+
+ private Vector elementsTable = new Vector ();
+
+ class ViewLabelProvider extends LabelProvider implements ITableLabelProvider {
+ public String getColumnText(Object obj, int index) {
+ return getText(obj);
+ }
+ public Image getColumnImage(Object obj, int index) {
+ return getImage(obj);
+ }
+ public Image getImage(Object obj) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages
+ .IMG_OPEN_MARKER);
+
+ }
+ }
+ /**
+ * The constructor.
+ */
+ public SavedStatesView() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void createPartControl(Composite parent) {
+ viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+
+ viewer.setContentProvider(ArrayContentProvider.getInstance());
+ //TODO add elements to the table
+ viewer.setInput(elementsTable);
+ viewer.setLabelProvider(new ViewLabelProvider());
+
+ // Create the help context id for the viewer's control
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(),
+ "ExecutedActionView.viewer");
+ getSite().setSelectionProvider(viewer);
+ makeActions();
+ contributeToActionBars();
+ save.setEnabled(false);
+ goTo.setEnabled(false);
+ delete.setEnabled(false);
+
+ }
+
+ private void contributeToActionBars() {
+ IActionBars bars = getViewSite().getActionBars();
+ fillLocalPullDown(bars.getMenuManager());
+ fillLocalToolBar(bars.getToolBarManager());
+ }
+
+ private void fillLocalPullDown(IMenuManager manager) {
+ manager.add(new Separator());
+ manager.add(save);
+ manager.add(new Separator());
+ manager.add(goTo);
+ manager.add(new Separator());
+ manager.add(delete);
+
+ }
+
+ private void fillLocalToolBar(IToolBarManager manager) {
+ manager.add(save);
+ manager.add(goTo);
+ manager.add(delete);
+ }
+
+ private void makeActions() {
+
+ save = new Action() {
+ public void run() {
+ SaveStateDialog dialog = new SaveStateDialog(viewer.getControl().getShell());
+ dialog.create();
+ if (dialog.open() == Window.OK) {
+ elementsTable.add(dialog.getTag());
+ ViewsController.INSTANCE.addStateToMap(dialog.getTag());
+ }
+ }
+ };
+ save.setText("Save");
+ save.setToolTipText("Save");
+ ImageDescriptor imageDescriptorSave = AbstractUIPlugin
+ .imageDescriptorFromPlugin( "com.irtsaintexupery.fiacre"
+ + ".simulator", "/icons/brick_add.png" );
+ save.setImageDescriptor(imageDescriptorSave);
+
+ goTo = new Action() {
+ public void run() {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ if (!selection.isEmpty()) {
+ if (selection != null && selection instanceof IStructuredSelection) {
+ ViewsController.INSTANCE.goToState(obj.toString());
+ }
+ }
+ }
+ };
+ goTo.setText("GoTo");
+ goTo.setToolTipText("GoTo");
+ ImageDescriptor imageDescriptorGoTo = AbstractUIPlugin
+ .imageDescriptorFromPlugin( "com.irtsaintexupery.fiacre"
+ + ".simulator", "/icons/brick_go.png" );
+ goTo.setImageDescriptor(imageDescriptorGoTo);
+
+ delete = new Action() {
+ public void run() {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ if (!selection.isEmpty()) {
+ if (selection != null && selection instanceof IStructuredSelection) {
+ ViewsController.INSTANCE.deleteState(obj.toString());
+ }
+ }
+ }
+ };
+ delete.setText("Delete");
+ delete.setToolTipText("Delete");
+ ImageDescriptor imageDescriptorDelete = AbstractUIPlugin
+ .imageDescriptorFromPlugin( "com.irtsaintexupery.fiacre"
+ + ".simulator", "/icons/brick_delete.png" );
+ delete.setImageDescriptor(imageDescriptorDelete);
+
+ }
+
+ private void showMessage(String message) {
+ MessageDialog.openInformation(
+ viewer.getControl().getShell(),
+ "Executed Action View",
+ message);
+ }
+
+ @Override
+ public void setFocus() {
+ viewer.getControl().setFocus();
+
+ }
+
+
+ public class SaveStateDialog extends TitleAreaDialog {
+ private Text tagLabel;
+ private String tag;
+
+ public SaveStateDialog(Shell parentShell) {
+ super(parentShell);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void create() {
+ super.create();
+ setTitle("Save state");
+ setMessage("write a identifier Tag to current state", IMessageProvider.INFORMATION);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite area = (Composite) super.createDialogArea(parent);
+ Composite container = new Composite(area, SWT.NONE);
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ GridLayout layout = new GridLayout(2, false);
+ container.setLayout(layout);
+
+ createTagLabel(container);
+
+ return area;
+ }
+
+ private void createTagLabel(Composite container) {
+ Label lbtFirstName = new Label(container, SWT.NONE);
+ lbtFirstName.setText("State Tag");
+
+ GridData dataFirstName = new GridData();
+ dataFirstName.grabExcessHorizontalSpace = true;
+ dataFirstName.horizontalAlignment = GridData.FILL;
+
+ tagLabel = new Text(container, SWT.BORDER);
+ tagLabel.setLayoutData(dataFirstName);
+ }
+
+
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ // save content of the Text fields because they get disposed
+ // as soon as the Dialog closes
+ private void saveInput() {
+ tag = tagLabel.getText();
+
+ }
+
+ @Override
+ protected void okPressed() {
+ saveInput();
+ super.okPressed();
+ }
+
+ public String getTag() {
+ return tag;
+ }
+ }
+
+ public void update(ArrayList list) {
+ elementsTable.clear();
+ for (String s : list) {
+ elementsTable.add(s);
+ }
+ if(ViewsController.INSTANCE.getFile() != null){
+ save.setEnabled(true);
+ goTo.setEnabled(true);
+ delete.setEnabled(true);
+ }else {
+ save.setEnabled(false);
+ goTo.setEnabled(false);
+ delete.setEnabled(false);
+ }
+ viewer.setContentProvider(ArrayContentProvider.getInstance());
+ viewer.setInput(elementsTable);
+ viewer.setLabelProvider(new ViewLabelProvider());
+ }
+
+}
\ No newline at end of file
diff --git a/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/TransitionsView.java b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/TransitionsView.java
new file mode 100644
index 0000000..b8fc099
--- /dev/null
+++ b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/TransitionsView.java
@@ -0,0 +1,260 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the LGPL 3.0
+ * which accompanies this distribution, and is available at
+ * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ *
+ * Contributors:
+ * Faiez Zalila - initial API and implementation and/or initial documentation
+ * Jorge Enrique Gutierrez Zuluaga
+ *******************************************************************************/
+package com.irtsaintexupery.fiacre.simulator.perspective.views;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.part.*;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.graphics.Image;
+
+import java.util.ArrayList;
+import java.util.Vector;
+
+import org.apache.thrift.TException;
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.*;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import com.irtsaintexupery.fiacre.simulator.core.DelayEvent;
+import com.irtsaintexupery.fiacre.simulator.core.FiacreSimulator;
+import com.irtsaintexupery.fiacre.simulator.core.ReadDelay;
+import com.irtsaintexupery.fiacre.simulator.core.Utils;
+import com.irtsaintexupery.fiacre.simulator.perspective.ViewsController;
+import com.irtsaintexupery.fiacre.simulator.staticjson.extractor.DynamicJsonExtractor;
+
+import fr.laas.libtts.LibTTS;
+import tts.Error;
+import tts.InvalidDelay;
+import tts.StateNotFound;
+
+
+
+public class TransitionsView extends ViewPart {
+
+ public static final String ID = "com.irtsaintexupery.fiacre.simulator"
+ + ".perspective.transitionsView";
+
+ private TableViewer viewer;
+ private Action doubleClickAction;
+ private Action oneClickAction;
+ private Action delay;
+
+ private Vector elementsTable = new Vector ();
+
+ class ViewLabelProvider extends LabelProvider implements ITableLabelProvider {
+ public String getColumnText(Object obj, int index) {
+ return getText(obj);
+ }
+ public Image getColumnImage(Object obj, int index) {
+ return getImage(obj);
+ }
+ public Image getImage(Object obj) {
+ if (ViewsController.INSTANCE.isFireable(getText(obj))) {
+ return PlatformUI.getWorkbench().getSharedImages()
+ .getImage(ISharedImages.IMG_OBJ_ADD);
+ }else {
+ return PlatformUI.getWorkbench().getSharedImages()
+ .getImage(ISharedImages.IMG_ELCL_STOP);
+ }
+ }
+ }
+ /**
+ * The constructor.
+ */
+ public TransitionsView() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void createPartControl(Composite parent) {
+ viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+
+ viewer.setContentProvider(ArrayContentProvider.getInstance());
+ //TODO add elements to the table
+ viewer.setInput(elementsTable);
+ viewer.setLabelProvider(new ViewLabelProvider());
+
+ // Create the help context id for the viewer's control
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(),
+ "TransitionView.viewer");
+ getSite().setSelectionProvider(viewer);
+ makeActions();
+ hookDoubleClickAction();
+ hookOneClickAction();
+ contributeToActionBars();
+ delay.setEnabled(false);
+
+ }
+
+ private void contributeToActionBars() {
+ IActionBars bars = getViewSite().getActionBars();
+ fillLocalPullDown(bars.getMenuManager());
+ fillLocalToolBar(bars.getToolBarManager());
+ }
+
+ private void fillLocalPullDown(IMenuManager manager) {
+ manager.add(new Separator());
+ manager.add(delay);
+ }
+
+ private void fillLocalToolBar(IToolBarManager manager) {
+ manager.add(delay);
+ }
+
+
+ private void makeActions() {
+
+ doubleClickAction = new Action() {
+ public void run() {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ //showMessage("Double-click fire on "+obj.toString());
+ if (!selection.isEmpty()) {
+ if (selection != null && selection instanceof IStructuredSelection
+ && ViewsController.INSTANCE.isFireable(obj.toString())
+ ) {
+ ViewsController.INSTANCE.fireTransition(obj.toString());
+ }
+ }
+ }
+ };
+
+ oneClickAction = new Action() {
+ public void run() {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ if (selection != null & selection instanceof IStructuredSelection
+ && obj != null) {
+ ViewsController.INSTANCE.showSelectedTransition(obj
+ .toString());
+ }
+ }
+ };
+
+ delay = new Action() {
+ public void run() {
+ ///////////////DELAY
+ delay();
+ }
+ };
+ delay.setText("delay");
+ delay.setToolTipText("Delay");
+ ImageDescriptor imageDescriptordelay = AbstractUIPlugin
+ .imageDescriptorFromPlugin( "com.irtsaintexupery.fiacre"
+ + ".simulator", "/icons/time_add.png" );
+
+ delay.setImageDescriptor(imageDescriptordelay);
+ }
+
+ private void hookDoubleClickAction() {
+ viewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ doubleClickAction.run();
+ }
+ });
+ }
+
+ private void hookOneClickAction() {
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ oneClickAction.run();
+ }
+ });
+ }
+
+ private void showMessage(String message) {
+ MessageDialog.openInformation(
+ viewer.getControl().getShell(),
+ "Transition View",
+ message);
+ }
+
+ @Override
+ public void setFocus() {
+ viewer.getControl().setFocus();
+
+ }
+
+ public void update(ArrayList list) {
+ delay.setEnabled(true);
+ elementsTable.clear();
+ for (String s : list) {
+ elementsTable.add(s);
+ }
+ viewer.setContentProvider(ArrayContentProvider.getInstance());
+ viewer.setInput(elementsTable);
+ viewer.setLabelProvider(new ViewLabelProvider());
+ }
+
+ public void clearContent() {
+ elementsTable.clear();
+ delay.setEnabled(false);
+ viewer.setContentProvider(ArrayContentProvider.getInstance());
+ viewer.setInput(elementsTable);
+ viewer.setLabelProvider(new ViewLabelProvider());
+ }
+
+ //Jorge Gutierrez 22/08/2016
+ public void delay(){
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().getActivePart().getSite().getShell();
+ ReadDelay dialog = new ReadDelay(shell);
+ dialog.create();
+ if (dialog.open() == Window.OK) {
+ dialog.getValue();
+ LibTTS libtts = FiacreSimulator.getLibTTS();
+ DynamicJsonExtractor dje = FiacreSimulator.sendDje();
+ try {
+ libtts.getTTSSimulator().delay(dialog.getValue());
+ dje.extractExecutableStatements();
+
+
+ //Jorge Gutierrez 03/08/2016
+ ViewsController.INSTANCE.updateTransitionView();
+ ViewsController.INSTANCE.addDelayToAction(dialog.getValue());
+ ViewsController.INSTANCE.updateExecutedActionView();
+
+ dje.saveInstanceResource();
+ } catch (Error e) {
+ // TODO Auto-generated catch block
+ Utils.showException("Error",e);
+ //e.printStackTrace();
+ } catch (StateNotFound e) {
+ // TODO Auto-generated catch block
+ Utils.showException("StateNotFound",e);
+ //e.printStackTrace();
+ } catch (InvalidDelay e) {
+ // TODO Auto-generated catch block
+ Utils.showException("InvalidDelay",e);
+ //e.printStackTrace();
+ } catch (TException e) {
+ // TODO Auto-generated catch block
+ Utils.showException("TException",e);
+ //e.printStackTrace();
+ } catch (NumberFormatException e) {
+ // TODO Auto-generated catch block
+ Utils.showException("NumberFormatException: "+dialog.getValue()+" is not numeric value",e);
+ //e.printStackTrace();
+ }
+ }
+ }
+}
+
diff --git a/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/ValuesView.java b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/ValuesView.java
new file mode 100644
index 0000000..6826e14
--- /dev/null
+++ b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/perspective/views/ValuesView.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the LGPL 3.0
+ * which accompanies this distribution, and is available at
+ * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ *
+ * Contributors:
+ * Faiez Zalila - initial API and implementation and/or initial documentation
+ * Jorge Enrique Gutierrez Zuluaga
+ *******************************************************************************/
+package com.irtsaintexupery.fiacre.simulator.perspective.views;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.part.*;
+
+import com.irtsaintexupery.fiacre.simulator.perspective.model.ValuesData;
+import com.irtsaintexupery.fiacre.simulator.perspective.model.ValuesDataProvider;
+
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.*;
+import org.eclipse.ui.*;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.SWT;
+
+
+public class ValuesView extends ViewPart {
+ public static final String ID = "com.irtsaintexupery.fiacre.simulator"
+ + ".perspective.valuesView";
+
+ private TableViewer viewer;
+ private Action doubleClickAction;
+
+
+
+ class ViewLabelProvider extends LabelProvider implements ITableLabelProvider {
+ public String getColumnText(Object obj, int index) {
+ return getText(obj);
+ }
+ public Image getColumnImage(Object obj, int index) {
+ return getImage(obj);
+ }
+ public Image getImage(Object obj) {
+ return PlatformUI.getWorkbench().getSharedImages()
+ .getImage(ISharedImages.IMG_OBJ_ELEMENT);
+ }
+ }
+ /**
+ * The constructor.
+ */
+ public ValuesView() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void createPartControl(Composite parent) {
+ viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL
+ | SWT.FULL_SELECTION | SWT.BORDER);
+ createTable(parent);
+ final Table table = viewer.getTable();
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ viewer.setContentProvider(new ArrayContentProvider());
+ // get the content for the viewer, setInput will call getElements in the
+ // contentProvider
+ viewer.setInput(ValuesDataProvider.INSTANCE.getData());
+ // make the selection available to other views
+ getSite().setSelectionProvider(viewer);
+ // set the sorter for the table
+
+ // define layout for the viewer
+ GridData gridData = new GridData();
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.horizontalSpan = 2;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ viewer.getControl().setLayoutData(gridData);
+
+ }
+
+ @Override
+ public void setFocus() {
+ viewer.getControl().setFocus();
+
+ }
+
+ private void createTable(Composite parent){
+ String[] titles = { "Name", "Current Value" };
+ int[] bounds = { 100, 100 };
+
+ // Name
+ TableViewerColumn col = createTableViewerColumn(titles[0], bounds[0], 0);
+ col.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ ValuesData e = (ValuesData)element;
+ return e.getName();
+ }
+ });
+
+ // Current Value
+ col = createTableViewerColumn(titles[1], bounds[1], 1);
+ col.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ ValuesData e = (ValuesData)element;
+ return ""+e.getCurrent();
+ }
+ });
+
+ }
+
+ private TableViewerColumn createTableViewerColumn(String title, int bound,
+ final int colNumber) {
+ final TableViewerColumn viewerColumn = new TableViewerColumn(viewer,
+ SWT.NONE);
+ final TableColumn column = viewerColumn.getColumn();
+ column.setText(title);
+ column.setWidth(bound);
+ column.setResizable(true);
+ column.setMoveable(true);
+ return viewerColumn;
+ }
+
+ public void update() {
+ viewer.setInput(ValuesDataProvider.INSTANCE.getData());
+ }
+
+}
diff --git a/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/popup/actions/FiacreSimulationAction.java b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/popup/actions/FiacreSimulationAction.java
new file mode 100644
index 0000000..f3a5518
--- /dev/null
+++ b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/popup/actions/FiacreSimulationAction.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the LGPL 3.0
+ * which accompanies this distribution, and is available at
+ * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ *
+ * Contributors:
+ * Faiez Zalila - initial API and implementation and/or initial documentation
+ * Jorge Enrique Gutierrez Zuluaga
+ *******************************************************************************/
+package com.irtsaintexupery.fiacre.simulator.popup.actions;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+import com.irtsaintexupery.fiacre.simulator.core.FiacreSimulator;
+import com.irtsaintexupery.fiacre.simulator.perspective.ViewsController;
+
+
+public class FiacreSimulationAction implements IObjectActionDelegate {
+
+ private Shell shell;
+ // added selection attribute
+ private ISelection selection;
+
+ /**
+ * Constructor for Action1.
+ */
+ public FiacreSimulationAction() {
+ super();
+ //toto
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ shell = targetPart.getSite().getShell();
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ // charger le fichier .fcr
+
+ //Jorge Gutierrez 12/08/2016
+ try {
+ ViewsController.INSTANCE.launchFeedBack();
+ } catch (InvocationTargetException | InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ IFile file = getFile();
+
+ FiacreSimulator simfcr = new FiacreSimulator(file);
+
+ }
+
+ // added getFile() method
+ private IFile getFile() {
+ return (IFile) ((IStructuredSelection) selection).getFirstElement();
+ }
+
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ // Don't forget this line.
+ // It is the most important line.
+ this.selection = selection;
+ }
+
+
+}
diff --git a/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/popup/actions/old.txt b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/popup/actions/old.txt
new file mode 100644
index 0000000..01cb5ac
--- /dev/null
+++ b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/popup/actions/old.txt
@@ -0,0 +1,247 @@
+package com.irt.ingequip.fiacre.simulator.popup.actions;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.xtext.nodemodel.INode;
+import org.eclipse.xtext.resource.EObjectAtOffsetHelper;
+import org.eclipse.xtext.resource.XtextResource;
+import org.eclipse.xtext.ui.editor.IURIEditorOpener;
+import org.eclipse.xtext.ui.editor.XtextEditor;
+import org.eclipse.xtext.ui.editor.model.XtextDocument;
+import org.eclipse.xtext.ui.editor.utils.EditorUtils;
+import org.eclipse.xtext.ui.resource.XtextResourceSetProvider;
+//import org.xtext.example.mydsl.ui.internal.MyDslActivator;
+import org.eclipse.xtext.util.TextRegion;
+import org.eclipse.xtext.validation.AbstractDeclarativeValidator;
+import org.eclipse.xtext.validation.AbstractDeclarativeValidator.StateAccess;
+import org.eclipse.xtext.validation.ValidationMessageAcceptor;
+
+import com.google.inject.Injector;
+
+import fr.irit.fiacre.xtext.fiacre.BlockStatement;
+import fr.irit.fiacre.xtext.fiacre.CaseStatement;
+import fr.irit.fiacre.xtext.fiacre.ConditionalStatement;
+import fr.irit.fiacre.xtext.fiacre.ExtendedConditionalStatement;
+import fr.irit.fiacre.xtext.fiacre.ForeachStatement;
+import fr.irit.fiacre.xtext.fiacre.SelectStatement;
+import fr.irit.fiacre.xtext.fiacre.Statement;
+import fr.irit.fiacre.xtext.fiacre.StatementChoice;
+import fr.irit.fiacre.xtext.fiacre.StatementSequence;
+import fr.irit.fiacre.xtext.fiacre.UnlessStatement;
+import fr.irit.fiacre.xtext.fiacre.WhileStatement;
+import fr.irit.fiacre.xtext.ui.internal.FiacreActivator;
+import fr.irit.fiacre.xtext.validation.FiacreValidator;
+
+public class Simulate implements IObjectActionDelegate {
+
+ private Shell shell;
+ // added selection attribute
+ private ISelection selection;
+
+ /**
+ * Constructor for Action1.
+ */
+ public Simulate() {
+ super();
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ shell = targetPart.getSite().getShell();
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ IFile file = getFile();
+ Injector injector = FiacreActivator.getInstance().getInjector("fr.irit.fiacre.xtext.Fiacre");
+ XtextResourceSetProvider provider = injector.getInstance(XtextResourceSetProvider.class);
+ ResourceSet resourceSet = provider.get(file.getProject());
+
+ URI xtextURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
+
+ XtextResource xtextResource = (XtextResource) resourceSet.getResource(xtextURI, true);
+
+ System.out.println("resource" + xtextResource);
+
+ IURIEditorOpener editorOpener = injector.getInstance(IURIEditorOpener.class);
+ final XtextEditor xtextEditor = (XtextEditor) editorOpener.open(xtextURI, true);
+ System.out.println("editor 2" + xtextEditor);
+ XtextDocument xtextDocument = (XtextDocument) xtextEditor.getDocument();
+ System.out.println("document " + xtextDocument);
+ for (int i = 0; i < xtextDocument.getNumberOfLines(); i++) {
+ try {
+ System.out.println("getLineLength " + i + " " + xtextDocument.getLineLength(i));
+ System.out.println("getLineOffset " + i + " " + xtextDocument.getLineOffset(i));
+ } catch (BadLocationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ EObjectAtOffsetHelper eObjectAtOffsetHelper = injector.getInstance(EObjectAtOffsetHelper.class);
+ for (int i = 0; i < xtextDocument.getLength(); i++) {
+ try {
+ EObject object = eObjectAtOffsetHelper.resolveElementAt(xtextResource, i);
+ EObject object2 = eObjectAtOffsetHelper.resolveContainedElementAt(xtextResource, i);
+ EObject object3 = eObjectAtOffsetHelper.resolveCrossReferencedElementAt(xtextResource, i);
+ INode object4 = eObjectAtOffsetHelper.getCrossReferenceNode(xtextResource, new TextRegion(i, 1));
+
+ int line = xtextDocument.getLineOfOffset(i);
+ int column = (i - xtextDocument.getLineOffset(xtextDocument.getLineOfOffset(i)));
+
+ System.out.println("----- ");
+ System.out.print("o " + i);
+ System.out.print(" (l " + line + " ");
+ System.out.print("c " + column + ") ");
+ System.out.print("(el = " + (line + 1) + ", ");
+ System.out.print("ec = " + (column + 1) + ") ");
+ System.out.println("calculated offset " + getOffset(xtextDocument, line , column));
+ System.out.println("object " + object);
+ System.out.println("cross " + object3);
+ System.out.println("contained " + object2);
+ System.out.println("containerStatement " + getStatement(object2));
+ System.out.println("object4 " + object4);
+
+ } catch (BadLocationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ FiacreValidator validator = injector.getInstance(FiacreValidator.class);
+ System.out.println("validator " + validator);
+ System.out.println("getmsgacceptor " + validator.getMessageAcceptor() + this);
+
+// StateAccess access = new StateAccess((AbstractDeclarativeValidator) validator.getMessageAcceptor());
+// validator.getMessageAcceptor().acceptError("Assigning any value not allowed in a function ",eObjectAtOffsetHelper.resolveElementAt(xtextResource, 14773),null,ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null);
+// validator.state.get().hasErrors = true;
+ // try {
+ // BufferedReader bufferRead = new BufferedReader(new
+ // InputStreamReader(System.in));
+ // String s = bufferRead.readLine();
+ // int x = Integer.parseInt(s);
+ // String r = bufferRead.readLine();
+ // int y = Integer.parseInt(r);
+ //
+ // //EObjectAtOffsetHelper eObjectAtOffsetHelper = new
+ // EObjectAtOffsetHelper();
+ // EObject object3 =
+ // eObjectAtOffsetHelper.resolveElementAt(xtextResource,
+ // getOffset(xtextDocument, x, y));
+ // System.out.println("object3 " + object3);
+ // try {
+ // System.out.println("line of offset " +
+ // xtextDocument.getLineOfOffset(getOffset(xtextDocument, x, y)));
+ // } catch (BadLocationException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ //
+ //
+ // } catch (IOException e) {
+ // e.printStackTrace();
+ // }
+ }
+
+ // added getFile() method
+ private IFile getFile() {
+ return (IFile) ((IStructuredSelection) selection).getFirstElement();
+ }
+
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ // Don't forget this line.
+ // It is the most important line.
+ this.selection = selection;
+ }
+
+ public int getOffset(XtextDocument xtextDocument, int x, int y) {
+ int offset = 0;
+
+ for (int i = 0; i < x; i++) {
+ try {
+ offset += xtextDocument.getLineLength(i);
+ } catch (BadLocationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ offset += y;
+ System.out.println("offset" + offset);
+ return offset;
+
+ }
+
+ public EObject eContainer(EObject root, Class> type) {
+ EObject current = root;
+ while (current != null) {
+ if (type.isInstance(current)) {
+ return current;
+ } else {
+ current = current.eContainer();
+ }
+ }
+ return null;
+ }
+
+ public EObject eContainerStatement(EObject root) {
+ EObject current = root;
+ while (current != null) {
+ if (StatementSequence.class.isInstance(current.eContainer())) {
+ return current;
+ } else {
+ current = current.eContainer();
+ }
+ }
+ return null;
+ }
+
+ public EObject getStatement(EObject root) {
+ EObject current = root;
+ while (current != null) {
+ if (!(isAtomicStatement(current.eContainer()))) {
+ return current;
+ } else {
+ current = current.eContainer();
+ }
+ }
+ return null;
+ }
+
+ public boolean isAtomicStatement(EObject root) {
+ if (eContainer(root, Statement.class) != null) {
+ if (UnlessStatement.class.isInstance(root) || StatementChoice.class.isInstance(root)
+ || StatementSequence.class.isInstance(root) || ConditionalStatement.class.isInstance(root)
+ || ExtendedConditionalStatement.class.isInstance(root) || SelectStatement.class.isInstance(root)
+ || WhileStatement.class.isInstance(root) || ForeachStatement.class.isInstance(root)
+ || CaseStatement.class.isInstance(root) || BlockStatement.class.isInstance(root)
+ ) {
+ return false;
+ } else {
+ return true;
+ }
+
+ } else {
+ return false;
+ }
+
+ }
+
+}
diff --git a/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/staticjson/extractor/DynamicJsonExtractor.xtend b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/staticjson/extractor/DynamicJsonExtractor.xtend
new file mode 100644
index 0000000..3080fce
--- /dev/null
+++ b/eclipse/plugins/com.irtsaintexupery.fiacre.simulator/src/com/irtsaintexupery/fiacre/simulator/staticjson/extractor/DynamicJsonExtractor.xtend
@@ -0,0 +1,878 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the LGPL 3.0
+ * which accompanies this distribution, and is available at
+ * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ *
+ * Contributors:
+ * Faiez Zalila - initial API and implementation and/or initial documentation
+ * Jorge Enrique Gutierrez Zuluaga
+ *******************************************************************************/
+package com.irtsaintexupery.fiacre.simulator.staticjson.extractor
+
+import com.google.inject.Injector
+import com.irtsaintexupery.fiacre.instance.fiacreinstance.BlockInstance
+import com.irtsaintexupery.fiacre.instance.fiacreinstance.DeclarationInstance
+import com.irtsaintexupery.fiacre.instance.fiacreinstance.EnabledStatementBlock
+import com.irtsaintexupery.fiacre.instance.fiacreinstance.ExecutableStatementBlock
+import com.irtsaintexupery.fiacre.instance.fiacreinstance.ExecutedStatementBlock
+import com.irtsaintexupery.fiacre.instance.fiacreinstance.FireableStatementBlock
+import com.irtsaintexupery.fiacre.instance.fiacreinstance.InstanceEnabledStatementBlock
+import com.irtsaintexupery.fiacre.instance.fiacreinstance.InstanceExecutableStatementBlock
+import com.irtsaintexupery.fiacre.instance.fiacreinstance.InstanceExecutedStatementBlock
+import com.irtsaintexupery.fiacre.instance.fiacreinstance.InstanceFireableStatementBlock
+import com.irtsaintexupery.fiacre.instance.fiacreinstance.InstanceModel
+import com.irtsaintexupery.fiacre.instance.fiacreinstance.ProcessDeclarationInstance
+import com.irtsaintexupery.fiacre.instance.fiacreinstance.VariableDeclarationInstance
+import com.irtsaintexupery.fiacre.simulator.core.Utils
+import com.irtsaintexupery.fiacre.simulator.msc.msc.EnterStateStep
+import com.irtsaintexupery.fiacre.simulator.msc.msc.MSC
+import com.irtsaintexupery.fiacre.simulator.msc.msc.SendStep
+import com.irtsaintexupery.fiacre.simulator.msc.msc.Step
+import com.irtsaintexupery.fiacre.simulator.msc.msc.SynchronisationStep
+import fr.irit.fiacre.xtext.fiacre.ArrayExpression
+import fr.irit.fiacre.xtext.fiacre.ArrayType
+import fr.irit.fiacre.xtext.fiacre.BasicType
+import fr.irit.fiacre.xtext.fiacre.BlockStatement
+import fr.irit.fiacre.xtext.fiacre.CaseStatement
+import fr.irit.fiacre.xtext.fiacre.ConditionalStatement
+import fr.irit.fiacre.xtext.fiacre.ConstructionExpression
+import fr.irit.fiacre.xtext.fiacre.Expression
+import fr.irit.fiacre.xtext.fiacre.ExtendedConditionalStatement
+import fr.irit.fiacre.xtext.fiacre.FalseLiteral
+import fr.irit.fiacre.xtext.fiacre.FieldExpression
+import fr.irit.fiacre.xtext.fiacre.ForeachStatement
+import fr.irit.fiacre.xtext.fiacre.IdentifierExpression
+import fr.irit.fiacre.xtext.fiacre.IdentifierPattern
+import fr.irit.fiacre.xtext.fiacre.Model
+import fr.irit.fiacre.xtext.fiacre.NaturalLiteral
+import fr.irit.fiacre.xtext.fiacre.PortDeclaration
+import fr.irit.fiacre.xtext.fiacre.QueueExpression
+import fr.irit.fiacre.xtext.fiacre.QueueType
+import fr.irit.fiacre.xtext.fiacre.RangeType
+import fr.irit.fiacre.xtext.fiacre.ReceiveStatement
+import fr.irit.fiacre.xtext.fiacre.RecordExpression
+import fr.irit.fiacre.xtext.fiacre.RecordType
+import fr.irit.fiacre.xtext.fiacre.ReferencedType
+import fr.irit.fiacre.xtext.fiacre.SelectStatement
+import fr.irit.fiacre.xtext.fiacre.SendStatement
+import fr.irit.fiacre.xtext.fiacre.Statement
+import fr.irit.fiacre.xtext.fiacre.StatementChoice
+import fr.irit.fiacre.xtext.fiacre.StatementSequence
+import fr.irit.fiacre.xtext.fiacre.TransitionSource
+import fr.irit.fiacre.xtext.fiacre.TrueLiteral
+import fr.irit.fiacre.xtext.fiacre.Type
+import fr.irit.fiacre.xtext.fiacre.TypeDeclaration
+import fr.irit.fiacre.xtext.fiacre.UnionTagDeclaration
+import fr.irit.fiacre.xtext.fiacre.UnionType
+import fr.irit.fiacre.xtext.fiacre.UnlessStatement
+import fr.irit.fiacre.xtext.fiacre.ValueExpression
+import fr.irit.fiacre.xtext.fiacre.VariablesDeclaration
+import fr.irit.fiacre.xtext.fiacre.WhileStatement
+import fr.irit.fiacre.xtext.ui.internal.XtextActivator
+import fr.laas.libtts.TTSSimulator
+import java.util.ArrayList
+import java.util.HashMap
+import java.util.LinkedHashMap
+import java.util.Map
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.emf.ecore.resource.Resource
+import org.eclipse.jface.text.BadLocationException
+import org.eclipse.xtext.resource.EObjectAtOffsetHelper
+import org.eclipse.xtext.resource.XtextResource
+import org.eclipse.xtext.ui.editor.IURIEditorOpener
+import org.eclipse.xtext.ui.editor.XtextEditor
+import org.eclipse.xtext.ui.editor.model.XtextDocument
+import org.json.simple.JSONArray
+import org.json.simple.JSONAware
+import org.json.simple.JSONObject
+
+///Jorge Guiterrez 10/08/2016
+class DynamicJsonExtractor{
+ var XtextResource fiacreResource
+ var Resource instanceResource
+ var Resource mscResource
+ val TTSSimulator tTSSimulator
+ var HashMap mapping_blockinstance_jsonelement
+ var JSONObject fiacreStaticJson
+ val HashMap> tr_gl_tr_ins = new HashMap>();
+ val HashMap> tr_in_stmts = new HashMap>();
+
+ new(XtextResource _fiacreResource, Resource _instanceResource, TTSSimulator _TTSSimulator, JSONObject _fiacreStaticJson, HashMap _mapping, Resource _mscResource) {
+ fiacreResource = _fiacreResource
+ instanceResource = _instanceResource
+ tTSSimulator = _TTSSimulator
+ mapping_blockinstance_jsonelement = _mapping
+ fiacreStaticJson = _fiacreStaticJson
+ mscResource = _mscResource
+ extractTransitionsMappings
+ }
+ def mscFirstStepExtract(){
+ var Step step = Utils.createStep
+ MSCModel.steps.add(step)
+ for (pdi: instanceModel.eAllContents.toList.filter(ProcessDeclarationInstance)){
+ var EnterStateStep esst = Utils.createEnterStateStep
+ step.microSteps.add(esst)
+ esst.stateName = pdi.currentState.name
+ esst.site = MSCModel.sites.filter[site|site.name == pdi.flatname].get(0)
+ }
+ Utils.saveResource(mscResource)
+ }
+ def ArrayList getallInstanceTransitionsObjects() {
+ // Get all Instance transitions from the mapping between block instances and json object
+ val ArrayList allInstanceTransitions = new ArrayList()
+ for (element : ( mapping_blockinstance_jsonelement.filter[p1, p2|p1 instanceof ProcessDeclarationInstance].values.map[value|(value as JSONObject).get("transitions")])) {
+ for (jelement : element as JSONArray) {
+ allInstanceTransitions.add(jelement as JSONObject)
+ }
+ }
+ allInstanceTransitions
+ }
+
+ def extractTransitionsMappings() {
+ val Injector injector = XtextActivator.getInstance().getInjector("fr.irit.fiacre.xtext.Fiacre")
+ val IURIEditorOpener editorOpener = injector.getInstance(IURIEditorOpener)
+ val XtextEditor xtextEditor = editorOpener.open(fiacreResource.URI, true) as XtextEditor
+ val XtextDocument xtextDocument = xtextEditor.document as XtextDocument
+ val EObjectAtOffsetHelper eObjectAtOffsetHelper = injector.getInstance(EObjectAtOffsetHelper)
+ // The following code line is just to show what performed inside mappings
+ /*
+ * It exists two kinds of transitions
+ * Global transitions: which can be find in the json model root
+ * and Instance transitions which can be find in the process instances
+ * So from global transitions, we must find the instance transitions
+ * to obtain, after, the locations for each transition
+ */
+ // Get global transitions from the json model
+ val JSONArray global_transitions = fiacreStaticJson.get("gtransitions") as JSONArray
+
+// // Get all Instance transitions from the mapping between block instances and json object
+// val ArrayList allInstanceTransitions = new ArrayList()
+// for (element : ( mapping_blockinstance_jsonelement.filter[p1, p2|p1 instanceof ProcessDeclarationInstance].values.map[value|(value as JSONObject).get("transitions")])) {
+// for (jelement : element as JSONArray) {
+// allInstanceTransitions.add(jelement as JSONObject)
+// }
+// }
+ // for each global transition name (a_global_tr_name)
+ for (a_global_tr_name : global_transitions.map[agtr|(agtr as JSONObject).get("name")]) {
+
+ // Get the corresponding json object (a_g_tr_jobject) from the global transitions array list
+ val JSONObject a_g_tr_jobject = global_transitions.filter[gtr|(gtr as JSONObject).get("name") == a_global_tr_name].get(0) as JSONObject
+ // create an array list of instance transition of the current global transition
+ val ArrayList in_trs_of_gl = new ArrayList()
+
+ // for each instance transition name, found in the transitions array of the global transition object
+ for (a_i_tr_name : a_g_tr_jobject.get("transitions") as JSONArray) {
+ // add the instance name in the array list
+ in_trs_of_gl.add(a_i_tr_name as String)
+ // Get the instance transition object (a_i_tr_jobject)
+ val JSONObject a_i_tr_jobject = getallInstanceTransitionsObjects.filter[aatr|(aatr as JSONObject).get("name") == a_i_tr_name].get(0)
+
+ // Get the Process Declaration Instance that contains the instance transition object (a_i_tr_jobject)
+ // just to print it and verify
+ // val c_pdi = mapping_blockinstance_jsonelement.filter[p1, p2|p1 instanceof ProcessDeclarationInstance].filter[p1, p2|((p2 as JSONObject).get("transitions") as JSONArray).contains(a_i_tr_jobject)].keySet.get(0);
+ // Get locations of each instance transition
+ // statements_ins_tr allows to save an eobject (an atomic statement or a transition source)
+ // with its first position
+ // for example fr.irit.fiacre.xtext.fiacre.impl.TransitionSourceImpl@53c7c937 = 325 3
+ val LinkedHashMap statements_ins_tr = new LinkedHashMap()
+
+ // for each identified location in the locations table of an instance transition
+ for (a_location_jsonobject : (a_i_tr_jobject as JSONObject).get("locations") as JSONArray) {
+ // we find the from location
+ val JSONObject from_location = (a_location_jsonobject as JSONObject).get("from") as JSONObject
+ val long line_from = from_location.get("line") as Long
+ val long char_from = from_location.get("char") as Long
+ // we calculate the from offset
+ val int offset_from = xtextDocument.getOffset(line_from.intValue, char_from.intValue)
+
+ // we find the to location
+ val JSONObject to_location = (a_location_jsonobject as JSONObject).get("to") as JSONObject
+ val long line_to = to_location.get("line") as Long
+ val long char_to = to_location.get("char") as Long
+ // we calculate the to offset
+ val int offset_to = xtextDocument.getOffset(line_to.intValue, char_to.intValue)
+ // from to from offset to the to offset
+ for (var int i = offset_from; i <= offset_to; i++) {
+ // we calculate the line column position from the offset
+ val int line = xtextDocument.getLineOfOffset(i)
+ val int column = (i - xtextDocument.getLineOffset(xtextDocument.getLineOfOffset(i)))
+
+ // we find the corresponding statement
+ val statement = eObjectAtOffsetHelper.resolveContainedElementAt(fiacreResource, i).getStatement
+ // We insert the statements in the list with its line column location
+ /*
+ * We insert only transition source (from)
+ * or atomic statement
+ * In addition
+ */
+ if((statement instanceof TransitionSource)
+ //&& ! statements_ins_tr.keySet.contains(statement)
+ && statements_ins_tr.keySet.filter(TransitionSource).size == 0
+ )
+ statements_ins_tr.put(statement, (line + 1) + " " + (column + 1))
+
+ if(statement.isAtomicStatement)
+ // TODO Ă voir l'histoire des to statement et les loop
+// if(statement instanceof ToStatement){
+// if(statements_ins_tr.keySet.filter(ToStatement).size == 0)
+// statements_ins_tr.put(statement, (line + 1) + " " + (column + 1))
+// }
+// else
+ // if(! statements_ins_tr.keySet.contains(statement))
+ statements_ins_tr.put(statement, (line + 1) + " " + (column + 1))
+ }
+ }
+ tr_in_stmts.put(a_i_tr_name as String, statements_ins_tr)
+ }
+ // mapping global transition = instance transitions. en gros, c'est gtransitions de json dynamique
+ tr_gl_tr_ins.put(a_global_tr_name as String, in_trs_of_gl)
+ }
+ }
+
+ def extractValues() {
+ val HashMap variablesMappings = getVariablesMappings
+ for (element : Utils.getJsonObject(tTSSimulator.state.getValues).keySet) {
+ if(variablesMappings.filter[p1, p2|(p1 as JSONObject).get("flatname") == element].size > 0) {
+ val JSONObject jo = variablesMappings.filter[p1, p2|(p1 as JSONObject).get("flatname") == element].keySet.get(0)
+ val DeclarationInstance decl = variablesMappings.filter[p1, p2|(p1 as JSONObject).get("flatname") == element].values.get(0)
+ val Object value = Utils.getJsonObject(tTSSimulator.state.getValues).get(element)
+ val VariableDeclarationInstance vd_i = decl.variableDeclarationInstances.filter[vdi|vdi.variableDeclaration.name == jo.get("sourcename")].get(0)
+ val HashMap