]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Select which indexes of multidimensional variables are shown in the trend view
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 20 Jan 2011 14:37:23 +0000 (14:37 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 20 Jan 2011 14:37:23 +0000 (14:37 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@19440 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationIndexNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/Keys.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/ShowInChartsCheckBox.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/viewUtils/SysdynDatasetSelectionListener.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java

index af4921f503881bee15dd3b51a6ecfeea8a0dd677..68d404b58d754ab63a526904c59104cee9136cee 100644 (file)
             label="System Dynamics ontology dependencies">\r
       </feature>\r
    </extension>\r
+   <extension\r
+         point="org.simantics.browsing.ui.common.checkedStateBinding">\r
+      <binding\r
+            browseContext="http://www.simantics.org/Sysdyn-1.0/EnumerationIndexes">\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.properties.widgets.arrays.ShowInChartsCheckBox"\r
+               preference="2.0">\r
+         </implementation>\r
+      </binding>\r
+   </extension>\r
 </plugin>\r
index d006e9c265b8b6fb9b728770e8c9f9b4cea17919..8573747f87f928f29a56c1c587524d8c2b624362 100644 (file)
@@ -1,5 +1,7 @@
 package org.simantics.sysdyn.ui.properties;\r
 \r
+import java.util.List;\r
+\r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
 import org.eclipse.jface.viewers.ISelection;\r
@@ -10,8 +12,12 @@ import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;\r
 import org.eclipse.swt.widgets.Composite;\r
 import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
 import org.eclipse.swt.widgets.Tree;\r
+import org.eclipse.swt.widgets.TreeItem;\r
 import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.NodeContext;\r
 import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
 import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
 import org.simantics.browsing.ui.swt.widgets.Button;\r
@@ -21,6 +27,7 @@ import org.simantics.browsing.ui.swt.widgets.Table;
 import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
 import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.Builtins;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
@@ -30,9 +37,13 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.management.ISessionContext;\r
+import org.simantics.db.request.Read;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.SysdynModel;\r
+import org.simantics.sysdyn.manager.SysdynModelManager;\r
+import org.simantics.sysdyn.ui.properties.widgets.arrays.EnumerationIndexNode;\r
 import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNamePropertyModifier;\r
 import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNameValidator;\r
 import org.simantics.ui.SimanticsUI;\r
@@ -43,6 +54,8 @@ import org.simantics.utils.ui.ISelectionUtils;
 public class EnumerationTab extends PropertyTabContributorImpl {\r
 \r
        GraphExplorerComposite indexExplorer;\r
+       \r
+       Button showAll;\r
 \r
        \r
        Table table;\r
@@ -52,147 +65,72 @@ public class EnumerationTab extends PropertyTabContributorImpl {
 \r
                Composite container = new Composite(body, SWT.None);\r
                GridDataFactory.fillDefaults().grab(true, true).applyTo(container);\r
-               GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(container);\r
+               GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(container);\r
 \r
         TrackedText nameText = new TrackedText(container, support, SWT.BORDER);\r
         nameText.setTextFactory(new StringPropertyFactory(Builtins.URIs.HasName));\r
         nameText.addModifyListener(new VariableNamePropertyModifier(context, Builtins.URIs.HasName));\r
         nameText.setInputValidator(new VariableNameValidator(support));\r
-        GridDataFactory.fillDefaults().grab(true, false).span(2,1).applyTo(nameText.getWidget());\r
+        GridDataFactory.fillDefaults().grab(true, false).span(3,1).applyTo(nameText.getWidget());\r
 \r
 \r
         \r
         \r
         indexExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
-                               "displaySelectors", "displayFilter").values(false, false), site, container, support, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI);\r
+                               "displaySelectors", "displayFilter").values(false, false), site, container, support, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI | SWT.CHECK);\r
                \r
         indexExplorer\r
                .setBrowseContexts("http://www.simantics.org/Sysdyn-1.0/EnumerationIndexes");\r
         indexExplorer.setInputSource(new SingleSelectionInputSource(\r
                                Resource.class));\r
+        ((Tree)indexExplorer.getExplorerControl()).addListener(SWT.Selection, new Listener () {\r
+        \r
+            @Override\r
+            public void handleEvent (Event event) {\r
+                if(event.detail == SWT.CHECK) {\r
+                    final TreeItem item = (TreeItem)event.item;\r
+                    final boolean checked = item.getChecked();\r
+                    NodeContext context = (NodeContext)item.getData();\r
+                    final EnumerationIndexNode node = (EnumerationIndexNode) context.getAdapter(EnumerationIndexNode.class);\r
+                    node.setShowInChartsSelected(checked);\r
+                    \r
+                    SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
+                                               @Override\r
+                                               public void run(ReadGraph graph) throws DatabaseException {\r
+                                                       Layer0 l0 = Layer0.getInstance(graph);\r
+                                                       Resource enumeration = (Resource)indexExplorer.getExplorer().getRoot().getAdapter(Resource.class);\r
+                                                       Resource configuration = graph.getSingleObject(enumeration, l0.PartOf);\r
+                                                       SysdynModel model = SysdynModelManager.getInstance(graph.getSession()).getModel(graph, configuration);\r
+                                                       // update results in graphs\r
+                                                       model.resultChanged();\r
+                                               }\r
+                                       });\r
+                }\r
+            }\r
+        });\r
+        \r
 \r
         indexExplorer.finish();\r
 \r
-               GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(\r
+               GridDataFactory.fillDefaults().grab(true, true).span(3, 1).applyTo(\r
                                indexExplorer);\r
                \r
                Control c = indexExplorer.getExplorerControl();\r
                if (c instanceof Tree)\r
                        ((Tree) c).setLinesVisible(true);\r
-               \r
-        \r
-        /*\r
-        \r
-        \r
-               table = new Table(container, support, SWT.BORDER);\r
-               table.setItemFactory(new ReadFactoryImpl<Object, List<Pair<String,Object>>>() {\r
 \r
-                       @Override\r
-                       public List<Pair<String, Object>> perform(ReadGraph graph,\r
-                                       Object input) throws DatabaseException {\r
-                               Resource enumeration = (Resource)input;\r
-                               SysdynResource sr = SysdynResource.getInstance(graph);\r
-                               Resource list = graph.getSingleObject(enumeration, sr.HasEnumerationIndexes);\r
-                               List<Resource> resourceList = OrderedSetUtils.toList(graph, list);\r
-\r
-                               List<Pair<String, Object>> result = new ArrayList<Pair<String, Object>>();\r
-                               for(Resource r : resourceList) {\r
-                                       result.add(new Pair<String, Object>( \r
-                                                       (String)graph.getRelatedValue(r, Layer0.getInstance(graph).HasName, Bindings.STRING)\r
-                                                       , r));\r
-                               }\r
-                               return result;\r
-                       }\r
-               });\r
-               table.setSelectionFactory(new ReadFactoryImpl<Resource, String>() {\r
-\r
-                       @Override\r
-                       public String perform(ReadGraph graph, final Resource input) throws DatabaseException {\r
-                               return graph.getRelatedValue(input, Layer0.getInstance(graph).HasName);\r
-                       }\r
-               });\r
-               GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(table.getWidget());\r
-               \r
-\r
-               final TableEditor editor = new TableEditor(table.getWidget());\r
-               // The editor must have the same size as the cell and must\r
-               // not be any smaller than 50 pixels.\r
-               editor.horizontalAlignment = SWT.LEFT;\r
-               editor.grabHorizontal = true;\r
-               editor.minimumWidth = 50;\r
-               // editing the second column\r
-               final int EDITABLECOLUMN = 0;\r
-\r
-               table.addSelectionListener(new SelectionAdapter() {\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                               // Clean up any previous editor control\r
-                               Control oldEditor = editor.getEditor();\r
-                               if (oldEditor != null)\r
-                                       oldEditor.dispose();\r
-\r
-                               // Identify the selected row\r
-                               final TableItem item = (TableItem) e.item;\r
-                               if (item == null)\r
-                                       return;\r
-\r
-                               // The control that will be the editor must be a child of the\r
-                               // Table\r
-                               Text newEditor = new Text(item.getParent(), SWT.NONE);\r
-                               final String originalText = item.getText(EDITABLECOLUMN);\r
-                               final Resource resource = (Resource) item.getData();\r
-                               newEditor.setText(originalText);\r
-                               newEditor.addModifyListener(new ModifyListener() {\r
-                                       public void modifyText(ModifyEvent me) {\r
-                                               Text text = (Text) editor.getEditor();\r
-                                               if(!text.isDisposed()) {\r
-                                                       TableItem item = editor.getItem();\r
-                                                       if(!item.isDisposed())\r
-                                                               item.setText(EDITABLECOLUMN, text.getText());\r
-                                               }\r
-                                       }\r
-                               });\r
-                               newEditor.addFocusListener(new FocusAdapter() {\r
-                                       @Override\r
-                                       public void focusLost(FocusEvent e) {\r
-                                               final Text text = (Text) editor.getEditor();\r
-                                               if(!text.getText().equals(originalText)) {\r
-                                                       final String newText = text.getText();\r
-                                                       try {\r
-                                                               context.getSession().syncRequest(new WriteRequest() {\r
-\r
-                                                                       @Override\r
-                                                                       public void perform(WriteGraph graph) throws DatabaseException {\r
-                                                                               graph.claimLiteral(\r
-                                                                                               resource, \r
-                                                                                               Layer0.getInstance(graph).HasName, \r
-                                                                                               newText);\r
-                                                                       }\r
-                                                               });\r
-                                                       } catch (DatabaseException e1) {\r
-                                                               e1.printStackTrace();\r
-                                                       }\r
-                                               }\r
-                                       }\r
-                               });\r
-                               newEditor.selectAll();\r
-                               newEditor.setFocus();\r
-                               editor.setEditor(newEditor, item, EDITABLECOLUMN);\r
-                       }\r
-               });\r
-\r
-               \r
-               \r
-               \r
-               */\r
-               \r
 \r
                Button add = new Button(container, support, SWT.None);\r
-               add.setText("Add index");\r
+               add.setText("Add");\r
                add.addSelectionListener(new addEnumerationIndexListener(support));\r
 \r
                Button remove = new Button(container, support, SWT.None);\r
                remove.setText("Remove");\r
                remove.addSelectionListener(new removeEnumerationIndexListener(support));\r
+               \r
+               showAll = new Button(container, support, SWT.CHECK);\r
+               showAll.setText("Show all in charts");\r
+               showAll.addSelectionListener(new ShowAllIndexesListener(support));\r
        }\r
 \r
        private class addEnumerationIndexListener implements SelectionListener, Widget {\r
@@ -304,4 +242,102 @@ public class EnumerationTab extends PropertyTabContributorImpl {
                }\r
 \r
        }\r
+       \r
+       private class ShowAllIndexesListener implements SelectionListener, Widget {\r
+\r
+                       Resource enumerationIndexes;\r
+\r
+                       public ShowAllIndexesListener(WidgetSupport support) {\r
+                               support.register(this);\r
+                       }\r
+\r
+                       @Override\r
+                       public void setInput(ISessionContext context, Object input) {\r
+                               final Resource enumeration = ISelectionUtils.filterSingleSelection((ISelection)input, Resource.class);\r
+                               \r
+                               context.getSession().asyncRequest(new Read<Boolean>() {\r
+\r
+                                       @Override\r
+                                       public Boolean perform(ReadGraph graph)\r
+                                                       throws DatabaseException {\r
+                                               SysdynResource sr = SysdynResource.getInstance(graph);\r
+                                               enumerationIndexes = graph.getSingleObject(enumeration, sr.HasEnumerationIndexes);\r
+                                               List<Resource> indexes = OrderedSetUtils.toList(graph, enumerationIndexes);\r
+                                               for(Resource index : indexes) {\r
+                                                       Boolean show = graph.getPossibleRelatedValue(index, sr.ShowEnumerationIndexInCharts, Bindings.BOOLEAN);\r
+                                                       if(!Boolean.TRUE.equals(show))\r
+                                                               return false;\r
+                                               }\r
+                                               return true;\r
+                                       }\r
+                                       \r
+                               }, new org.simantics.db.procedure.Listener<Boolean>() {\r
+\r
+                                       @Override\r
+                                       public void execute(final Boolean result) {\r
+                                               showAll.getWidget().getDisplay().asyncExec(new Runnable() {\r
+\r
+                                                       @Override\r
+                                                       public void run() {\r
+                                                               showAll.getWidget().setSelection(result.booleanValue());\r
+                                                       }\r
+                                               });\r
+                                       }\r
+                                                       \r
+\r
+                                       @Override\r
+                                       public void exception(Throwable t) {\r
+                                               t.printStackTrace();\r
+                                       }\r
+\r
+                                       @Override\r
+                                       public boolean isDisposed() {\r
+                                               if(showAll == null)\r
+                                                       return true;\r
+                                               return showAll.getWidget().isDisposed();\r
+                                       }\r
+                               });\r
+                               \r
+                       }\r
+\r
+                       @Override\r
+                       public void widgetSelected(SelectionEvent e) {\r
+                               final boolean selected = showAll.getWidget().getSelection();\r
+                               try {\r
+                                       SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+\r
+                                               @Override\r
+                                               public void perform(WriteGraph graph) throws DatabaseException {\r
+                                                       SysdynResource sr = SysdynResource.getInstance(graph);\r
+                                                       List<Resource> indexes = OrderedSetUtils.toList(graph, enumerationIndexes);\r
+                                                       for(Resource index : indexes) {\r
+                                                               Boolean show = graph.getPossibleRelatedValue(index, sr.ShowEnumerationIndexInCharts, Bindings.BOOLEAN);\r
+                                                               if(selected && !Boolean.TRUE.equals(show)) {\r
+                                                                       graph.claimLiteral(index, sr.ShowEnumerationIndexInCharts, true, Bindings.BOOLEAN);\r
+                                                               } else if(!selected && !Boolean.FALSE.equals(show)) {\r
+                                                                       graph.claimLiteral(index, sr.ShowEnumerationIndexInCharts, false, Bindings.BOOLEAN);\r
+                                                               }\r
+                                                       }\r
+                                                       \r
+                                                       Resource enumeration = graph.getSingleObject(enumerationIndexes, sr.HasEnumerationIndexes_Inverse);\r
+                                                       Resource configuration = graph.getSingleObject(enumeration, Layer0.getInstance(graph).PartOf);\r
+                                                       SysdynModel model = SysdynModelManager.getInstance(graph.getSession()).getModel(graph, configuration);\r
+                                                       // update results in graphs\r
+                                                       model.resultChanged();\r
+\r
+                                               }\r
+                                       });\r
+                               } catch (DatabaseException e1) {\r
+                                       e1.printStackTrace();\r
+                               }\r
+                               \r
+\r
+                       }\r
+\r
+                       @Override\r
+                       public void widgetDefaultSelected(SelectionEvent e) {\r
+\r
+                       }\r
+\r
+               }\r
 }\r
index 94909cda42d602a5e8c4ee332659bcb38fe0cc49..da74629d3d2625fb02266828c3cce4511af73014 100644 (file)
@@ -1,6 +1,7 @@
 package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
 \r
 import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.common.node.IDoubleClickableNode;\r
 import org.simantics.browsing.ui.common.node.IModifiableNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
 import org.simantics.db.ReadGraph;\r
@@ -10,10 +11,11 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.utils.VariableNameUtils;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
-public class EnumerationIndexNode  extends AbstractNode<Resource> implements IModifiableNode {\r
+public class EnumerationIndexNode  extends AbstractNode<Resource> implements IModifiableNode, IDoubleClickableNode {\r
 \r
        public EnumerationIndexNode(Resource resource) {\r
                super(resource);\r
@@ -69,4 +71,23 @@ public class EnumerationIndexNode  extends AbstractNode<Resource> implements IMo
         \r
        }\r
 \r
+       @Override\r
+       public boolean handleDoubleClick() {\r
+               return true;\r
+       }\r
+       \r
+       public void setShowInChartsSelected(final boolean selected) {\r
+       try {\r
+                       SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+                           @Override\r
+                           public void perform(WriteGraph graph) throws DatabaseException {\r
+                               SysdynResource sr = SysdynResource.getInstance(graph);\r
+                               graph.claimLiteral(data, sr.ShowEnumerationIndexInCharts, selected);\r
+                           }\r
+                       });\r
+               } catch (DatabaseException e) {\r
+                       e.printStackTrace();\r
+               }\r
+       }\r
+\r
 }\r
index 57dd8e2ba3f1d633e52dd70fbf3ded5ee885466c..993723d0811fe79ce0c2afd552018b783a71e9d8 100644 (file)
@@ -7,6 +7,7 @@ public class Keys {
        \r
        public static final String   ENUMERATION        = "Enumeration";\r
        public static final String   INDEXES            = "Indexes";\r
+       public static final String   SHOW_IN_CHARTS = "ShowInCharts";\r
         \r
        public static String[] ENUMERATION_COLUMNS_KEYS = { ENUMERATION, INDEXES };\r
     public static Column[] ENUMERATION_TABLE_COLUMNS = new Column[] {\r
@@ -15,4 +16,10 @@ public class Keys {
     };\r
     \r
 \r
+       public static String[] ENUMERATION_INDEX_COLUMNS_KEYS = { ENUMERATION, SHOW_IN_CHARTS };\r
+    public static Column[] ENUMERATION_INDEX_TABLE_COLUMNS = new Column[] {\r
+        new Column(ENUMERATION, Align.LEFT, 100, "Enumeration", true),\r
+        new Column(SHOW_IN_CHARTS, Align.LEFT, 20, "Show in charts", false),\r
+    };\r
+    \r
 }\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/ShowInChartsCheckBox.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/ShowInChartsCheckBox.java
new file mode 100644 (file)
index 0000000..232db37
--- /dev/null
@@ -0,0 +1,21 @@
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+import org.simantics.browsing.ui.CheckedState;\r
+import org.simantics.browsing.ui.graph.contributor.labeler.CheckedStateContributor;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class ShowInChartsCheckBox extends CheckedStateContributor<EnumerationIndexNode> {\r
+\r
+       @Override\r
+       public CheckedState getState(ReadGraph graph, EnumerationIndexNode input)\r
+                       throws DatabaseException {\r
+               SysdynResource sr = SysdynResource.getInstance(graph);\r
+               Boolean selected = graph.getPossibleRelatedValue(input.data, sr.ShowEnumerationIndexInCharts, Bindings.BOOLEAN);\r
+               return selected ? CheckedState.CHECKED : CheckedState.NOT_CHECKED;\r
+       }\r
+       \r
+}\r
+\r
index 7a37cc2b6fd6cf8d7a6acd31940da4cd672f35c0..79738f173d579ff3c8df2a746467c6952cbd9cca 100644 (file)
@@ -22,15 +22,19 @@ import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;\r
 import org.eclipse.ui.ISelectionListener;\r
 import org.eclipse.ui.IWorkbenchPart;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.Session;\r
 import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.SelectionHints;\r
+import org.simantics.db.layer0.variable.RepresentsProperty;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
 import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.layer0.Layer0;\r
 import org.simantics.modeling.ModelingUtils;\r
 import org.simantics.simulation.ontology.SimulationResource;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -140,7 +144,8 @@ public abstract class SysdynDatasetSelectionListener implements ISelectionListen
 \r
        protected Collection<SysdynDataSet> loadAllActive(ReadGraph g, Variable variable) throws DatabaseException {\r
                ArrayList<SysdynDataSet> dataSets = new ArrayList<SysdynDataSet>();\r
-\r
+               HashMap<String, String> rvis = new HashMap<String, String>();\r
+               \r
                String rvi = Variables.getRVI(g, variable);\r
                if (rvi == null) \r
                        return dataSets;\r
@@ -148,6 +153,17 @@ public abstract class SysdynDatasetSelectionListener implements ISelectionListen
                rvi = rvi.length() > 0 ? rvi.substring(1) : rvi;\r
                rvi = rvi.replace("/", ".");\r
                \r
+               RepresentsProperty rp = (RepresentsProperty)variable.getProperty(g, Variables.REPRESENTS);\r
+               Resource r = rp.getValue(g);\r
+               \r
+               SysdynResource sr = SysdynResource.getInstance(g);\r
+               Resource arrayIndexes = g.getPossibleObject(r, sr.HasArrayIndexes);\r
+               if(arrayIndexes == null) {\r
+                       rvis.put(rvi, rvi);\r
+               } else {\r
+                       traverseIndexes(g, rvi, rvis, OrderedSetUtils.toList(g, arrayIndexes));\r
+               }\r
+               \r
                Resource modelResource = Variables.getModel(g, variable);\r
                SysdynModel model = getSysdynModel(g, modelResource);\r
                \r
@@ -156,14 +172,45 @@ public abstract class SysdynDatasetSelectionListener implements ISelectionListen
                \r
                Collection<SysdynResult> activeResults = model.getActiveResults(g);\r
                for(SysdynResult sysdynResult : activeResults) {\r
-                       SysdynDataSet sds = sysdynResult.getDataSet(rvi);\r
-                       if(sds != null)\r
-                               dataSets.add(sds);\r
+                       for(String currvi : rvis.keySet()) {\r
+                               SysdynDataSet sds = sysdynResult.getDataSet(currvi);\r
+                               if(sds != null) {\r
+                                       sds.name = rvis.get(currvi);\r
+                                       dataSets.add(sds);\r
+                               }\r
+                       }\r
                }\r
                return dataSets;\r
 \r
        }\r
        \r
+       private void traverseIndexes(ReadGraph g, String rvi, HashMap<String, String> rvis, List<Resource> arrayIndexes) throws DatabaseException {\r
+               traverseIndexes(g, rvi, rvis, arrayIndexes, arrayIndexes.get(0), "", "");\r
+       }\r
+       \r
+       private void traverseIndexes(ReadGraph g, String rvi, HashMap<String, String> rvis, List<Resource> arrayIndexes, Resource currentEnumeration, String indexesSoFar, String indexNamesSoFar) throws DatabaseException {\r
+               SysdynResource sr = SysdynResource.getInstance(g);\r
+               Resource enumerationIndexes = g.getPossibleObject(currentEnumeration, sr.HasEnumerationIndexes);\r
+               if(enumerationIndexes == null)\r
+                       return;\r
+               List<Resource> indexes = OrderedSetUtils.toList(g, enumerationIndexes);\r
+               for(int i = 0; i < indexes.size(); i++) {\r
+                       Boolean b = g.getPossibleRelatedValue(indexes.get(i), sr.ShowEnumerationIndexInCharts, Bindings.BOOLEAN);\r
+                       if(Boolean.TRUE.equals(b)) {\r
+                               int arrayIndex = arrayIndexes.indexOf(currentEnumeration);\r
+                               String name = g.getRelatedValue(indexes.get(i), Layer0.getInstance(g).HasName);\r
+                               if(arrayIndex < arrayIndexes.size() - 1)\r
+                                       traverseIndexes(g, rvi, rvis, arrayIndexes, arrayIndexes.get(arrayIndex + 1), \r
+                                                       indexesSoFar + (i + 1) +",", indexNamesSoFar + (name) +",");\r
+                               else {\r
+                                       rvis.put(\r
+                                                       rvi + "[" + indexesSoFar + (i + 1) + "]", \r
+                                                       rvi + "[" + indexNamesSoFar + (name) + "]");\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+       \r
        private Variable getVariable(ReadGraph g, Resource element, Resource runtime) throws DatabaseException {\r
                SysdynResource sr = SysdynResource.getInstance(g);\r
                DiagramResource dr = DiagramResource.getInstance(g);\r
index cb6fe0780c567275350410f8e0378d68d3f2d31d..c1abc57ec42d71fe70b8c76129762fc7ecba7293 100644 (file)
@@ -251,10 +251,9 @@ public class SysdynModel implements IMappingListener, IModel {
                                                        result.filter();\r
                                                        sysdynResult.setResult(result);\r
                                                        progressMonitor.worked(1);\r
-                                                       synchronized(resultListeners) {\r
-                                                               for(Runnable listener : resultListeners)\r
-                                                                       listener.run();\r
-                                                       }\r
+                                                       \r
+                                                       resultChanged();\r
+                                                       \r
                                                        setExperimentStopped(experiment);\r
                                                }\r
                                        } catch (FileNotFoundException e) {\r
@@ -348,6 +347,14 @@ public class SysdynModel implements IMappingListener, IModel {
                        resultListeners.remove(listener);\r
                }\r
        }\r
+       \r
+       public void resultChanged() {\r
+               synchronized(resultListeners) {\r
+                       for(Runnable listener : resultListeners) {\r
+                               listener.run();\r
+                       }\r
+               }\r
+       }\r
 \r
        public void addModificationListener(Runnable listener) {\r
                synchronized(modificationListeners) {\r