]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Merged changes from r27124 through r27280 from trunk to branches/simantics-1.10
authorlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 12 Apr 2013 01:12:44 +0000 (01:12 +0000)
committerlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 12 Apr 2013 01:12:44 +0000 (01:12 +0000)
in preparation for the Simantics 1.10 release.

refs #4189

The merged changes include fixes for the following issues:

<pre>
2013-07 (22)
#4219 Transferable graph with resource literals can only be imported once
#4223 Remove stdout printing option from issues to CSV export action
#4231 Wordwrap/Horizontal scrollbar for document editor StyledText widget
#4233 FileUtils.copyFile/copy do not close file descriptors properly
#4234 File handle leakage in PDF export
#4246 Problems in FastLZ stream implementations
#4248 Query collector fails to collect some discarded parents
#4249 Subscription collection initialization fails if a subscription item is broken (has no name)
#4250 ContextualHelp should attempt help context resolution on diagrams even when selected element is not mapped
#4224 Allow GraphExplorer item selection by keys / labels to use other than primary column for matching.
#4189 Branch and release Simantics 1.10
#4235 Drawing template changes
#4065 Fix annotation user interfaces
#4218 Color edit support for DnD monitors
#4220 Change EntityRemover to not remove L0.HasProperty objects as composed properties if they are an L0.PartOf something else
#4225 Show resource ID in issue view if there's nothing else to show for the issue context
#4226 Make low level Layer0 validation produce fatal issues so that they don't go unnoticed.
#4228 Allow CSV export number format specification through preferences
#4229 Customizable clipboard logic in CopyPasteHandler
#4230 Prevent RouteGraphNode from starting connection rerouting if there are more than one other elements selected
#4247 Primarily look for workbench search function from active model, resort to project only secondarily.
#4251 Allow tree columns in TreeDialog
2013-06 (28)
#4113 ResourceBinding cleanup
#4181 Caching prevents some valid renames
#4182 Dependency index gets out of sync
#4185 undo(int numberOfOperations)
#4186 PDF export leaks memory
#4190 Do not allow entity names to be modified to begin with one or more dots ('.')
#4191 AdaptationUtils.adaptToCollection fails to adapt, if class implements IAdaptable
#4193 Selection view input throttling produces wrong tabs for user
#4195 Deleting terminal element in symbol editor fails to remove diagram connection points from symbol
#4202 SWTKeyEventAdapter produces wrong modifier state mask for key event when AltGr is pressed
#4210 Simulation time HMS mode viewing fails to show time beyond 5 965 hours
#4211 Problems with session reconnect
#4212 setImmutable failed if cluster was not resident
#4215 Safety fixes for monitor formatting
#2897 As a developer, I want to use GraphExplorer as non-virtual
#3219 Lazy updating of model browser and graph explorer are problematic
#3994 Get Resource -> Resource map in SCL based mapping
#4184 TreeViewer based GraphExplorer
#4206 Save work done for team feature movie.
#3984 Import sources for SimanticsExcel.dll
#4197 If mouse doesn't move between subsequent diagram copy-paste operations, offset the pasted elements as when using Edit / Paste main menu
#4203 Migration framework enhancement
#4204 Temp file management in Simantics facade
#4205 Refactor issues to allow reporting of L0 issues
#4213 Make recovery work silently.
#4214 GraphExplorerImpl image decorations should be offloaded from the UI thread into the image loader job
#4216 BoxSelectionMode should be cancelable by pressing ESC
#4217 Extend BasicExpression lexer to support 8-bit ASCII characters in quoted strings
2013-05 (29)
#4114 Flag type not verified for newly created flags
#4132 Workspace persistent virtual graph loading robustness / safety enhancements
#4144 Spreadsheet loses selection while editing cell
#4145 Useless error messages when pasting PNG image on top of image node in a drawing template
#4151 Issues are not updated in some removal cases
#4157 Diagram loading can cause weird exceptions if editor is disposed during loading
#4158 Manual activation of mapping messes up undo
#4159 Removal of connected diagram reference elements corrupts database
#4161 RouteGraph.makePersistent behaves incorrectly when the connection is simple
#4163 Minor bug in connect tool
#4164 Component modification metadata missing for some removed connections
#4166 Session does not close properly
#4169 Modelled views fail to show content at startup
#4173 Random access values can corrupt the database session
#4174 AwtFocusHandler.hidePopups race condition
#4178 Move tryRemover from DeleteNodeHandler to RemoverUtil
#4153 Exporting GraphFiles
#4160 Minor modifications to SCL documentation
#4165 Support session reconnect in SimanticsPlatform
#3519 Change Sysdyn jenkins builds to bundle JRE 6
#4142 Simantics 1.9 release
#4147 Store SCL console command history into preferences
#4148 Add undo into DB.scl
#4150 Batch issue validation performance enhancements
#4155 Allow overriding oleEditor's title.
#4162 runTest command for SCL console
#4167 Remove resources from index updates
#4170 Set exported PDF Application metadata based on IProduct information
#4179 Support multiple tg roots in migration framework
</pre>

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches@27281 ac1ea38d-2e2b-0410-8846-a27921b304fc

51 files changed:
simantics-1.10/org.simantics.jfreechart.ontology/graph.tg
simantics-1.10/org.simantics.jfreechart.ontology/graph/JFreeChart.pgraph
simantics-1.10/org.simantics.jfreechart.ontology/src/org/simantics/sysdyn/JFreeChartResource.java
simantics-1.10/org.simantics.jfreechart/adapters.xml
simantics-1.10/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/DeviationRenderer.java [new file with mode: 0644]
simantics-1.10/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/ColorPicker.java
simantics-1.10/org.simantics.modelica/src/org/simantics/modelica/ModelicaManager.java
simantics-1.10/org.simantics.modelica/src/org/simantics/modelica/SimulationLocation.java
simantics-1.10/org.simantics.objmap/src/org/simantics/objmap/impl/Mapping.java
simantics-1.10/org.simantics.objmap/src/org/simantics/objmap/impl/RangeUpdateRequest.java
simantics-1.10/org.simantics.sysdyn.ontology/graph.tg
simantics-1.10/org.simantics.sysdyn.ontology/graph/Migration.pgraph
simantics-1.10/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
simantics-1.10/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java
simantics-1.10/org.simantics.sysdyn.ui/adapters.xml
simantics-1.10/org.simantics.sysdyn.ui/icons/bullet_gray.png [new file with mode: 0644]
simantics-1.10/org.simantics.sysdyn.ui/icons/bullet_green.png [new file with mode: 0644]
simantics-1.10/org.simantics.sysdyn.ui/plugin.xml
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/CreateVariablesShortcutParticipant.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewBarChartHandler.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewExperimentNodeHandler.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewFunctionHandler.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewFunctionLibraryHandler.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewHistoryDataHandler.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewModuleNodeHandler.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewPieChartHandler.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSensitivityAnalysisExperimentNodeHandler.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSensitivityChartHandler.java [new file with mode: 0644]
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSharedFunctionLibraryHandler.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewXYLineChartHandler.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleInputTab.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SensitivityDataset.java [new file with mode: 0644]
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/XYDataset.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ExpressionUtils.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/imports/ImportUtils.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/EnumerationFunction.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/ExpressionIssueFunction.java
simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/IssueWithStringContext.java
simantics-1.10/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/IndexVariable.java
simantics-1.10/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariable.java
simantics-1.10/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/VariableValueSubscription.java
simantics-1.10/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiment.java
simantics-1.10/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java
simantics-1.10/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java
simantics-1.10/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynSensitivityAnalysisExperiment.java
simantics-1.10/org.simantics.sysdyn/src/org/simantics/sysdyn/refactoring/TGRefactoring.java
simantics-1.10/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Sheet.java
simantics-1.10/org.simantics.sysdyn/src/org/simantics/sysdyn/simulation/SimulationJob.java
simantics-1.10/org.simantics.sysdyn/src/org/simantics/sysdyn/simulation/SimulationScheduler.java

index 5cc13db42534db0cc86f976efc7ecbc3a92498b4..3abaa9be847550808ab81c7e8e16fbfe528e4f5a 100644 (file)
Binary files a/simantics-1.10/org.simantics.jfreechart.ontology/graph.tg and b/simantics-1.10/org.simantics.jfreechart.ontology/graph.tg differ
index c83c674356aecde088d2d0419323a44f0e701ec1..aaf0a275a2264f0bb380b09b52486b265c2138c1 100644 (file)
@@ -111,6 +111,8 @@ JFREE.XYAreaRenderer <T JFREE.Renderer
 
 JFREE.BarRenderer <T JFREE.Renderer
 JFREE.StackedBarRenderer <T JFREE.Renderer
+
+JFREE.DeviationRenderer <T JFREE.Renderer
     
 //#####################################################################
 // Position
index 78e3f109f86c470b2faa4c30d201877b25427c88..9faec9520b92f0ac8b432a341a17862003b7c503 100644 (file)
@@ -69,6 +69,7 @@ public class JFreeChartResource {
     public final Resource Dataset_renderer_Inverse;\r
     public final Resource Dataset_seriesList;\r
     public final Resource Dataset_seriesList_Inverse;\r
+    public final Resource DeviationRenderer;\r
     public final Resource ImageTitle;\r
     public final Resource Left;\r
     public final Resource LegendTitle;\r
@@ -194,6 +195,7 @@ public class JFreeChartResource {
         public static final String Dataset_renderer_Inverse = "http://www.simantics.org/JFreeChart-1.0/Dataset/renderer/Inverse";\r
         public static final String Dataset_seriesList = "http://www.simantics.org/JFreeChart-1.0/Dataset/seriesList";\r
         public static final String Dataset_seriesList_Inverse = "http://www.simantics.org/JFreeChart-1.0/Dataset/seriesList/Inverse";\r
+        public static final String DeviationRenderer = "http://www.simantics.org/JFreeChart-1.0/DeviationRenderer";\r
         public static final String ImageTitle = "http://www.simantics.org/JFreeChart-1.0/ImageTitle";\r
         public static final String Left = "http://www.simantics.org/JFreeChart-1.0/Left";\r
         public static final String LegendTitle = "http://www.simantics.org/JFreeChart-1.0/LegendTitle";\r
@@ -329,6 +331,7 @@ public class JFreeChartResource {
         Dataset_renderer_Inverse = getResourceOrNull(graph, URIs.Dataset_renderer_Inverse);\r
         Dataset_seriesList = getResourceOrNull(graph, URIs.Dataset_seriesList);\r
         Dataset_seriesList_Inverse = getResourceOrNull(graph, URIs.Dataset_seriesList_Inverse);\r
+        DeviationRenderer = getResourceOrNull(graph, URIs.DeviationRenderer);\r
         ImageTitle = getResourceOrNull(graph, URIs.ImageTitle);\r
         Left = getResourceOrNull(graph, URIs.Left);\r
         LegendTitle = getResourceOrNull(graph, URIs.LegendTitle);\r
index b6a4e8f065f7f404cc0787cabd24a59f7ac14fcc..54fd841ce80612948c9fc6bd5c3da8f366227fd2 100644 (file)
             class="org.simantics.jfreechart.chart.StackedBarRenderer">\r
             <graph />\r
             <this />\r
-        </type>        \r
+        </type>      \r
+        <type uri="http://www.simantics.org/JFreeChart-0.0/DeviationRenderer"\r
+            class="org.simantics.jfreechart.chart.DeviationRenderer">\r
+            <graph />\r
+            <this />\r
+        </type>           \r
     </target> \r
 </adapters>
\ No newline at end of file
diff --git a/simantics-1.10/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/DeviationRenderer.java b/simantics-1.10/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/DeviationRenderer.java
new file mode 100644 (file)
index 0000000..716bb68
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.jfreechart.chart;\r
+\r
+import org.jfree.chart.labels.StandardXYToolTipGenerator;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+\r
+public class DeviationRenderer extends AbstractRenderer {\r
+\r
+    public DeviationRenderer(ReadGraph graph, Resource resource) {\r
+        super(graph, resource);\r
+    }\r
+\r
+    private org.jfree.chart.renderer.xy.DeviationRenderer renderer;\r
+    \r
+    @Override\r
+    public org.jfree.chart.renderer.AbstractRenderer getRenderer() {\r
+        if(renderer == null) {\r
+            renderer = new org.jfree.chart.renderer.xy.DeviationRenderer();\r
+            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());\r
+        }\r
+        return renderer;\r
+    }\r
+\r
+}\r
index 2901c2700a9b9096a95d1171180d00712dcfd2ef..c51a8feb6aed0a8659fcd511ccbc11e49b50918b 100644 (file)
@@ -13,12 +13,10 @@ package org.simantics.jfreechart.chart.properties;
 \r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.graphics.Color;\r
 import org.eclipse.swt.graphics.Device;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Image;\r
 import org.eclipse.swt.graphics.Point;\r
 import org.eclipse.swt.graphics.RGB;\r
 import org.eclipse.swt.widgets.ColorDialog;\r
@@ -44,6 +42,7 @@ import org.simantics.ui.SimanticsUI;
 import org.simantics.ui.utils.AdaptionUtils;\r
 import org.simantics.utils.RunnableWithObject;\r
 import org.simantics.utils.datastructures.Triple;\r
+import org.simantics.utils.ui.gfx.ColorImageDescriptor;\r
 \r
 /**\r
  * Composite for selecting a color for a chart component\r
@@ -165,12 +164,12 @@ public class ColorPicker extends Composite implements Widget {
      * @param blue Blue 0-255\r
      * @return\r
      */\r
-    private Image getColorPickerImage(Device device, int red, int green, int blue) {\r
-        Image image = new Image(device, 20, 20);\r
-        GC gc = new GC (image);\r
-        gc.setBackground (new Color(device, red, green, blue));\r
-        gc.fillRectangle (image.getBounds ());\r
-        gc.dispose ();\r
+    private ImageDescriptor getColorPickerImage(Device device, int red, int green, int blue) {\r
+        ImageDescriptor image = new ColorImageDescriptor(red, green, blue, 20, 20, true);\r
+        //GC gc = new GC (image);\r
+        //gc.setBackground (new Color(device, red, green, blue));\r
+        //gc.fillRectangle (image.getBounds ());\r
+        //gc.dispose ();\r
         return image;\r
     }\r
 \r
@@ -179,7 +178,7 @@ public class ColorPicker extends Composite implements Widget {
      * @author Teemu Lempinen\r
      *\r
      */\r
-    private class ColorImageFactoryFactory extends ReadFactoryImpl<Resource, Image> {\r
+    private class ColorImageFactoryFactory extends ReadFactoryImpl<Resource, ImageDescriptor> {\r
         \r
         Button button;\r
         \r
@@ -188,12 +187,13 @@ public class ColorPicker extends Composite implements Widget {
             this.button = button;\r
         }\r
         \r
+        @Override\r
         public Object getIdentity(Object inputContents) {\r
             return new Triple<Object, Class<?>, Button>(inputContents, getClass(), button);\r
         }\r
 \r
         @Override\r
-        public Image perform(ReadGraph graph, Resource input) throws DatabaseException {\r
+        public ImageDescriptor perform(ReadGraph graph, Resource input) throws DatabaseException {\r
             if(button.getWidget().isDisposed())\r
                 return null;\r
             Display device = button.getWidget().getDisplay();\r
@@ -263,6 +263,7 @@ public class ColorPicker extends Composite implements Widget {
             final RGB oldRGB = getColor(graph, resource);\r
             \r
             display.asyncExec(new RunnableWithObject(oldRGB) {\r
+                @Override\r
                 public void run() {\r
                     // Use color dialog to select a color\r
                     Shell shell = new Shell(display);\r
@@ -280,7 +281,7 @@ public class ColorPicker extends Composite implements Widget {
                         @Override\r
                         public void perform(WriteGraph graph) throws DatabaseException {\r
                             G2DResource g2d = G2DResource.getInstance(graph);\r
-                            float[] components = new float[] {(float)rgb.red / 255.0f,  (float)rgb.green / 255.0f, (float)rgb.blue / 255.0f, 1.0f};\r
+                            float[] components = new float[] {rgb.red / 255.0f,  rgb.green / 255.0f, rgb.blue / 255.0f, 1.0f};\r
                             graph.claimLiteral(resource, getColorRelation(graph), g2d.Color, components);                            \r
                         }\r
                     });\r
@@ -301,7 +302,7 @@ public class ColorPicker extends Composite implements Widget {
      */\r
     private class DefaultColorSelectionFactory extends ReadFactoryImpl<Resource, Boolean> {\r
 \r
-        private Boolean isCustom;\r
+        private final Boolean isCustom;\r
 \r
         /**\r
          * \r
index 5364078e099eb65b1dda761de1e47b9d3cd815e5..2de275d8a9782e4b4147946e9219c889a5e1f949 100644 (file)
@@ -68,7 +68,10 @@ public class ModelicaManager {
     public enum OSType {\r
         APPLE, LINUX, SUN, WINDOWS, UNKNOWN\r
     }\r
-\r
+    \r
+    public static String OMC_VERSION = "OMC_VERSION"; \r
+    public static String RESULT_FILE_NAME = "RESULT_FILE_NAME"; \r
+    \r
     /**\r
      * Get operating system type\r
      * @return OSType\r
@@ -538,12 +541,23 @@ public class ModelicaManager {
 \r
             ArrayList<String> commands = new ArrayList<String>();\r
             commands.add(simulationLocation.executableFile.getAbsolutePath());\r
+            \r
+           if(experimentParameters.get(RESULT_FILE_NAME) != null) {\r
+               commands.add("-r="+experimentParameters.get(RESULT_FILE_NAME));\r
+           }\r
+            \r
             // Write new initial values (parameters). No need to update xml if structure has changed. In that case also xml is up-to-date\r
             if(parameterChanges != null) {\r
-                String version = getOMCVersion(simulationLocation.omcHome);\r
+                String version = experimentParameters.get(OMC_VERSION);\r
+                if(version == null)\r
+                        version = getOMCVersion(simulationLocation.omcHome);\r
                 if(version.startsWith("1.9")) {\r
                     // Handled in experiment\r
-                    updateInitFile(simulationLocation, experimentParameters, parameterChanges);\r
+                    if(parameterChanges.size() == 1) {\r
+                        commands.add("-override");\r
+                        commands.add(parameterChanges.keySet().iterator().next() + "=" + parameterChanges.values().iterator().next());\r
+                    } else\r
+                        updateInitFile(simulationLocation, experimentParameters, parameterChanges);\r
                 } else {\r
                     writeInits(simulationLocation, experimentParameters, monitor);\r
                 }\r
index 91ef37b8516edb167a87ac0bfc53d00a1fa574e7..98f5cdd03c1bedf91449c818afa467f749b174be 100644 (file)
@@ -16,6 +16,7 @@ import java.io.File;
 /**\r
  * \r
  * @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
  *\r
  */\r
 public class SimulationLocation {\r
index cf4c33c9c6ea0a45d37cd655bed2671daa2cb35a..abb726e7b61c5bff3b5c8b0459bdcbad4f754492 100644 (file)
@@ -275,12 +275,14 @@ public class Mapping implements IMapping {
                        if(listensDomain) {\r
                            RangeUpdateRequest request = new RangeUpdateRequest(link, map, this);\r
                            try {\r
-                    g.syncRequest(request, request);\r
+                    boolean modified = g.syncRequest(request, request);\r
+                    if(modified) {\r
+                        updated.add(link.rangeElement);\r
+                    }\r
                 } catch (DatabaseException e) {\r
                     throw new MappingException(e);\r
                 }\r
-                           // TODO check if really modified\r
-                           updated.add(link.rangeElement);\r
+\r
                        }\r
                        else\r
                            if(link.type.updateRange(g, map, link.domainElement, link.rangeElement))\r
index 3268d9e266d75d1ad0ebe77391b905432225fd3f..4c1906589f9e1cb12f45506259962fb065f6bcc8 100644 (file)
@@ -38,9 +38,9 @@ public class RangeUpdateRequest implements Read<Boolean>, SyncListener<Boolean>
     @Override\r
     public Boolean perform(ReadGraph g) throws DatabaseException {\r
         if(map != null) {\r
-            link.type.updateRange(g, map, link.domainElement, link.rangeElement);\r
+            boolean updated = link.type.updateRange(g, map, link.domainElement, link.rangeElement);\r
             map = null;\r
-            return Boolean.TRUE;\r
+            return updated;\r
         }\r
         else if(mapping != null) {\r
             mapping.domainModified(link);\r
index a7b7d77e4d60bc63d49fa91846c27fd24e7fbb2d..eba5af9cb5f8cdb5a2a547e031682e6cfaab4039 100644 (file)
Binary files a/simantics-1.10/org.simantics.sysdyn.ontology/graph.tg and b/simantics-1.10/org.simantics.sysdyn.ontology/graph.tg differ
index 42345d3128af4256110dcdff490573a2f37fa9fa..7d1354690328cb2e734050526bcb8575aea24ffe 100644 (file)
@@ -8,14 +8,34 @@ move : L0.Template
             L0.NamespaceMigrationStep.Prefix.from %from\r
             L0.NamespaceMigrationStep.Prefix.to %to\r
             \r
-MIGRATION = SYSDYN."from1.6to1.7" : L0.MigrationSequence\r
+MIGRATION = SYSDYN.Migration : L0.Library\r
+            \r
+MIGRATION.fromModel1 : L0.Migration\r
+  L0.Migration.format "sysdynModel"\r
+  L0.Migration.from 1\r
+  L0.Migration.step FROM16TO17\r
+  L0.Migration.priority 1.0\r
+  \r
+MIGRATION.fromModule1 : L0.Migration\r
+  L0.Migration.format "sysdynModule"\r
+  L0.Migration.from 1\r
+  L0.Migration.step FROM16TO17\r
+  L0.Migration.priority 1.0\r
+\r
+MIGRATION.fromFunctionLibrary1 : L0.Migration\r
+  L0.Migration.format "sysdynFunctionLibrary"\r
+  L0.Migration.from 1\r
+  L0.Migration.step FROM16TO17\r
+  L0.Migration.priority 1.0    \r
+              \r
+FROM16TO17 = MIGRATION."from1.6to1.7" : L0.MigrationSequence\r
     @L0.list\r
-        MIGRATION.Ontologies\r
-        MIGRATION.Spreadsheets\r
-        MIGRATION.SysdynChanges\r
-        MIGRATION.OrderedSetsToLists\r
+        FROM16TO17.Ontologies\r
+        FROM16TO17.Spreadsheets\r
+        FROM16TO17.SysdynChanges\r
+        FROM16TO17.OrderedSetsToLists\r
 \r
-MIGRATION.Ontologies : L0.NamespaceMigrationStep\r
+FROM16TO17.Ontologies : L0.NamespaceMigrationStep\r
   @L0.list\r
     _\r
       @move "http://www.simantics.org/Layer0-" "1.0" "1.1"\r
@@ -60,7 +80,7 @@ MIGRATION.Ontologies : L0.NamespaceMigrationStep
     _\r
       @move"http://www.simantics.org/SelectionView-" "1.1" "1.2"\r
       \r
-MIGRATION.Spreadsheets : L0.NamespaceMigrationStep\r
+FROM16TO17.Spreadsheets : L0.NamespaceMigrationStep\r
   @L0.list\r
     _\r
       @move "http://www.simantics.org/Spreadsheet-1.2/" "HasContent" "Cell/content"\r
@@ -91,7 +111,7 @@ MIGRATION.Spreadsheets : L0.NamespaceMigrationStep
     _\r
       @move "http://www.simantics.org/Spreadsheet-1.2/" "ColumnWidthsOf" "Headers/columnWidths/Inverse"        \r
 \r
-MIGRATION.SysdynChanges : L0.NamespaceMigrationStep\r
+FROM16TO17.SysdynChanges : L0.NamespaceMigrationStep\r
   @L0.list\r
     _\r
       @move "http://www.simantics.org/Sysdyn-1.1/" "HasTail" "Variable/HasTail"\r
@@ -101,7 +121,7 @@ MIGRATION.SysdynChanges : L0.NamespaceMigrationStep
       @move "http://www.simantics.org/Sysdyn-1.1/" "SharedModuleOntolofgy" "SharedModuleOntology"\r
       \r
                   \r
-MIGRATION.OrderedSetsToLists : L0.OrderedSetToListMigrationStep\r
+FROM16TO17.OrderedSetsToLists : L0.OrderedSetToListMigrationStep\r
     @L0.list\r
         _ : L0.OrderedSetToListMigrationStep.Change\r
             L0.OrderedSetToListMigrationStep.entityType "http://www.simantics.org/Sysdyn-1.1/Variable"\r
index 30c5641a0035065c31020adbf6e4234c78f854ce..109a1df91b92ea1fa02ad85dd823ed36ee8d4064 100644 (file)
@@ -44,6 +44,8 @@ SYSDYN.SysdynModel <T MOD.StructuralModel
     >-- SYSDYN.SysdynModel.tolerance --> L0.Double <R L0.HasProperty : L0.FunctionalRelation
     >-- SYSDYN.SysdynModel.solver --> L0.String <R L0.HasProperty : L0.FunctionalRelation
     >-- SYSDYN.SysdynModel.variableFilter --> L0.String <R L0.HasProperty : L0.FunctionalRelation
+    >-- SYSDYN.SysdynModel.fmuFile --> L0.ByteArray <R L0.HasProperty
+//    >-- SYSDYN.SysdynModel.exeFile --> L0.ByteArray <R L0.HasProperty
     @L0.assert SYSDYN.SysdynModel.startTime 0.0
     @L0.assert SYSDYN.SysdynModel.stopTime 10.0
     @L0.assert SYSDYN.SysdynModel.solver "euler"
@@ -352,6 +354,10 @@ SYSDYN.SensitivityAnalysisExperiment <T SYSDYN.Experiment
     >-- SYSDYN.SensitivityAnalysisExperiment.minValue --> L0.Double <R L0.HasProperty : L0.FunctionalRelation
     >-- SYSDYN.SensitivityAnalysisExperiment.maxValue --> L0.Double <R L0.HasProperty : L0.FunctionalRelation
     >-- SYSDYN.SensitivityAnalysisExperiment.numValues --> L0.Integer <R L0.HasProperty : L0.FunctionalRelation
+    >-- SYSDYN.SensitivityAnalysisExperiment.mean --> L0.Double <R L0.HasProperty : L0.FunctionalRelation
+    >-- SYSDYN.SensitivityAnalysisExperiment.stdDeviation --> L0.Double <R L0.HasProperty : L0.FunctionalRelation
+
+SYSDYN.SensitivityAnalysisExperiment.SensitivityDataset <T JFREE.Dataset
 
 //#####################################################################
 // Results and history datasets
index 458c0d4826413c3f039700ec8879a560abc97ac2..fd575f45446bb499c63d122d3bc5e23eee6ffa6e 100644 (file)
@@ -432,6 +432,15 @@ public class SysdynResource {
     public final Resource LookupExpression;\r
     public final Resource LookupExpression_lookup;\r
     public final Resource LookupExpression_lookup_Inverse;\r
+    public final Resource Migration;\r
+    public final Resource Migration_from1$6to1$7;\r
+    public final Resource Migration_from1$6to1$7_Ontologies;\r
+    public final Resource Migration_from1$6to1$7_OrderedSetsToLists;\r
+    public final Resource Migration_from1$6to1$7_Spreadsheets;\r
+    public final Resource Migration_from1$6to1$7_SysdynChanges;\r
+    public final Resource Migration_fromFunctionLibrary1;\r
+    public final Resource Migration_fromModel1;\r
+    public final Resource Migration_fromModule1;\r
     public final Resource ModelBrowser;\r
     public final Resource ModelingActionContext;\r
     public final Resource ModelingActionContext_Actions;\r
@@ -508,14 +517,19 @@ public class SysdynResource {
     public final Resource Right;\r
     public final Resource SelectedSharedFunctionLibraries;\r
     public final Resource SensitivityAnalysisExperiment;\r
+    public final Resource SensitivityAnalysisExperiment_SensitivityDataset;\r
     public final Resource SensitivityAnalysisExperiment_maxValue;\r
     public final Resource SensitivityAnalysisExperiment_maxValue_Inverse;\r
+    public final Resource SensitivityAnalysisExperiment_mean;\r
+    public final Resource SensitivityAnalysisExperiment_mean_Inverse;\r
     public final Resource SensitivityAnalysisExperiment_minValue;\r
     public final Resource SensitivityAnalysisExperiment_minValue_Inverse;\r
     public final Resource SensitivityAnalysisExperiment_numValues;\r
     public final Resource SensitivityAnalysisExperiment_numValues_Inverse;\r
     public final Resource SensitivityAnalysisExperiment_propabilityDistribution;\r
     public final Resource SensitivityAnalysisExperiment_propabilityDistribution_Inverse;\r
+    public final Resource SensitivityAnalysisExperiment_stdDeviation;\r
+    public final Resource SensitivityAnalysisExperiment_stdDeviation_Inverse;\r
     public final Resource SensitivityAnalysisExperiment_variedParameter;\r
     public final Resource SensitivityAnalysisExperiment_variedParameter_Inverse;\r
     public final Resource SharedFunctionOntology;\r
@@ -535,6 +549,8 @@ public class SysdynResource {
     public final Resource SysdynConnectionType;\r
     public final Resource SysdynDiagramModelingRules;\r
     public final Resource SysdynModel;\r
+    public final Resource SysdynModel_fmuFile;\r
+    public final Resource SysdynModel_fmuFile_Inverse;\r
     public final Resource SysdynModel_outputInterval;\r
     public final Resource SysdynModel_outputInterval_Inverse;\r
     public final Resource SysdynModel_simulationStepLength;\r
@@ -660,11 +676,6 @@ public class SysdynResource {
     public final Resource WithLookupExpression_maxY;\r
     public final Resource WithLookupExpression_minX;\r
     public final Resource WithLookupExpression_minY;\r
-    public final Resource from1$6to1$7;\r
-    public final Resource from1$6to1$7_Ontologies;\r
-    public final Resource from1$6to1$7_OrderedSetsToLists;\r
-    public final Resource from1$6to1$7_Spreadsheets;\r
-    public final Resource from1$6to1$7_SysdynChanges;\r
         \r
     public static class URIs {\r
         public static final String AdditionalSymbols = "http://www.simantics.org/Sysdyn-1.1/AdditionalSymbols";\r
@@ -1090,6 +1101,15 @@ public class SysdynResource {
         public static final String LookupExpression = "http://www.simantics.org/Sysdyn-1.1/LookupExpression";\r
         public static final String LookupExpression_lookup = "http://www.simantics.org/Sysdyn-1.1/LookupExpression/lookup";\r
         public static final String LookupExpression_lookup_Inverse = "http://www.simantics.org/Sysdyn-1.1/LookupExpression/lookup/Inverse";\r
+        public static final String Migration = "http://www.simantics.org/Sysdyn-1.1/Migration";\r
+        public static final String Migration_from1$6to1$7 = "http://www.simantics.org/Sysdyn-1.1/Migration/from1.6to1.7";\r
+        public static final String Migration_from1$6to1$7_Ontologies = "http://www.simantics.org/Sysdyn-1.1/Migration/from1.6to1.7/Ontologies";\r
+        public static final String Migration_from1$6to1$7_OrderedSetsToLists = "http://www.simantics.org/Sysdyn-1.1/Migration/from1.6to1.7/OrderedSetsToLists";\r
+        public static final String Migration_from1$6to1$7_Spreadsheets = "http://www.simantics.org/Sysdyn-1.1/Migration/from1.6to1.7/Spreadsheets";\r
+        public static final String Migration_from1$6to1$7_SysdynChanges = "http://www.simantics.org/Sysdyn-1.1/Migration/from1.6to1.7/SysdynChanges";\r
+        public static final String Migration_fromFunctionLibrary1 = "http://www.simantics.org/Sysdyn-1.1/Migration/fromFunctionLibrary1";\r
+        public static final String Migration_fromModel1 = "http://www.simantics.org/Sysdyn-1.1/Migration/fromModel1";\r
+        public static final String Migration_fromModule1 = "http://www.simantics.org/Sysdyn-1.1/Migration/fromModule1";\r
         public static final String ModelBrowser = "http://www.simantics.org/Sysdyn-1.1/ModelBrowser";\r
         public static final String ModelingActionContext = "http://www.simantics.org/Sysdyn-1.1/ModelingActionContext";\r
         public static final String ModelingActionContext_Actions = "http://www.simantics.org/Sysdyn-1.1/ModelingActionContext/Actions";\r
@@ -1166,14 +1186,19 @@ public class SysdynResource {
         public static final String Right = "http://www.simantics.org/Sysdyn-1.1/Right";\r
         public static final String SelectedSharedFunctionLibraries = "http://www.simantics.org/Sysdyn-1.1/SelectedSharedFunctionLibraries";\r
         public static final String SensitivityAnalysisExperiment = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment";\r
+        public static final String SensitivityAnalysisExperiment_SensitivityDataset = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/SensitivityDataset";\r
         public static final String SensitivityAnalysisExperiment_maxValue = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/maxValue";\r
         public static final String SensitivityAnalysisExperiment_maxValue_Inverse = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/maxValue/Inverse";\r
+        public static final String SensitivityAnalysisExperiment_mean = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/mean";\r
+        public static final String SensitivityAnalysisExperiment_mean_Inverse = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/mean/Inverse";\r
         public static final String SensitivityAnalysisExperiment_minValue = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/minValue";\r
         public static final String SensitivityAnalysisExperiment_minValue_Inverse = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/minValue/Inverse";\r
         public static final String SensitivityAnalysisExperiment_numValues = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/numValues";\r
         public static final String SensitivityAnalysisExperiment_numValues_Inverse = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/numValues/Inverse";\r
         public static final String SensitivityAnalysisExperiment_propabilityDistribution = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/propabilityDistribution";\r
         public static final String SensitivityAnalysisExperiment_propabilityDistribution_Inverse = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/propabilityDistribution/Inverse";\r
+        public static final String SensitivityAnalysisExperiment_stdDeviation = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/stdDeviation";\r
+        public static final String SensitivityAnalysisExperiment_stdDeviation_Inverse = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/stdDeviation/Inverse";\r
         public static final String SensitivityAnalysisExperiment_variedParameter = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/variedParameter";\r
         public static final String SensitivityAnalysisExperiment_variedParameter_Inverse = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/variedParameter/Inverse";\r
         public static final String SharedFunctionOntology = "http://www.simantics.org/Sysdyn-1.1/SharedFunctionOntology";\r
@@ -1193,6 +1218,8 @@ public class SysdynResource {
         public static final String SysdynConnectionType = "http://www.simantics.org/Sysdyn-1.1/SysdynConnectionType";\r
         public static final String SysdynDiagramModelingRules = "http://www.simantics.org/Sysdyn-1.1/SysdynDiagramModelingRules";\r
         public static final String SysdynModel = "http://www.simantics.org/Sysdyn-1.1/SysdynModel";\r
+        public static final String SysdynModel_fmuFile = "http://www.simantics.org/Sysdyn-1.1/SysdynModel/fmuFile";\r
+        public static final String SysdynModel_fmuFile_Inverse = "http://www.simantics.org/Sysdyn-1.1/SysdynModel/fmuFile/Inverse";\r
         public static final String SysdynModel_outputInterval = "http://www.simantics.org/Sysdyn-1.1/SysdynModel/outputInterval";\r
         public static final String SysdynModel_outputInterval_Inverse = "http://www.simantics.org/Sysdyn-1.1/SysdynModel/outputInterval/Inverse";\r
         public static final String SysdynModel_simulationStepLength = "http://www.simantics.org/Sysdyn-1.1/SysdynModel/simulationStepLength";\r
@@ -1318,11 +1345,6 @@ public class SysdynResource {
         public static final String WithLookupExpression_maxY = "http://www.simantics.org/Sysdyn-1.1/WithLookupExpression/maxY";\r
         public static final String WithLookupExpression_minX = "http://www.simantics.org/Sysdyn-1.1/WithLookupExpression/minX";\r
         public static final String WithLookupExpression_minY = "http://www.simantics.org/Sysdyn-1.1/WithLookupExpression/minY";\r
-        public static final String from1$6to1$7 = "http://www.simantics.org/Sysdyn-1.1/from1.6to1.7";\r
-        public static final String from1$6to1$7_Ontologies = "http://www.simantics.org/Sysdyn-1.1/from1.6to1.7/Ontologies";\r
-        public static final String from1$6to1$7_OrderedSetsToLists = "http://www.simantics.org/Sysdyn-1.1/from1.6to1.7/OrderedSetsToLists";\r
-        public static final String from1$6to1$7_Spreadsheets = "http://www.simantics.org/Sysdyn-1.1/from1.6to1.7/Spreadsheets";\r
-        public static final String from1$6to1$7_SysdynChanges = "http://www.simantics.org/Sysdyn-1.1/from1.6to1.7/SysdynChanges";\r
     }\r
     \r
     public static Resource getResourceOrNull(ReadGraph graph, String uri) {\r
@@ -1758,6 +1780,15 @@ public class SysdynResource {
         LookupExpression = getResourceOrNull(graph, URIs.LookupExpression);\r
         LookupExpression_lookup = getResourceOrNull(graph, URIs.LookupExpression_lookup);\r
         LookupExpression_lookup_Inverse = getResourceOrNull(graph, URIs.LookupExpression_lookup_Inverse);\r
+        Migration = getResourceOrNull(graph, URIs.Migration);\r
+        Migration_from1$6to1$7 = getResourceOrNull(graph, URIs.Migration_from1$6to1$7);\r
+        Migration_from1$6to1$7_Ontologies = getResourceOrNull(graph, URIs.Migration_from1$6to1$7_Ontologies);\r
+        Migration_from1$6to1$7_OrderedSetsToLists = getResourceOrNull(graph, URIs.Migration_from1$6to1$7_OrderedSetsToLists);\r
+        Migration_from1$6to1$7_Spreadsheets = getResourceOrNull(graph, URIs.Migration_from1$6to1$7_Spreadsheets);\r
+        Migration_from1$6to1$7_SysdynChanges = getResourceOrNull(graph, URIs.Migration_from1$6to1$7_SysdynChanges);\r
+        Migration_fromFunctionLibrary1 = getResourceOrNull(graph, URIs.Migration_fromFunctionLibrary1);\r
+        Migration_fromModel1 = getResourceOrNull(graph, URIs.Migration_fromModel1);\r
+        Migration_fromModule1 = getResourceOrNull(graph, URIs.Migration_fromModule1);\r
         ModelBrowser = getResourceOrNull(graph, URIs.ModelBrowser);\r
         ModelingActionContext = getResourceOrNull(graph, URIs.ModelingActionContext);\r
         ModelingActionContext_Actions = getResourceOrNull(graph, URIs.ModelingActionContext_Actions);\r
@@ -1834,14 +1865,19 @@ public class SysdynResource {
         Right = getResourceOrNull(graph, URIs.Right);\r
         SelectedSharedFunctionLibraries = getResourceOrNull(graph, URIs.SelectedSharedFunctionLibraries);\r
         SensitivityAnalysisExperiment = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment);\r
+        SensitivityAnalysisExperiment_SensitivityDataset = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_SensitivityDataset);\r
         SensitivityAnalysisExperiment_maxValue = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_maxValue);\r
         SensitivityAnalysisExperiment_maxValue_Inverse = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_maxValue_Inverse);\r
+        SensitivityAnalysisExperiment_mean = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_mean);\r
+        SensitivityAnalysisExperiment_mean_Inverse = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_mean_Inverse);\r
         SensitivityAnalysisExperiment_minValue = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_minValue);\r
         SensitivityAnalysisExperiment_minValue_Inverse = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_minValue_Inverse);\r
         SensitivityAnalysisExperiment_numValues = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_numValues);\r
         SensitivityAnalysisExperiment_numValues_Inverse = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_numValues_Inverse);\r
         SensitivityAnalysisExperiment_propabilityDistribution = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_propabilityDistribution);\r
         SensitivityAnalysisExperiment_propabilityDistribution_Inverse = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_propabilityDistribution_Inverse);\r
+        SensitivityAnalysisExperiment_stdDeviation = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_stdDeviation);\r
+        SensitivityAnalysisExperiment_stdDeviation_Inverse = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_stdDeviation_Inverse);\r
         SensitivityAnalysisExperiment_variedParameter = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_variedParameter);\r
         SensitivityAnalysisExperiment_variedParameter_Inverse = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_variedParameter_Inverse);\r
         SharedFunctionOntology = getResourceOrNull(graph, URIs.SharedFunctionOntology);\r
@@ -1861,6 +1897,8 @@ public class SysdynResource {
         SysdynConnectionType = getResourceOrNull(graph, URIs.SysdynConnectionType);\r
         SysdynDiagramModelingRules = getResourceOrNull(graph, URIs.SysdynDiagramModelingRules);\r
         SysdynModel = getResourceOrNull(graph, URIs.SysdynModel);\r
+        SysdynModel_fmuFile = getResourceOrNull(graph, URIs.SysdynModel_fmuFile);\r
+        SysdynModel_fmuFile_Inverse = getResourceOrNull(graph, URIs.SysdynModel_fmuFile_Inverse);\r
         SysdynModel_outputInterval = getResourceOrNull(graph, URIs.SysdynModel_outputInterval);\r
         SysdynModel_outputInterval_Inverse = getResourceOrNull(graph, URIs.SysdynModel_outputInterval_Inverse);\r
         SysdynModel_simulationStepLength = getResourceOrNull(graph, URIs.SysdynModel_simulationStepLength);\r
@@ -1986,11 +2024,6 @@ public class SysdynResource {
         WithLookupExpression_maxY = getResourceOrNull(graph, URIs.WithLookupExpression_maxY);\r
         WithLookupExpression_minX = getResourceOrNull(graph, URIs.WithLookupExpression_minX);\r
         WithLookupExpression_minY = getResourceOrNull(graph, URIs.WithLookupExpression_minY);\r
-        from1$6to1$7 = getResourceOrNull(graph, URIs.from1$6to1$7);\r
-        from1$6to1$7_Ontologies = getResourceOrNull(graph, URIs.from1$6to1$7_Ontologies);\r
-        from1$6to1$7_OrderedSetsToLists = getResourceOrNull(graph, URIs.from1$6to1$7_OrderedSetsToLists);\r
-        from1$6to1$7_Spreadsheets = getResourceOrNull(graph, URIs.from1$6to1$7_Spreadsheets);\r
-        from1$6to1$7_SysdynChanges = getResourceOrNull(graph, URIs.from1$6to1$7_SysdynChanges);\r
     }\r
     \r
     public static SysdynResource getInstance(ReadGraph graph) {\r
index 179907b0d1286ea7fe9f2f8c117d84ee31cddeae..a3b6f6917be74815950391228f2a89dcf1f2af51 100644 (file)
@@ -10,5 +10,5 @@
         VTT Technical Research Centre of Finland - initial API and implementation\r
  -->\r
 
-<adapters>\r\r   <target interface="org.simantics.db.layer0.adapter.Realization">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/Module"\r                 class="org.simantics.structural2.realization.StructuralRealization">\r                   <this />\r               </type>\r        </target>\r\r     <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r      <type uri = "http://www.simantics.org/Sysdyn-0.0/DiagramToCompositeMapping"\r          class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r         <graph/>\r           <this />\r       </type>\r        </target>\r      \r       <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                    class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r                      <this />\r               </type>\r        </target>               \r               \r\r      <target\r                interface="org.simantics.browsing.ui.common.node.AbstractNode">\r                <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                  class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r                       <this />\r               </type>\r\r               <resource\r                      uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                 class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r                      <this />\r               </resource>\r\r           <type\r                  uri="http://www.simantics.org/Simulation-0.0/Experiment"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r                  <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/Result"\r                       class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r                    <this />\r               </type>\r                \r       </target>\r\r     <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r       <target interface="org.simantics.g2d.diagram.DiagramClass">\r            <adapter uri="http://www.simantics.org/Sysdyn-0.0/ConfigurationDiagram"\r                        adapterClass="org.simantics.sysdyn.ui.elements.ConfigurationDiagramClassAdapter" />\r    </target>\r\r     <!-- Sysdyn symbols -->\r        <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                        class="org.simantics.sysdyn.ui.elements.StockFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements.ModuleFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements.ValveFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements.AuxiliaryFactory" />\r           <resource uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements.CloudFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements.InputFactory" />\r\r              <type uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements.StockFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements.ModuleFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements.ValveFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements.AuxiliaryFactory" />\r           <type uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements.CloudFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements.InputFactory" />                        \r       </target>\r      \r       <!-- Additional symbols -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r          <resource uri="http://www.simantics.org/Sysdyn-0.0/AdditionalSymbols/MultilineText"\r            class="org.simantics.sysdyn.ui.elements.MultilineTextElementFactory" />\r        <type uri="http://www.simantics.org/Sysdyn-0.0/AdditionalSymbols/MultilineText"\r            class="org.simantics.sysdyn.ui.elements.MultilineTextElementFactory" />         \r    </target>                  \r       \r       <!-- Sysdyn connections -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <!-- Edges -->       \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements.connections.RouteFlowEdgeFactory" />\r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements.connections.RouteFlowEdgeFactory" />            \r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements.connections.RouteFlowConnectionFactory">\r            <graph/>\r        </type>                          \r                       \r               <resource uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements.connections.DependencyEdgeFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements.connections.DependencyEdgeFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements.connections.DependencyConnectionFactory" />\r    </target>\r      \r       <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r          <baseType uri="http://www.simantics.org/Diagram-0.0/HasConnector" />\r   <resource uri="http://www.simantics.org/Diagram-0.0/HasPlainConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>none 0</string>\r       </resource>\r    <resource uri="http://www.simantics.org/Diagram-0.0/HasArrowConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>fill 1</string>\r       </resource>\r  </target>\r      \r       <!-- ModelBrowser2 -->\r \r       <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleTypeChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleContentChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleContentChildRule"/>              \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.VariableChildRule"/>                  \r                  \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/HistoryDataset/HistoryDatasetVariablesBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.historyDataset.VariableChildRule"/>     \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterChildRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterChildRule"/>               \r    </target>\r    \r    <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleTypeLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.ModuleTypeLabelRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/VariableNameLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.VariableNameLabelRule"/>\r\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/VariableImageRule"\r            class="org.simantics.sysdyn.ui.browser.imagerules.VariableImageRule"/>   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ChartImageRule"\r            class="org.simantics.sysdyn.ui.browser.imagerules.ChartImageRule"/>      \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ResultImageRule"\r            class="org.simantics.sysdyn.ui.browser.imagerules.ResultImageRule"/>                        \r            \r  \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/HistoryDataset/HistoryDatasetVariablesBrowseContext/VariableLabelRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.historyDataset.VariableLabelRule"/>                \r\r            \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterLabelRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterLabelRule"/>    \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterLabelDecorationRule"/>               \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterModifierRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterModifierRule"/>    \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterSorterRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterSorterRule"/>                                      \r    </target>    \r    \r    <target interface="org.simantics.db.layer0.adapter.ActionFactory">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewModuleType"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewModuleTypeAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewEnumeration"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewEnumerationAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewFunction"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewFunctionAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewFunctionLibraryAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewSharedFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewSharedFunctionLibraryAction" />   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewExperiment"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewExperimentAction" />   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewSimulationPlaybackExperiment"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewSimulationPlaybackExperimentAction" />    \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewLineChart"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewLineChartAction" /> \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewBarChart"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewBarChartAction" /> \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewPieChart"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewPieChartAction" />        \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewSheet"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewSheetAction" />       \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewHistoryData"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewHistoryDataAction" />                                                                                              \r    </target>         \r    \r   <target interface="org.simantics.db.layer0.adapter.DropActionFactory">\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/FunctionDropAction"\r            class="org.simantics.sysdyn.ui.browser.actions.drop.FunctionDropAction" />\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/ChartDropAction"\r            class="org.simantics.sysdyn.ui.browser.actions.drop.ChartDropAction" />            \r   \r                    \r    </target>     \r  \r    <target interface="org.simantics.db.layer0.adapter.Remover">\r        <type uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleSymbol"\r            class="org.simantics.sysdyn.ui.browser.actions.remove.ModuleTypeRemover">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/Sysdyn-0.0/Variable"\r            class="org.simantics.sysdyn.ui.actions.SysdynVariableRemover">\r            <this />\r        </type>\r    </target>\r    \r    \r    <target interface="org.simantics.browsing.ui.model.nodetypes.NodeType">\r        <baseType uri="http://www.simantics.org/Layer0-0.0/Entity" />\r        <type\r            uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleSymbolNodeType"\r            class="org.simantics.sysdyn.ui.browser.nodeTypes.ModuleSymbolNodeType"\r            constructor="create">\r            <this/>\r        </type>        \r     </target>\r    \r  <!-- PROFILES -->\r    <target interface="org.simantics.scenegraph.profile.Style">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/SimulationPlaybackStyle"\r            class="org.simantics.sysdyn.ui.elements.profiles.SimulationPlaybackStyle">\r        </resource>\r                <resource uri="http://www.simantics.org/Sysdyn-0.0/IssueStyle"\r            class="org.simantics.sysdyn.ui.elements.profiles.IssueDecorationStyle">\r        </resource>\r    </target>\r    \r \r    <!--  TODO: currently maps jfree concepts directly to Sysdyn implementations. Sysdyn needs tool specific types for the datasets. -->\r    <!--  TODO: AllVariablesOfModel query is run on random Resources; listing all possible types explicitly is cumbersome, we need a better implementation. -->\r    <target interface="org.simantics.jfreechart.chart.properties.IAllVariablesOfModel">  \r        <type uri="http://www.simantics.org/Sysdyn-1.1/SysdynModel"\r            class="org.simantics.sysdyn.ui.trend.AllVariablesOfModel">\r            <this />\r        </type>  \r        <type uri="http://www.simantics.org/JFreeChart-1.0/NumberAxis"\r            class="org.simantics.sysdyn.ui.trend.AllVariablesOfModel">\r            <this />\r        </type>   \r        <type uri="http://www.simantics.org/JFreeChart-1.0/Series"\r            class="org.simantics.sysdyn.ui.trend.AllVariablesOfModel">\r            <this />\r        </type>      \r    </target> \r       \r    <target interface="org.simantics.jfreechart.chart.properties.RangeHandlerFactory">  \r        <type uri="http://www.simantics.org/Sysdyn-1.1/SysdynModel"\r            class="org.simantics.sysdyn.ui.trend.SysdynRangeHandlerFactory">\r        </type>        \r    </target> \r    \r    <!--  TODO: currently maps jfree concepts directly to Sysdyn implementations. Sysdyn needs tool specific types for the datasets. -->\r     <target interface="org.simantics.jfreechart.chart.IDataset">\r        <type uri="http://www.simantics.org/JFreeChart-0.0/XYDataset"\r            class="org.simantics.sysdyn.ui.trend.XYDataset">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-0.0/CategoryDataset"\r            class="org.simantics.sysdyn.ui.trend.CategoryDataset">\r            <graph />\r            <this />\r        </type>        \r        <type uri="http://www.simantics.org/JFreeChart-0.0/PieDataset"\r            class="org.simantics.sysdyn.ui.trend.PieDataset">\r            <graph />\r            <this />\r        </type>          \r    </target>\r
+<adapters>\r\r   <target interface="org.simantics.db.layer0.adapter.Realization">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/Module"\r                 class="org.simantics.structural2.realization.StructuralRealization">\r                   <this />\r               </type>\r        </target>\r\r     <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r      <type uri = "http://www.simantics.org/Sysdyn-0.0/DiagramToCompositeMapping"\r          class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r         <graph/>\r           <this />\r       </type>\r        </target>\r      \r       <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                    class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r                      <this />\r               </type>\r        </target>               \r               \r\r      <target\r                interface="org.simantics.browsing.ui.common.node.AbstractNode">\r                <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                  class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r                       <this />\r               </type>\r\r               <resource\r                      uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                 class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r                      <this />\r               </resource>\r\r           <type\r                  uri="http://www.simantics.org/Simulation-0.0/Experiment"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r                  <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/Result"\r                       class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r                    <this />\r               </type>\r                \r       </target>\r\r     <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r       <target interface="org.simantics.g2d.diagram.DiagramClass">\r            <adapter uri="http://www.simantics.org/Sysdyn-0.0/ConfigurationDiagram"\r                        adapterClass="org.simantics.sysdyn.ui.elements.ConfigurationDiagramClassAdapter" />\r    </target>\r\r     <!-- Sysdyn symbols -->\r        <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                        class="org.simantics.sysdyn.ui.elements.StockFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements.ModuleFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements.ValveFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements.AuxiliaryFactory" />\r           <resource uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements.CloudFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements.InputFactory" />\r\r              <type uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements.StockFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements.ModuleFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements.ValveFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements.AuxiliaryFactory" />\r           <type uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements.CloudFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements.InputFactory" />                        \r       </target>\r      \r       <!-- Additional symbols -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r          <resource uri="http://www.simantics.org/Sysdyn-0.0/AdditionalSymbols/MultilineText"\r            class="org.simantics.sysdyn.ui.elements.MultilineTextElementFactory" />\r        <type uri="http://www.simantics.org/Sysdyn-0.0/AdditionalSymbols/MultilineText"\r            class="org.simantics.sysdyn.ui.elements.MultilineTextElementFactory" />         \r    </target>                  \r       \r       <!-- Sysdyn connections -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <!-- Edges -->       \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements.connections.RouteFlowEdgeFactory" />\r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements.connections.RouteFlowEdgeFactory" />            \r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements.connections.RouteFlowConnectionFactory">\r            <graph/>\r        </type>                          \r                       \r               <resource uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements.connections.DependencyEdgeFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements.connections.DependencyEdgeFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements.connections.DependencyConnectionFactory" />\r    </target>\r      \r       <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r          <baseType uri="http://www.simantics.org/Diagram-0.0/HasConnector" />\r   <resource uri="http://www.simantics.org/Diagram-0.0/HasPlainConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>none 0</string>\r       </resource>\r    <resource uri="http://www.simantics.org/Diagram-0.0/HasArrowConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>fill 1</string>\r       </resource>\r  </target>\r      \r       <!-- ModelBrowser2 -->\r \r       <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleTypeChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleContentChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleContentChildRule"/>              \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.VariableChildRule"/>                  \r                  \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/HistoryDataset/HistoryDatasetVariablesBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.historyDataset.VariableChildRule"/>     \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterChildRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterChildRule"/>               \r    </target>\r    \r    <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleTypeLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.ModuleTypeLabelRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/VariableNameLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.VariableNameLabelRule"/>\r\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/VariableImageRule"\r            class="org.simantics.sysdyn.ui.browser.imagerules.VariableImageRule"/>   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ChartImageRule"\r            class="org.simantics.sysdyn.ui.browser.imagerules.ChartImageRule"/>      \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ResultImageRule"\r            class="org.simantics.sysdyn.ui.browser.imagerules.ResultImageRule"/>                        \r            \r  \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/HistoryDataset/HistoryDatasetVariablesBrowseContext/VariableLabelRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.historyDataset.VariableLabelRule"/>                \r\r            \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterLabelRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterLabelRule"/>    \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterLabelDecorationRule"/>               \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterModifierRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterModifierRule"/>    \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterSorterRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterSorterRule"/>                                      \r    </target>    \r    \r    <target interface="org.simantics.db.layer0.adapter.ActionFactory">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewModuleType"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewModuleTypeAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewEnumeration"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewEnumerationAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewFunction"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewFunctionAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewFunctionLibraryAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewSharedFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewSharedFunctionLibraryAction" />   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewExperiment"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewExperimentAction" />   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewSimulationPlaybackExperiment"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewSimulationPlaybackExperimentAction" />    \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewLineChart"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewLineChartAction" /> \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewBarChart"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewBarChartAction" /> \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewPieChart"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewPieChartAction" />        \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewSheet"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewSheetAction" />       \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewHistoryData"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewHistoryDataAction" />                                                                                              \r    </target>         \r    \r   <target interface="org.simantics.db.layer0.adapter.DropActionFactory">\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/FunctionDropAction"\r            class="org.simantics.sysdyn.ui.browser.actions.drop.FunctionDropAction" />\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/ChartDropAction"\r            class="org.simantics.sysdyn.ui.browser.actions.drop.ChartDropAction" />            \r   \r                    \r    </target>     \r  \r    <target interface="org.simantics.db.layer0.adapter.Remover">\r        <type uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleSymbol"\r            class="org.simantics.sysdyn.ui.browser.actions.remove.ModuleTypeRemover">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/Sysdyn-0.0/Variable"\r            class="org.simantics.sysdyn.ui.actions.SysdynVariableRemover">\r            <this />\r        </type>\r    </target>\r    \r    \r    <target interface="org.simantics.browsing.ui.model.nodetypes.NodeType">\r        <baseType uri="http://www.simantics.org/Layer0-0.0/Entity" />\r        <type\r            uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleSymbolNodeType"\r            class="org.simantics.sysdyn.ui.browser.nodeTypes.ModuleSymbolNodeType"\r            constructor="create">\r            <this/>\r        </type>        \r     </target>\r    \r  <!-- PROFILES -->\r    <target interface="org.simantics.scenegraph.profile.Style">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/SimulationPlaybackStyle"\r            class="org.simantics.sysdyn.ui.elements.profiles.SimulationPlaybackStyle">\r        </resource>\r                <resource uri="http://www.simantics.org/Sysdyn-0.0/IssueStyle"\r            class="org.simantics.sysdyn.ui.elements.profiles.IssueDecorationStyle">\r        </resource>\r    </target>\r    \r \r    <!--  TODO: currently maps jfree concepts directly to Sysdyn implementations. Sysdyn needs tool specific types for the datasets. -->\r    <!--  TODO: AllVariablesOfModel query is run on random Resources; listing all possible types explicitly is cumbersome, we need a better implementation. -->\r    <target interface="org.simantics.jfreechart.chart.properties.IAllVariablesOfModel">  \r        <type uri="http://www.simantics.org/Sysdyn-1.1/SysdynModel"\r            class="org.simantics.sysdyn.ui.trend.AllVariablesOfModel">\r            <this />\r        </type>  \r        <type uri="http://www.simantics.org/JFreeChart-1.0/NumberAxis"\r            class="org.simantics.sysdyn.ui.trend.AllVariablesOfModel">\r            <this />\r        </type>   \r        <type uri="http://www.simantics.org/JFreeChart-1.0/Series"\r            class="org.simantics.sysdyn.ui.trend.AllVariablesOfModel">\r            <this />\r        </type>      \r    </target> \r       \r    <target interface="org.simantics.jfreechart.chart.properties.RangeHandlerFactory">  \r        <type uri="http://www.simantics.org/Sysdyn-1.1/SysdynModel"\r            class="org.simantics.sysdyn.ui.trend.SysdynRangeHandlerFactory">\r        </type>        \r    </target> \r    \r    <!--  TODO: currently maps jfree concepts directly to Sysdyn implementations. Sysdyn needs tool specific types for the datasets. -->\r     <target interface="org.simantics.jfreechart.chart.IDataset">\r        <type uri="http://www.simantics.org/JFreeChart-0.0/XYDataset"\r            class="org.simantics.sysdyn.ui.trend.XYDataset">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-0.0/CategoryDataset"\r            class="org.simantics.sysdyn.ui.trend.CategoryDataset">\r            <graph />\r            <this />\r        </type>        \r        <type uri="http://www.simantics.org/JFreeChart-0.0/PieDataset"\r            class="org.simantics.sysdyn.ui.trend.PieDataset">\r            <graph />\r            <this />\r        </type>   \r        <type uri="http://www.simantics.org/Sysdyn-0.0/SensitivityAnalysisExperiment/SensitivityDataset"\r            class="org.simantics.sysdyn.ui.trend.SensitivityDataset">\r            <graph />\r            <this />\r        </type>\r    </target>\r
 </adapters>
\ No newline at end of file
diff --git a/simantics-1.10/org.simantics.sysdyn.ui/icons/bullet_gray.png b/simantics-1.10/org.simantics.sysdyn.ui/icons/bullet_gray.png
new file mode 100644 (file)
index 0000000..6f58b93
Binary files /dev/null and b/simantics-1.10/org.simantics.sysdyn.ui/icons/bullet_gray.png differ
diff --git a/simantics-1.10/org.simantics.sysdyn.ui/icons/bullet_green.png b/simantics-1.10/org.simantics.sysdyn.ui/icons/bullet_green.png
new file mode 100644 (file)
index 0000000..1b5409f
Binary files /dev/null and b/simantics-1.10/org.simantics.sysdyn.ui/icons/bullet_green.png differ
index 46659c965039766eb0bc50c63137f82e1c430c7f..b03868c116dfe0c64b47893a40690125940a899f 100644 (file)
                   </with>\r
                </visibleWhen>\r
             </command>\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.newSensitivityChart"\r
+                  icon="platform:/plugin/com.famfamfam.silk/icons/chart_line.png"\r
+                  id="org.simantics.sysdyn.ui.browser.newSensitivityChart"\r
+                  label="Sensitivity Chart"\r
+                  style="push">\r
+               <visibleWhen\r
+                     checkEnabled="true">\r
+                  <with\r
+                        variable="selection">\r
+                     <test\r
+                           args="org.simantics.sysdyn.ui.browser.nodes.ChartsFolder"\r
+                           property="org.simantics.sysdyn.ui.nodeClass">\r
+                     </test>\r
+                  </with>\r
+               </visibleWhen>\r
+            </command>\r
             <command\r
                   commandId="org.simantics.sysdyn.ui.newHistoryData"\r
                   icon="platform:/plugin/com.famfamfam.silk/icons/table.png"\r
             id="org.simantics.sysdyn.ui.newPieChart"\r
             name="New Pie Chart">\r
       </command>\r
+      <command\r
+            defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewSensitivityChartHandler"\r
+            id="org.simantics.sysdyn.ui.newSensitivityChart"\r
+            name="New XY Line Chart">\r
+      </command>      \r
       <command\r
             defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewHistoryDataHandler"\r
             id="org.simantics.sysdyn.ui.newHistoryData"\r
index 43a558969a35b7813e14a96915985560c7977bdd..e518828c79a3603e0720e880aa0c9ab7fa1d8a9d 100644 (file)
@@ -120,7 +120,7 @@ public class CreateVariablesShortcutParticipant extends AbstractDiagramParticipa
                        \r
                        kpe = (KeyPressedEvent) ke;\r
                        \r
-                       if (kpe.stateMask != java.awt.event.KeyEvent.SHIFT_DOWN_MASK || isEditing()) \r
+                       if (!kpe.isShiftDown() || isEditing()) \r
                                return false;\r
                        \r
                        if (kpe.keyCode == java.awt.event.KeyEvent.VK_A) {\r
index 3171cc787f70d2a325f30ce97b3b78b35857690e..88aa7eb72e68837fd5c5c2db8fde7b8784d538d6 100644 (file)
@@ -31,7 +31,7 @@ import org.simantics.layer0.utils.direct.GraphUtils;
 import org.simantics.sysdyn.JFreeChartResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.ChartsFolder;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
  * Handler for creating a new Bar Chart\r
index 5a50ffba2c47eda2c84f7294b21d835a0441e08e..0ddf1a3b8ea2295c99bc7f38acdbadd73bc0934a 100644 (file)
@@ -29,7 +29,7 @@ import org.simantics.layer0.utils.direct.GraphUtils;
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
  * Creates a new normal SysDyn experiment\r
index 67ddc56b98cc323b578d72acef3e50a98d02d5b9..7acab21ed23d06b97e2f3693b2e9cedd7f441ba3 100644 (file)
@@ -26,7 +26,7 @@ import org.simantics.layer0.Layer0;
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
  * Creates a new function to a SysdynModel or Library.\r
index 978137a5a247f95d7a3f3368927f1276a6ceb59c..bf62f3efdf04d739becd531ae55e2af1c4fdf0c9 100644 (file)
@@ -27,7 +27,7 @@ import org.simantics.layer0.Layer0;
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
  * Creates a new function library to a model or other library.\r
index 09d7beb002a89a40c992181ac8bd5fbbfd1d57f9..d97b684548dbde15b11d7140aa062d5544864002 100644 (file)
@@ -27,7 +27,7 @@ import org.simantics.layer0.Layer0;
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
  * Handler for creating new history dataset\r
index 3aa9e5f7977062bb31cc7f373d6640f8ba9d18c7..60170f7eccc9fd459d52038d5cbc47bde51aae0f 100644 (file)
@@ -33,7 +33,7 @@ import org.simantics.sysdyn.SysdynResource;
 import org.simantics.sysdyn.ui.browser.actions.newActions.NewModuleTypeAction;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 import org.simantics.utils.datastructures.ArrayMap;\r
 \r
 /**\r
index 516e49f959301306550f34f4abd668e9ffd2c40b..3f17f995c7bbaf5e9457bec76e12c6845988a069 100644 (file)
@@ -31,7 +31,7 @@ import org.simantics.layer0.utils.direct.GraphUtils;
 import org.simantics.sysdyn.JFreeChartResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.ChartsFolder;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
  * Handler for craeting a new Pie Chart\r
index 26d63daf72e02dc74757de54efd4045bd21829fb..8c8c00b6acad6ed975e6a05ce91c5f7dfba347d3 100644 (file)
@@ -32,6 +32,8 @@ public class NewSensitivityAnalysisExperimentNodeHandler extends NewExperimentNo
         graph.claimLiteral(experiment, sr.SensitivityAnalysisExperiment_minValue, SysdynSensitivityAnalysisExperiment.DEFAULT_MIN_VALUE);\r
         graph.claimLiteral(experiment, sr.SensitivityAnalysisExperiment_maxValue, SysdynSensitivityAnalysisExperiment.DEFAULT_MAX_VALUE);\r
         graph.claimLiteral(experiment, sr.SensitivityAnalysisExperiment_numValues, SysdynSensitivityAnalysisExperiment.DEFAULT_NUM_VALUES);\r
+        graph.claimLiteral(experiment, sr.SensitivityAnalysisExperiment_mean, SysdynSensitivityAnalysisExperiment.DEFAULT_MEAN);\r
+        graph.claimLiteral(experiment, sr.SensitivityAnalysisExperiment_stdDeviation, SysdynSensitivityAnalysisExperiment.DEFAULT_STD_DEVIATION);\r
         graph.claimLiteral(experiment, sr.SensitivityAnalysisExperiment_propabilityDistribution, "uniform");\r
     }\r
 \r
diff --git a/simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSensitivityChartHandler.java b/simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSensitivityChartHandler.java
new file mode 100644 (file)
index 0000000..824ba4b
--- /dev/null
@@ -0,0 +1,105 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.UUID;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.ListUtils;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.stubs.G2DResource;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.ChartsFolder;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
+\r
+public class NewSensitivityChartHandler extends AbstractHandler {\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+\r
+\r
+        ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+\r
+        ChartsFolder node = AdaptionUtils.adaptToSingle(sel, ChartsFolder.class);\r
+        if (node == null)\r
+            return null;\r
+\r
+        final Resource model = node.data;        \r
+\r
+        SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+            @Override\r
+            public void perform(WriteGraph g) throws DatabaseException {\r
+                Layer0 l0 = Layer0.getInstance(g);\r
+                JFreeChartResource jfree = JFreeChartResource.getInstance(g);\r
+                G2DResource g2d = G2DResource.getInstance(g);\r
+\r
+                Resource jfreechart = GraphUtils.create2(g, jfree.Chart,\r
+                        l0.HasName, "SensitivityChart" + UUID.randomUUID().toString(),\r
+                        l0.HasLabel, NameUtils.findFreshLabel(g, "SensitivityChart", model),\r
+                        l0.PartOf, model,\r
+                        jfree.Chart_visibleBorder, true,\r
+                        jfree.Chart_borderWidth, 3);\r
+                g.claimLiteral(jfreechart, jfree.Chart_borderColor, g2d.Color, new float[] {0,0,0,1});\r
+\r
+                GraphUtils.create2(g, jfree.TextTitle,\r
+                        l0.HasName, "TextTitle" + UUID.randomUUID().toString(),\r
+                        l0.HasLabel, "Chart Title",\r
+                        jfree.Title_position, jfree.Top,\r
+                        l0.PartOf, jfreechart);\r
+\r
+                Resource domainAxis = GraphUtils.create2(g, jfree.NumberAxis,\r
+                        l0.HasName, "NumberAxis" + UUID.randomUUID().toString());\r
+                Resource rangeAxis = GraphUtils.create2(g, jfree.NumberAxis,\r
+                        l0.HasName, "NumberAxis" + UUID.randomUUID().toString(),\r
+                        l0.HasLabel, "Y-axis");\r
+\r
+                Resource renderer = GraphUtils.create2(g, jfree.DeviationRenderer);\r
+\r
+                Resource dataset = GraphUtils.create2(g, SysdynResource.getInstance(g).SensitivityAnalysisExperiment_SensitivityDataset,\r
+                        l0.HasName, "SensitivityDataset" + UUID.randomUUID().toString(),\r
+                        jfree.Dataset_mapToDomainAxis, domainAxis,\r
+                        jfree.Dataset_mapToRangeAxis, rangeAxis,\r
+                        jfree.Dataset_seriesList, ListUtils.create(g, new ArrayList<Resource>()),\r
+                        jfree.Dataset_renderer, renderer);\r
+\r
+                GraphUtils.create2(g, jfree.XYPlot,\r
+                        l0.HasName, "XYPlot" + UUID.randomUUID().toString(),\r
+                        l0.PartOf, jfreechart,\r
+                        jfree.Plot_domainAxis, domainAxis,\r
+                        jfree.Plot_rangeAxis, rangeAxis,\r
+                        jfree.Plot_rangeAxisList, ListUtils.create(g, Collections.singletonList(rangeAxis)),\r
+                        l0.ConsistsOf, dataset,\r
+                        l0.ConsistsOf, domainAxis,\r
+                        l0.ConsistsOf, rangeAxis);\r
+            }\r
+\r
+        });\r
+\r
+\r
+\r
+        return null;\r
+    }\r
+}
\ No newline at end of file
index 5eba69cdfeea749ea5c91dfefe62815530a8f0a1..ab79d1f8ce29eaff9337a6a0fce426cef8b6087c 100644 (file)
@@ -17,7 +17,7 @@ import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.ui.handlers.HandlerUtil;\r
 import org.simantics.browsing.ui.common.node.AbstractNode;\r
 import org.simantics.db.Resource;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
  * Creates a new shared function library.\r
index c2aac24458cdd5cb040736d7f1644eca084c2101..bb872cf21c7341e2ea27e0195333638811be4e42 100644 (file)
@@ -32,7 +32,7 @@ import org.simantics.layer0.utils.direct.GraphUtils;
 import org.simantics.sysdyn.JFreeChartResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.ChartsFolder;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
  * Handler for creating a new XYLineChart in model browser\r
index c4c92ac28bfbbb9cda2ee59a58a29b186a99622a..0b5b3d6874298ea6eda73590a88c56869ed30baa 100644 (file)
@@ -68,6 +68,9 @@ public class ModuleInputTab extends LabelPropertyTabContributor {
                 if(instanceOf == null) return result;\r
                 Resource configuration = graph.getSingleObject(instanceOf, sr2.IsDefinedBy);\r
                 for(Resource input : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.Input))) {\r
+                    if(!graph.getObjects(input, sr.Variable_isHeadOf).isEmpty())\r
+                        continue; // Only inputs with tail dependencies allowed.\r
+                    \r
                     Resource dependency = null;\r
                     for(Resource dep : graph.getObjects(module, sr.Variable_isHeadOf)) {\r
                         Resource refersTo = graph.getPossibleObject(dep, sr.Dependency_refersTo);\r
index 701e0cb86a12c9a5a16c720e65aef4f1e3b6d146..f3caa587f0dba0ca95494a73064560b1349e64bc 100644 (file)
@@ -104,6 +104,26 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo
         numValues.setInputValidator(new IntegerValidator());\r
         numValues.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), numValues.getWidget())));\r
         \r
+        // mean\r
+        label = new Label(composite, SWT.NONE);\r
+        label.setText("Mean");\r
+        \r
+        TrackedText mean = new TrackedText(composite, support, SWT.BORDER);\r
+        mean.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.SensitivityAnalysisExperiment_mean));\r
+        mean.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.SensitivityAnalysisExperiment_mean));\r
+        mean.setInputValidator(new DoubleValidator());\r
+        mean.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), mean.getWidget())));\r
+       \r
+        // standard deviation\r
+        label = new Label(composite, SWT.NONE);\r
+        label.setText("Standard deviation");\r
+        \r
+        TrackedText stdDeviation = new TrackedText(composite, support, SWT.BORDER);\r
+        stdDeviation.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.SensitivityAnalysisExperiment_stdDeviation));\r
+        stdDeviation.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.SensitivityAnalysisExperiment_stdDeviation));\r
+        stdDeviation.setInputValidator(new DoubleValidator());\r
+        stdDeviation.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), stdDeviation.getWidget())));\r
+       \r
         // Scrolled composite settings\r
         sc.setContent(composite);\r
         sc.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));\r
index 23ef6ea14767dc9f23292c7885723a37eb36b228..0c8d1c6343f41727b08c8197cb3c6c1ff0e4e083 100644 (file)
@@ -138,7 +138,7 @@ public class StockExpression implements IExpression {
     @Override\r
     public void save(final Resource expression, Map<String, Object> data) {\r
         final String currentText = this.expression.getExpression();\r
-        if(currentText != null) {\r
+        if(currentText != null && !currentText.equals(data.get("initialEquation"))) {\r
             SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
 \r
                 @Override\r
diff --git a/simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SensitivityDataset.java b/simantics-1.10/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SensitivityDataset.java
new file mode 100644 (file)
index 0000000..970185e
--- /dev/null
@@ -0,0 +1,189 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.trend;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Paint;\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+\r
+import javax.swing.SwingUtilities;\r
+\r
+import org.jfree.chart.ChartColor;\r
+import org.jfree.chart.renderer.AbstractRenderer;\r
+import org.jfree.chart.renderer.xy.DeviationRenderer;\r
+import org.jfree.data.general.Dataset;\r
+import org.jfree.data.xy.YIntervalSeries;\r
+import org.jfree.data.xy.YIntervalSeriesCollection;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.procedure.adapter.DisposableListener;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.jfreechart.chart.IRenderer;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class SensitivityDataset extends XYDataset {\r
+\r
+    DeviationRenderer renderer;\r
+    \r
+    public SensitivityDataset(ReadGraph graph, Resource resource) throws DatabaseException {\r
+        super(graph, resource);\r
+    }\r
+\r
+    @Override\r
+    public Dataset getDataset() {\r
+        if(dataset == null) {\r
+            dataset = new YIntervalSeriesCollection();\r
+        }   \r
+\r
+        if(datasetListener == null || datasetListener.isDisposed()) {\r
+            SimanticsUI.getSession().asyncRequest(getDatasetRequest(), getDatasetListener()); \r
+        }\r
+\r
+        if(timeListener == null || timeListener.isDisposed()) {\r
+            SimanticsUI.getSession().asyncRequest(getTimeRequest(), getTimeListener());\r
+        }\r
+        return dataset;\r
+    }\r
+\r
+    @Override\r
+    public AbstractRenderer getRenderer() {\r
+        if(renderer == null)\r
+            renderer = new DeviationRenderer(true, false);\r
+        return renderer;\r
+    }\r
+    \r
+    @Override\r
+    protected DisposableListener<Pair<ArrayList<TempSeries>, IRenderer>> getDatasetListener() {\r
+        if(datasetListener == null || datasetListener.isDisposed()) {\r
+            datasetListener = new SensitivityDatasetListener();\r
+        }\r
+        return datasetListener;\r
+    }\r
+\r
+    private class SensitivityDatasetListener extends DisposableListener<Pair<ArrayList<TempSeries>, IRenderer>> {\r
+\r
+        @Override\r
+        public void execute(Pair<ArrayList<TempSeries>, IRenderer> result) {\r
+            final ArrayList<TempSeries> series = result.first;\r
+            \r
+            // Modify series in AWT thread to avoid synchronization problems\r
+            SwingUtilities.invokeLater(new Runnable() {\r
+\r
+                @Override\r
+                public void run() {\r
+\r
+                    if(dataset == null || !(dataset instanceof YIntervalSeriesCollection))\r
+                        return;\r
+                    \r
+                    YIntervalSeriesCollection ds = (YIntervalSeriesCollection)dataset;\r
+\r
+                    DeviationRenderer dr = (DeviationRenderer)getRenderer();\r
+                    Paint[] paints = {\r
+                            ChartColor.LIGHT_RED,\r
+                            ChartColor.LIGHT_YELLOW,\r
+                            ChartColor.LIGHT_GREEN,\r
+                            ChartColor.LIGHT_BLUE,\r
+                            ChartColor.LIGHT_GRAY\r
+                            };\r
+                    for(int i = 0; i < paints.length; i++) {\r
+                        dr.setSeriesStroke(i, new BasicStroke(2F, 1, 1));\r
+                        dr.setSeriesPaint(i, paints[i]);\r
+                        dr.setSeriesFillPaint(i, paints[i]);\r
+                    }\r
+                    dr.setAlpha(1);\r
+                    \r
+                    // Remove all series\r
+                    for(int i = ds.getSeriesCount() - 1; i >= 0; i-- ) {\r
+                        ds.removeSeries(ds.getSeries(i));\r
+                    }\r
+                    \r
+                    int n = series.size();\r
+                    if(n < 1)\r
+                        return;\r
+                    \r
+                    int length = series.get(0).values[0].length;\r
+                    \r
+                    YIntervalSeries median = new YIntervalSeries("Median");\r
+                    YIntervalSeries p100 = new YIntervalSeries("100%");\r
+                    YIntervalSeries p75 = new YIntervalSeries("75%");\r
+                    YIntervalSeries p50 = new YIntervalSeries("50%");\r
+                    YIntervalSeries p25 = new YIntervalSeries("25%");\r
+\r
+                    ArrayList<Double> sorter = new ArrayList<Double>();\r
+                    for(int i = 0; i < length; i++) {\r
+                        sorter.clear();\r
+                        for(int j = 0; j < n; j++) {\r
+                            sorter.add(series.get(j).values[1][i]); // values is a two-dimensional array. 0 dimension == times, 1 == values\r
+                        }\r
+                        Collections.sort(sorter);\r
+                        \r
+                        median.add(\r
+                                series.get(0).values[0][i], \r
+                              sorter.get(sorter.size()/2),\r
+                              sorter.get(sorter.size()/2),\r
+                              sorter.get(sorter.size()/2)\r
+                              );\r
+                        \r
+                        if(n > 8)\r
+                            p25.add(\r
+                                    series.get(0).values[0][i], \r
+                                    sorter.get(sorter.size()/2),\r
+                                    sorter.get(sorter.size() / 2 - (int)(sorter.size() * 0.25) / 2),\r
+                                    sorter.get(sorter.size() / 2 + (int)(sorter.size() * 0.25) / 2)\r
+                                    );\r
+                        \r
+                        if(n > 4)\r
+                            p50.add(\r
+                                    series.get(0).values[0][i], \r
+                                    sorter.get(sorter.size()/2),\r
+                                    sorter.get(sorter.size() / 2 - (int)(sorter.size() * 0.5) / 2),\r
+                                    sorter.get(sorter.size() / 2 + (int)(sorter.size() * 0.5) / 2)\r
+                                    );\r
+                        \r
+                        if(n > 8)\r
+                            p75.add(\r
+                                    series.get(0).values[0][i], \r
+                                    sorter.get(sorter.size()/2),\r
+                                    sorter.get(sorter.size() / 2 - (int)(sorter.size() * 0.75) / 2),\r
+                                    sorter.get(sorter.size() / 2 + (int)(sorter.size() * 0.75) / 2)\r
+                                    );\r
+                        \r
+                        p100.add(\r
+                                series.get(0).values[0][i], \r
+                                sorter.get(sorter.size()/2),\r
+                                sorter.get(0),\r
+                                sorter.get(sorter.size() - 1)\r
+                                );\r
+                    }\r
+                    \r
+                    ds.addSeries(median);\r
+                    if(n > 8)\r
+                        ds.addSeries(p25);\r
+                    if(n > 4)\r
+                        ds.addSeries(p50);\r
+                    if(n > 8)\r
+                        ds.addSeries(p75);\r
+                    ds.addSeries(p100);\r
+\r
+                }\r
+            });\r
+        }\r
+\r
+        @Override\r
+        public void exception(Throwable t) {\r
+            t.printStackTrace();\r
+        }\r
+\r
+    }\r
+}\r
index f6a275c21107d255011d22e766e0e5e0b798f951..9eac19cf1c70a8f85f4f970468e049a1282d1fe0 100644 (file)
@@ -39,7 +39,7 @@ import org.simantics.db.layer0.exception.MissingVariableException;
 import org.simantics.db.layer0.request.PossibleActiveExperiment;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
-import org.simantics.db.procedure.Listener;\r
+import org.simantics.db.common.procedure.adapter.DisposableListener;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.diagram.G2DUtils;\r
 import org.simantics.jfreechart.chart.AbstractDataset;\r
@@ -62,198 +62,217 @@ import org.simantics.utils.datastructures.Pair;
  */\r
 public class XYDataset extends AbstractDataset implements org.simantics.jfreechart.chart.XYDataset{\r
 \r
-    private IRenderer renderer;\r
+    protected IRenderer renderer;\r
 \r
     public XYDataset(ReadGraph graph, final Resource datasetResource) throws DatabaseException {\r
         super(graph, datasetResource);\r
     }\r
 \r
-    private DefaultXYDataset dataset;\r
-    private DataSetListener datasetListener;\r
-    private TimeListener timeListener;\r
-\r
-    @Override\r
-    public Dataset getDataset() {\r
-        if(dataset == null) {\r
-            dataset = new DefaultXYDataset();\r
-        }   \r
-\r
+    protected Dataset dataset;\r
+    protected DisposableListener<Pair<ArrayList<TempSeries>, IRenderer>> datasetListener;\r
+    protected DisposableListener<Double> timeListener;\r
+    \r
+    protected DisposableListener<Pair<ArrayList<TempSeries>, IRenderer>> getDatasetListener() {\r
         if(datasetListener == null || datasetListener.isDisposed()) {\r
             datasetListener = new DataSetListener();\r
-            SimanticsUI.getSession().asyncRequest(new Read<Pair<ArrayList<TempSeries>, IRenderer>>() {\r
-\r
-                @Override\r
-                public Pair<ArrayList<TempSeries>, IRenderer> perform(ReadGraph graph) throws DatabaseException {\r
-                    JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
-\r
-                    // Renderer\r
-                    IRenderer renderer = null;\r
-                    Resource rendererResource = graph.getPossibleObject(resource, jfree.Dataset_renderer);\r
-                    if(rendererResource != null)\r
-                        renderer = graph.adapt(rendererResource, IRenderer.class);\r
-\r
-                    ArrayList<TempSeries> series = new ArrayList<TempSeries>();\r
-\r
-                    String realizationURI = getRealizationURI(graph);\r
-\r
-                    if(realizationURI == null)\r
-                        return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer); // No experiment -> No results\r
+        }\r
+        return datasetListener;\r
+    }\r
 \r
-                    // Get a variable for the x-axis (if not time)\r
-                    double[] domainValues = null;\r
-                    Resource domainAxis = graph.getPossibleObject(resource, jfree.Dataset_mapToDomainAxis);\r
-                    if(domainAxis != null) {\r
-                        String rvi = graph.getPossibleRelatedValue(domainAxis, jfree.variableRVI);\r
-                        if(rvi != null && !rvi.isEmpty()) {\r
-                            try {\r
-                                Variable domainVariable = Variables.getVariable(graph, realizationURI + rvi);\r
-                                Variable valuesVariable = domainVariable.browsePossible(graph, "#" + Functions.VALUES +"#");\r
-                                if(valuesVariable != null) {\r
-                                       double[][] valuesArray = valuesVariable.getValue(graph);\r
-                                       if(valuesArray.length > 0)\r
-                                               domainValues = valuesArray[0];\r
-                                }\r
-                            } catch(MissingVariableException e) {\r
-                                //Do nothing, use time as domain axis\r
+    protected DisposableListener<Double> getTimeListener() {\r
+        if(timeListener == null || timeListener.isDisposed()) {\r
+            timeListener = new TimeListener();\r
+        }\r
+        return timeListener;\r
+    }\r
+    \r
+    protected Read<Pair<ArrayList<TempSeries>, IRenderer>> getDatasetRequest() {\r
+        return new Read<Pair<ArrayList<TempSeries>, IRenderer>>() {\r
+\r
+            @Override\r
+            public Pair<ArrayList<TempSeries>, IRenderer> perform(ReadGraph graph) throws DatabaseException {\r
+                JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+\r
+                // Renderer\r
+                IRenderer renderer = null;\r
+                Resource rendererResource = graph.getPossibleObject(resource, jfree.Dataset_renderer);\r
+                if(rendererResource != null)\r
+                    renderer = graph.adapt(rendererResource, IRenderer.class);\r
+\r
+                ArrayList<TempSeries> series = new ArrayList<TempSeries>();\r
+\r
+                String realizationURI = getRealizationURI(graph);\r
+\r
+                if(realizationURI == null)\r
+                    return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer); // No experiment -> No results\r
+\r
+                // Get a variable for the x-axis (if not time)\r
+                double[] domainValues = null;\r
+                Resource domainAxis = graph.getPossibleObject(resource, jfree.Dataset_mapToDomainAxis);\r
+                if(domainAxis != null) {\r
+                    String rvi = graph.getPossibleRelatedValue(domainAxis, jfree.variableRVI);\r
+                    if(rvi != null && !rvi.isEmpty()) {\r
+                        try {\r
+                            Variable domainVariable = Variables.getVariable(graph, realizationURI + rvi);\r
+                            Variable valuesVariable = domainVariable.browsePossible(graph, "#" + Functions.VALUES +"#");\r
+                            if(valuesVariable != null) {\r
+                                double[][] valuesArray = valuesVariable.getValue(graph);\r
+                                if(valuesArray.length > 0)\r
+                                    domainValues = valuesArray[0];\r
                             }\r
+                        } catch(MissingVariableException e) {\r
+                            //Do nothing, use time as domain axis\r
                         }\r
                     }\r
+                }\r
 \r
-                    Resource seriesList = graph.getPossibleObject(resource, jfree.Dataset_seriesList);\r
+                Resource seriesList = graph.getPossibleObject(resource, jfree.Dataset_seriesList);\r
 \r
-                    // Get properties for all series\r
-                    if(seriesList != null) {\r
-                        for(Resource r : ListUtils.toList(graph, seriesList)) {\r
-                            String rvi = graph.getPossibleRelatedValue(r, jfree.variableRVI);\r
-                            if(rvi == null)\r
-                                continue;\r
+                // Get properties for all series\r
+                if(seriesList != null) {\r
+                    for(Resource r : ListUtils.toList(graph, seriesList)) {\r
+                        String rvi = graph.getPossibleRelatedValue(r, jfree.variableRVI);\r
+                        if(rvi == null)\r
+                            continue;\r
 \r
-                            try {\r
-                                // Get visual properties\r
-                                Integer width = graph.getPossibleRelatedValue(r, jfree.Series_lineWidth, Bindings.INTEGER);\r
-                                if(width == null) width = 1;\r
+                        try {\r
+                            // Get visual properties\r
+                            Integer width = graph.getPossibleRelatedValue(r, jfree.Series_lineWidth, Bindings.INTEGER);\r
+                            if(width == null) width = 1;\r
 \r
-                                Resource c = graph.getPossibleObject(r, jfree.color);\r
-                                Color color = c == null ? null : G2DUtils.getColor(graph, c);\r
-                                \r
-                                String label = graph.getPossibleRelatedValue(r, Layer0.getInstance(graph).HasLabel);\r
+                            Resource c = graph.getPossibleObject(r, jfree.color);\r
+                            Color color = c == null ? null : G2DUtils.getColor(graph, c);\r
+                            \r
+                            String label = graph.getPossibleRelatedValue(r, Layer0.getInstance(graph).HasLabel);\r
 \r
-                                // Get a variable for the series\r
-                                Variable v = Variables.getVariable(graph, realizationURI + rvi);\r
-                                if(v == null)\r
-                                    return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer);\r
+                            // Get a variable for the series\r
+                            Variable v = Variables.getVariable(graph, realizationURI + rvi);\r
+                            if(v == null)\r
+                                return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer);\r
 \r
-                                // Get values\r
-                                Variable dsVariable = v.browsePossible(graph, "#" + Functions.ACTIVE_DATASETS + "#");\r
-                                Object object = null;\r
-                                if(dsVariable != null)\r
-                                        object = dsVariable.getValue(graph);\r
+                            // Get values\r
+                            Variable dsVariable = v.browsePossible(graph, "#" + Functions.ACTIVE_DATASETS + "#");\r
+                            Object object = null;\r
+                            if(dsVariable != null)\r
+                                 object = dsVariable.getValue(graph);\r
 \r
-                                if(object == null || !(object instanceof ArrayList<?>))\r
-                                    return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer);\r
+                            if(object == null || !(object instanceof ArrayList<?>))\r
+                                return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer);\r
 \r
-                                ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
+                            ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
 \r
-                                for(Object o : (ArrayList<?>)object) {\r
-                                    if(o instanceof SysdynDataSet)\r
-                                        datasets.add((SysdynDataSet)o);\r
-                                }\r
+                            for(Object o : (ArrayList<?>)object) {\r
+                                if(o instanceof SysdynDataSet)\r
+                                    datasets.add((SysdynDataSet)o);\r
+                            }\r
 \r
 \r
-                                String[] filter = graph.getPossibleRelatedValue(r, jfree.variableFilter);\r
-                                if(filter != null) {\r
-                                    ArrayList<SysdynDataSet> result2 = VariableRVIUtils.getDataset(datasets, filter);\r
-                                    if(result2 != null) {\r
-                                        datasets = result2;\r
-                                    }\r
+                            String[] filter = graph.getPossibleRelatedValue(r, jfree.variableFilter);\r
+                            if(filter != null) {\r
+                                ArrayList<SysdynDataSet> result2 = VariableRVIUtils.getDataset(datasets, filter);\r
+                                if(result2 != null) {\r
+                                    datasets = result2;\r
                                 }\r
+                            }\r
+\r
+                            for(SysdynDataSet dataset : datasets) {\r
+                                double[] va = dataset.values;\r
 \r
-                                for(SysdynDataSet dataset : datasets) {\r
-                                    double[] va = dataset.values;\r
-\r
-                                    // Get domain axis values (time OR other variable) \r
-                                    double[] ta;\r
-                                    if(domainValues != null) {\r
-                                        ta = domainValues;\r
-\r
-                                        // If domainAxis is other than time, parameter values size is different. \r
-                                        if(domainValues.length > va.length) {\r
-                                            double value = va[0];\r
-                                            va = new double[domainValues.length];\r
-                                            for(int i = 0; i < domainValues.length; i++)\r
-                                                va[i] = value;\r
-                                        }\r
-\r
-                                        // If domainAxis is a parameter, the domainValues array is too short\r
-                                        if(domainValues.length < va.length && domainValues.length == 2 && domainValues[0] == domainValues[1]) {\r
-                                            double value = domainValues[0];\r
-                                            ta = new double[va.length];\r
-                                            for(int i = 0; i < va.length; i++)\r
-                                                ta[i] = value;\r
-                                        }\r
-\r
-                                    } else {\r
-                                        ta = dataset.times;\r
+                                // Get domain axis values (time OR other variable) \r
+                                double[] ta;\r
+                                if(domainValues != null) {\r
+                                    ta = domainValues;\r
+\r
+                                    // If domainAxis is other than time, parameter values size is different. \r
+                                    if(domainValues.length > va.length) {\r
+                                        double value = va[0];\r
+                                        va = new double[domainValues.length];\r
+                                        for(int i = 0; i < domainValues.length; i++)\r
+                                            va[i] = value;\r
                                     }\r
 \r
-                                    if(ta!=null && va!=null && (va.length == ta.length)) {\r
-                                        // Add series if everything OK\r
-                                        String name = dataset.name;\r
-                                        if(label != null)\r
-                                            name = label;\r
-                                        if(dataset.result != null && !dataset.result.isEmpty())\r
-                                            name = name + " : " + dataset.result;\r
-                                        series.add(new TempSeries(name, new double[][] {ta, va}, width, color));\r
-                                        if(ta.length == 0 || va.length == 0)\r
-                                            System.out.println(dataset.name + " : " + dataset.result + ". Sizes: " + va.length + " and " + ta.length);\r
+                                    // If domainAxis is a parameter, the domainValues array is too short\r
+                                    if(domainValues.length < va.length && domainValues.length == 2 && domainValues[0] == domainValues[1]) {\r
+                                        double value = domainValues[0];\r
+                                        ta = new double[va.length];\r
+                                        for(int i = 0; i < va.length; i++)\r
+                                            ta[i] = value;\r
                                     }\r
+\r
+                                } else {\r
+                                    ta = dataset.times;\r
                                 }\r
 \r
-                            } catch (MissingVariableException e) {\r
-                                // Do nothing, if variable was not found. Move on to the next series\r
+                                if(ta!=null && va!=null && (va.length == ta.length)) {\r
+                                    // Add series if everything OK\r
+                                    String name = dataset.name;\r
+                                    if(label != null)\r
+                                        name = label;\r
+                                    if(dataset.result != null && !dataset.result.isEmpty())\r
+                                        name = name + " : " + dataset.result;\r
+                                    series.add(new TempSeries(name, new double[][] {ta, va}, width, color));\r
+                                    if(ta.length == 0 || va.length == 0)\r
+                                        System.out.println(dataset.name + " : " + dataset.result + ". Sizes: " + va.length + " and " + ta.length);\r
+                                }\r
                             }\r
+\r
+                        } catch (MissingVariableException e) {\r
+                            // Do nothing, if variable was not found. Move on to the next series\r
                         }\r
                     }\r
-                    return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer);\r
                 }\r
-\r
-            }, datasetListener); \r
-        }\r
-\r
-        if(timeListener == null || timeListener.isDisposed()) {\r
-            timeListener = new TimeListener();\r
-            SimanticsUI.getSession().asyncRequest(new Read<Double>() {\r
-                @Override\r
-                public Double perform(ReadGraph graph) throws DatabaseException {\r
-                    JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
-                    // Get properties for all series\r
-                    Resource series = graph.getPossibleObject(resource, jfree.Dataset_seriesList);\r
-                    if(series != null) {\r
-                        List<Resource> seriesList = ListUtils.toList(graph, series);\r
-                        if(seriesList != null) {\r
-                            String realizationURI = getRealizationURI(graph);\r
-                            for(Resource r : seriesList) {\r
-                                String rvi = graph.getPossibleRelatedValue(r, jfree.variableRVI);\r
-                                if(rvi == null)\r
-                                    continue;\r
-                                try {\r
-                                       // Get a variable for the experiment run\r
-                                       Variable v = Variables.getVariable(graph, realizationURI);\r
-                                       if(v == null)\r
-                                               return null;\r
-                                       Variable timeVar = v.browsePossible(graph, "#" + Functions.TIME + "#");\r
-                                       if(timeVar != null)\r
-                                           return timeVar.getValue(graph, Bindings.DOUBLE);\r
-                                } catch (MissingVariableException e) {\r
-                                       // Do nothing, if variable was not found.\r
-                                }\r
+                return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer);\r
+            }\r
+        };\r
+    }\r
+    \r
+    protected Read<Double> getTimeRequest() {\r
+        return new Read<Double>() {\r
+            @Override\r
+            public Double perform(ReadGraph graph) throws DatabaseException {\r
+                JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+                // Get properties for all series\r
+                Resource series = graph.getPossibleObject(resource, jfree.Dataset_seriesList);\r
+                if(series != null) {\r
+                    List<Resource> seriesList = ListUtils.toList(graph, series);\r
+                    if(seriesList != null) {\r
+                        String realizationURI = getRealizationURI(graph);\r
+                        for(Resource r : seriesList) {\r
+                            String rvi = graph.getPossibleRelatedValue(r, jfree.variableRVI);\r
+                            if(rvi == null)\r
+                                continue;\r
+                            try {\r
+                                // Get a variable for the experiment run\r
+                                Variable v = Variables.getVariable(graph, realizationURI);\r
+                                if(v == null)\r
+                                    return null;\r
+                                Variable timeVar = v.browsePossible(graph, "#" + Functions.TIME + "#");\r
+                                if(timeVar != null)\r
+                                    return timeVar.getValue(graph, Bindings.DOUBLE);\r
+                            } catch (MissingVariableException e) {\r
+                                // Do nothing, if variable was not found.\r
                             }\r
                         }\r
                     }\r
-                    return null;\r
                 }\r
+                return null;\r
+            }\r
+\r
+        };\r
+    }\r
 \r
-            }, timeListener);\r
+    @Override\r
+    public Dataset getDataset() {\r
+        if(dataset == null) {\r
+            dataset = new DefaultXYDataset();\r
+        }   \r
+\r
+        if(datasetListener == null || datasetListener.isDisposed()) {\r
+            SimanticsUI.getSession().asyncRequest(getDatasetRequest(), getDatasetListener()); \r
+        }\r
+\r
+        if(timeListener == null || timeListener.isDisposed()) {\r
+            SimanticsUI.getSession().asyncRequest(getTimeRequest(), getTimeListener());\r
         }\r
         return dataset;\r
     }\r
@@ -263,7 +282,7 @@ public class XYDataset extends AbstractDataset implements org.simantics.jfreecha
      * @author Teemu Lempinen\r
      *\r
      */\r
-    private class TimeMarker extends ValueMarker {\r
+    protected class TimeMarker extends ValueMarker {\r
         private static final long serialVersionUID = 2018755066561629172L;\r
 \r
         public TimeMarker(double value, Paint paint, Stroke stroke) {\r
@@ -271,18 +290,7 @@ public class XYDataset extends AbstractDataset implements org.simantics.jfreecha
         }\r
     }\r
 \r
-    private class DataSetListener implements Listener<Pair<ArrayList<TempSeries>, IRenderer>> {\r
-\r
-        private boolean disposed = false;\r
-\r
-        public void dispose() {\r
-            disposed = true;\r
-        }\r
-\r
-        @Override\r
-        public boolean isDisposed() {\r
-            return disposed;\r
-        }\r
+    private class DataSetListener extends DisposableListener<Pair<ArrayList<TempSeries>, IRenderer>> {\r
 \r
         @Override\r
         public void execute(Pair<ArrayList<TempSeries>, IRenderer> result) {\r
@@ -295,7 +303,12 @@ public class XYDataset extends AbstractDataset implements org.simantics.jfreecha
                 @Override\r
                 public void run() {\r
 \r
+                    if(dataset == null || !(dataset instanceof DefaultXYDataset))\r
+                        return;\r
+                    \r
+                    DefaultXYDataset ds = (DefaultXYDataset)dataset;\r
                     org.jfree.chart.plot.XYPlot plot = ((AbstractXYItemRenderer)getRenderer()).getPlot();\r
+                    \r
                     if(plot != null) {\r
                         /*\r
                          *  Drawing supplier with a modified first yellow. The default first\r
@@ -313,14 +326,14 @@ public class XYDataset extends AbstractDataset implements org.simantics.jfreecha
                         plot.setDrawingSupplier(drawingsupplier);\r
                     }\r
                     // Remove all series\r
-                    for(int i = dataset.getSeriesCount() - 1; i >= 0; i-- ) {\r
-                        dataset.removeSeries(dataset.getSeriesKey(i));\r
+                    for(int i = ds.getSeriesCount() - 1; i >= 0; i-- ) {\r
+                        ds.removeSeries(ds.getSeriesKey(i));\r
                     }\r
 \r
                     // Add found series\r
                     for(int i = 0; i < series.size(); i++) {\r
                         TempSeries s = series.get(i);\r
-                        dataset.addSeries(s.name, s.values);\r
+                        ds.addSeries(s.name, s.values);\r
                         getRenderer().setSeriesStroke(i, new BasicStroke((float)s.width));\r
                         getRenderer().setSeriesPaint(i, s.color);\r
                     } \r
@@ -341,10 +354,9 @@ public class XYDataset extends AbstractDataset implements org.simantics.jfreecha
      * @author Teemu Lempinen\r
      *\r
      */\r
-    private class TimeListener implements Listener<Double> {\r
+    protected class TimeListener extends DisposableListener<Double> {\r
 \r
         private ValueMarker marker;\r
-        private boolean disposed = false;\r
         private Stroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT,\r
                 BasicStroke.JOIN_MITER, 10.0f, new float[] {5.0f, 3.0f, 1.0f, 3.0f}, 0.0f);\r
 \r
@@ -353,7 +365,7 @@ public class XYDataset extends AbstractDataset implements org.simantics.jfreecha
         }\r
 \r
         public void dispose() {\r
-            this.disposed = true;\r
+            super.dispose();\r
             if(marker != null) {\r
                 org.jfree.chart.plot.XYPlot plot = ((AbstractXYItemRenderer)getRenderer()).getPlot();\r
                 if(plot != null)\r
@@ -361,11 +373,6 @@ public class XYDataset extends AbstractDataset implements org.simantics.jfreecha
             }\r
         }\r
 \r
-        @Override\r
-        public boolean isDisposed() {\r
-            return disposed;\r
-        }\r
-\r
         @Override\r
         public void execute(final Double time) {\r
             // Modify in AWT thread to avoid synchronization problems\r
@@ -421,7 +428,7 @@ public class XYDataset extends AbstractDataset implements org.simantics.jfreecha
      * @author Teemu Lempinen\r
      *\r
      */\r
-    private class TempSeries {\r
+    protected class TempSeries {\r
         public double[][] values;\r
         public String name;\r
         public int width;\r
@@ -472,7 +479,7 @@ public class XYDataset extends AbstractDataset implements org.simantics.jfreecha
      * @return realization uri for current dataset resource\r
      * @throws DatabaseException\r
      */\r
-    private String getRealizationURI(ReadGraph graph) throws DatabaseException {\r
+    protected String getRealizationURI(ReadGraph graph) throws DatabaseException {\r
         if(resource == null)\r
             return null;\r
 \r
index 7fcf67c158284adb28d93d1709375cf8241a3f23..c6a513d17fc0825702712dc998fe90d8606ced1b 100644 (file)
@@ -570,8 +570,8 @@ public class ExpressionUtils {
             return ReferenceOption.DOES_NOT_EXIST;\r
         else if(Boolean.TRUE.equals(element))\r
             return ReferenceOption.CANNOT_BE_CONNECTED;\r
-        else if(element instanceof Variable) {\r
-            if(element instanceof Enumeration || element instanceof Sheet)\r
+        else if(element instanceof Variable || element instanceof Module) {\r
+            if(element instanceof Enumeration || element instanceof Sheet || element instanceof Module || parts.length > 1)\r
                 return ReferenceOption.CANNOT_BE_CONNECTED;\r
             else\r
                 return ReferenceOption.CAN_BE_CONNECTED;\r
index d69272b1ffb986373292fcfd9a6461972a15574f..c576dd7c9244baeb843d0d3984594f340d0df096 100644 (file)
@@ -8,6 +8,7 @@
  *\r
  * Contributors:\r
  *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *     Semantum Oy - Bug #4192\r
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.utils.imports;\r
 \r
@@ -40,6 +41,10 @@ import org.simantics.db.common.request.WriteResultRequest;
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.exception.ResourceNotFoundException;\r
+import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor;\r
+import org.simantics.db.layer0.migration.MigrationState;\r
+import org.simantics.db.layer0.migration.MigrationStateKeys;\r
+import org.simantics.db.layer0.migration.MigrationUtils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.issues.common.AllBatchIssueSources;\r
@@ -138,18 +143,22 @@ public class ImportUtils {
 \r
         Activator.getDefault().getPreferenceStore().setValue(IMPORTMODELTPATH, (new File(path)).getParent());\r
 \r
+        MigrationState state = MigrationUtils.newState();\r
+        state.setProperty(MigrationStateKeys.BASE_URI, SysdynResource.URIs.Migration);\r
+        state.setProperty(MigrationStateKeys.UPDATE_DEPENDENCIES, Boolean.FALSE);\r
 \r
-\r
-        HashMap<String, FormatHandler<Object>> handlers = new HashMap<String, FormatHandler<Object>>();\r
-        handlers.put("sysdynModel:1", new SysdynImportFormatHandler(project, SysdynResource.URIs.from1$6to1$7, monitor));\r
-\r
-        Object result = ImportUtils.readFile(path, handlers);\r
+        Resource result = null;\r
+        try {\r
+            result = MigrationUtils.importMigrated(monitor, SimanticsUI.getSession(), new File(path), state, new DefaultPasteImportAdvisor(project), project);\r
+        } catch (Exception e1) {\r
+            e1.printStackTrace();\r
+        }\r
 \r
         if(result == null || !(result instanceof Resource)) {\r
             return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed: File could not be read.", null);\r
         } else {\r
             try {\r
-                final Resource ModelRoot = (Resource) result;\r
+                final Resource ModelRoot = result;\r
                 IStatus status = SimanticsUI.getSession().syncRequest(new WriteResultRequest<IStatus>()  {\r
 \r
                     @Override\r
@@ -352,18 +361,22 @@ public class ImportUtils {
 \r
         Activator.getDefault().getPreferenceStore().setValue(IMPORTMODULETPATH, (new File(path)).getParent());\r
 \r
-        // Handler for importing modules\r
-        HashMap<String, FormatHandler<Object>> handlers = new HashMap<String, FormatHandler<Object>>();\r
-        handlers.put("sysdynModule:1", new SysdynImportFormatHandler(model, SysdynResource.URIs.from1$6to1$7, monitor));\r
+        MigrationState state = MigrationUtils.newState();\r
+        state.setProperty(MigrationStateKeys.BASE_URI, SysdynResource.URIs.Migration);\r
+        state.setProperty(MigrationStateKeys.UPDATE_DEPENDENCIES, Boolean.FALSE);\r
 \r
-        // Read module file\r
-        Object result = ImportUtils.readFile(path, handlers);\r
+        Resource result = null;\r
+        try {\r
+            result = MigrationUtils.importMigrated(monitor, SimanticsUI.getSession(), new File(path), state, new DefaultPasteImportAdvisor(model), model);\r
+        } catch (Exception e1) {\r
+            e1.printStackTrace();\r
+        }\r
 \r
 \r
-        if(result == null || !(result instanceof Resource)) {\r
+        if(result == null) {\r
             return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import module failed: Module could not be imported.", null);\r
         } else {\r
-            final Resource ModuleRoot = (Resource) result;\r
+            final Resource ModuleRoot = result;\r
             // Check that the imported file actually was a module. Display error message otherwise.\r
             try {\r
                 subTask(monitor, "Validate model");\r
@@ -415,15 +428,19 @@ public class ImportUtils {
 \r
         // Ensure that shared functions ontology exists\r
         ensureSharedOntologies();\r
+        \r
+        MigrationState state = MigrationUtils.newState();\r
+        state.setProperty(MigrationStateKeys.BASE_URI, SysdynResource.URIs.Migration);\r
+        state.setProperty(MigrationStateKeys.UPDATE_DEPENDENCIES, Boolean.FALSE);\r
 \r
-        // Handler for importing function libraries\r
-        HashMap<String, FormatHandler<Object>> handlers = new HashMap<String, FormatHandler<Object>>();\r
-        handlers.put("sysdynFunctionLibrary:1", new SysdynImportFormatHandler(functionLibrary, SysdynResource.URIs.from1$6to1$7, monitor, new SysdynFunctionLibraryImportAdvisor(functionLibrary)));\r
-\r
-        // Read function library file\r
-        Object result = ImportUtils.readFile(path, handlers);\r
+        Resource result = null;\r
+        try {\r
+            result = MigrationUtils.importMigrated(monitor, SimanticsUI.getSession(), new File(path), state, new DefaultPasteImportAdvisor(functionLibrary), functionLibrary);\r
+        } catch (Exception e1) {\r
+            e1.printStackTrace();\r
+        }\r
 \r
-        if(result == null || !(result instanceof Resource)) {\r
+        if(result == null) {\r
             return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import Function library failed: Function library not be imported.", null);\r
         } else {\r
             final Resource FunctionLibraryRoot = (Resource) result;\r
index a6aab02e946ca6cbae1fe0ff5cc1c4db892b4dea..96b687ca78efd89a89c4383f8b693770ab51700a 100644 (file)
@@ -17,10 +17,10 @@ import java.util.List;
 import org.simantics.db.Issue;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.common.issue.StandardIssue;\r
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.issues.common.StandardIssue;\r
 import org.simantics.scl.reflection.annotations.SCLValue;\r
 import org.simantics.sysdyn.SysdynResource;\r
 \r
index 782fb3cfef3ac5c15b583ebedf229841593c7e83..8a55a522fe886bd6f42613be08428aacb938a016 100644 (file)
@@ -17,10 +17,10 @@ import java.util.List;
 import org.simantics.db.Issue;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.common.issue.StandardIssue;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.issues.common.IssueUtils;\r
-import org.simantics.issues.common.StandardIssue;\r
 import org.simantics.scl.reflection.annotations.SCLValue;\r
 import org.simantics.sysdyn.SysdynResource;\r
 \r
index a491add4e3428a966599e19d58843df6b229770f..906124fb24433c96d16e66e8bdbf8c495e63bffe 100644 (file)
@@ -19,10 +19,10 @@ import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.issue.StandardIssue;\r
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.issues.common.StandardIssue;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 \r
index f56bc881722f626f50caf90ab20571d991e64057..7a336dc239b2560ca5a35b8d358fff3a16c9e067 100644 (file)
@@ -104,8 +104,10 @@ public abstract class IndexVariable<T> extends AbstractPropertyVariable {
         }\r
         @Override\r
         public void unregistered() {\r
-            unregisterSubscription(subscription);\r
-            subscription = null;\r
+            if(subscription != null) {\r
+                unregisterSubscription(subscription);\r
+                subscription = null;\r
+            }\r
         }\r
 \r
         @SuppressWarnings("unchecked")\r
index 9ce2169bd735ba0445cd7f36b2f7d5babee95c14..9834ff5db5c7bc42f04efe38cab661769a777eca 100644 (file)
@@ -36,7 +36,8 @@ public class ValueIndexVariable extends IndexVariable<double[]> {
                for(int i = 0; i < variableNames.size(); i++) {\r
                    for(SysdynResult r : results) {            \r
                        if(experiment instanceof SysdynGameExperiment) {\r
-                           result[i] = ((SysdynGameExperiment)experiment).getCurrentValue(variableNames.get(i));\r
+                           Double d = ((SysdynGameExperiment)experiment).getCurrentValue(variableNames.get(i)); \r
+                           result[i] = d != null ? d : 0;\r
                        } else {\r
                            SysdynDataSet ds = r.getDataSet(variableNames.get(i));\r
                            if(ds != null && ds.values != null && ds.values.length > 0) {\r
index 1f918aa7eeb99ecd96faca1939a89d9c82419d24..716fd5887f1ae657925d95c2e61c4ca050a3f118 100644 (file)
@@ -18,6 +18,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import org.simantics.db.Session;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.Logger;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.procedure.Listener;\r
 import org.simantics.db.request.ExternalRead;\r
@@ -48,11 +49,14 @@ public class VariableValueSubscription<T> {
                return request;\r
        }\r
 \r
-\r
-       public void update() {\r
-               T value = variable.getValue();\r
-               fireValue(value);\r
-       }\r
+    public void update() {\r
+        try {\r
+            T value = variable.getValue();\r
+            fireValue(value);\r
+        } catch (Throwable e) {\r
+            fireException(e);\r
+        }\r
+    }\r
 \r
        void fireValue(T value) {\r
                if (listener != null)\r
@@ -62,8 +66,12 @@ public class VariableValueSubscription<T> {
        void fireException(Throwable t) {\r
                if (listener != null && excepted.compareAndSet(false, true))\r
                        listener.exception(t);\r
+        else\r
+            // Can't invoke listener.exception multiple times, but logging\r
+            // further exceptions anyway.\r
+            Logger.defaultLogError(t);\r
        }\r
-\r
+       \r
        public void setListener(Listener<T> listener) {\r
                this.listener = listener;\r
        }\r
index 093baadff03d4f504335e1d8876f36255ab9d539..46433abd4fb490a06d617c851d4a66b3cc8db249 100644 (file)
@@ -449,23 +449,18 @@ public class SysdynExperiment extends Experiment implements IDynamicExperiment,
      */\r
     public synchronized void simulate(final IModelicaMonitor monitor, final IProgressMonitor progressMonitor) throws IOException {\r
         canceled = false;\r
-\r
         progressMonitor.subTask("Write modelica classes");\r
 \r
         // Write Modelica files\r
-\r
-        \r
         String modelText = getModelicaCode(monitor, false, getOpenModelicaVersion());\r
         if(modelText == null)\r
             return;\r
-\r
         progressMonitor.worked(1);\r
 \r
         // Write initial files and add init-parameters\r
         progressMonitor.subTask("Write simulation files");\r
         HashMap<String, String> experimentParameters = getExperimentParameters(monitor);\r
 \r
-\r
         // add loadFile script to load all related functions and function libraries\r
         String additionalScript = getAdditionalScripts();\r
 \r
@@ -473,7 +468,6 @@ public class SysdynExperiment extends Experiment implements IDynamicExperiment,
         SimulationLocation simulationLocation = createSimulationFiles(sysdynModel, modelText, experimentParameters, additionalScript, false);\r
         progressMonitor.worked(1);\r
 \r
-\r
         // Build the model and store previous model structure and inits that affect the building\r
         // If there is no exe file OR the model structure has not changed, no need to build\r
         boolean structureChanged = hasStructureChanged(modelText);\r
@@ -501,7 +495,6 @@ public class SysdynExperiment extends Experiment implements IDynamicExperiment,
                 e.printStackTrace();\r
             }\r
         }\r
-\r
         progressMonitor.worked(1);\r
 \r
         if(simulationLocation != null && !canceled) {\r
@@ -852,6 +845,17 @@ public class SysdynExperiment extends Experiment implements IDynamicExperiment,
             subscription.update();\r
         skippedVariableUpdate = false;\r
     }\r
+    \r
+    public int numberOfSimulationRunSteps() {\r
+        /*\r
+         * 1. Write modelica files\r
+         * 2. Write other simulation files\r
+         * 3. Build model OR update parameters\r
+         * 4. Run modelica\r
+         * 5. Read results \r
+         */\r
+        return 5; \r
+    }\r
 \r
 \r
     /* Experiment methods that are not used in this experiment */\r
index dd8ffe26f74f7c58d73608bc4bc85c07bf6bdf2f..c3c2e6f0d59dce795ea0ef5aed13a2e2dc94d8a0 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.manager;\r
 \r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.FileOutputStream;\r
 import java.io.IOException;\r
 import java.util.ArrayList;\r
 import java.util.HashMap;\r
@@ -19,10 +23,13 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;\r
 import org.eclipse.core.runtime.Status;\r
 import org.eclipse.core.runtime.jobs.Job;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.AsyncReadGraph;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.Session;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.procedure.AsyncListener;\r
 import org.simantics.db.request.Read;\r
@@ -175,13 +182,23 @@ public class SysdynGameExperiment extends SysdynExperiment {
                SimulationLocation simulationLocation = createSimulationFiles(sysdynModel, modelText, inits, additionalScript, true);\r
                progressMonitor.worked(1);\r
 \r
-\r
+               // Load precompiled fmu if structure has not changed and it has not yet been loaded\r
+               File fmu = null;\r
+               if(!sysdynModel.isStructureModified()) {\r
+                   if(!simulationLocation.executableFile.isFile()) {\r
+                       fmu = loadModelFmu(simulationLocation);\r
+                   } else {\r
+                       fmu = simulationLocation.executableFile;\r
+                   }\r
+               }\r
                // Build the model and store previous model structure and inits that affect the building\r
                // If there is no exe file OR the model structure has not changed, no need to build\r
-               if (!simulationLocation.executableFile.isFile() || hasStructureChanged(modelText)) {\r
+               if (fmu == null && (!simulationLocation.executableFile.isFile() || hasStructureChanged(modelText))) {\r
                        progressMonitor.subTask("Build model");\r
                        buildModel(simulationLocation, modelText, monitor);\r
                        previousModelStructure = modelText;\r
+                       \r
+                       saveModelFmu(simulationLocation);\r
                }\r
 \r
                progressMonitor.worked(1);\r
@@ -202,6 +219,81 @@ public class SysdynGameExperiment extends SysdynExperiment {
                simulate(false); \r
        }\r
 \r
+       /**\r
+        * Load fmu file from database, if it exists for the model of this experiment\r
+        * \r
+        * @param simulationLocation SimulationLocation indicating where the fmu should be loaded\r
+        * @return Loaded fmu or null if it was not loaded from database\r
+        */\r
+       private File loadModelFmu(SimulationLocation simulationLocation) {\r
+           File fmu = null;\r
+           try {\r
+               final String fmuLocation = simulationLocation.executableFile.getAbsolutePath();\r
+            fmu = session.syncRequest(new Read<File>() {\r
+                @Override\r
+                public File perform(ReadGraph graph) throws DatabaseException {\r
+                    File result = null;\r
+                    FileOutputStream fos;\r
+                    try {\r
+                        fos = new FileOutputStream(fmuLocation);\r
+                        byte[] fileBArray = graph.getPossibleRelatedValue(\r
+                                getModel(), SysdynResource.getInstance(graph).SysdynModel_fmuFile, Bindings.BYTE_ARRAY);\r
+                        \r
+                        if(fileBArray != null) {\r
+                            fos.write(fileBArray);\r
+                            fos.close();\r
+                            result = new File(fmuLocation);\r
+                        } else {\r
+                            fos.close();\r
+                            return null;\r
+                        }\r
+                        \r
+                    } catch (FileNotFoundException e) {\r
+                        e.printStackTrace();\r
+                    } catch (IOException e) {\r
+                        e.printStackTrace();\r
+                    }\r
+                    return result;\r
+                }\r
+            });\r
+        } catch (DatabaseException e) {\r
+            e.printStackTrace();\r
+        }\r
+           \r
+           return fmu;\r
+       }\r
+       \r
+       /**\r
+        * Save fmu file from simulationLocation to database\r
+        * @param simulationLocation Location for finding fmu\r
+        */\r
+       private void saveModelFmu(SimulationLocation simulationLocation) {\r
+           final String fmuLocation = simulationLocation.executableFile.getAbsolutePath();\r
+           session.asyncRequest(new WriteRequest() {\r
+\r
+               @Override\r
+               public void perform(WriteGraph graph) throws DatabaseException {\r
+                   File file = new File(fmuLocation);\r
+                   byte[] fileBArray = new byte[(int)file.length()];\r
+                   FileInputStream fis;\r
+                   try {\r
+                       fis = new FileInputStream(file);\r
+\r
+                       fis.read(fileBArray);\r
+                       graph.claimLiteral(\r
+                               getModel(), \r
+                               SysdynResource.getInstance(graph).SysdynModel_fmuFile, \r
+                               fileBArray, Bindings.BYTE_ARRAY);\r
+                       fis.close();\r
+                   } catch (FileNotFoundException e) {\r
+                       e.printStackTrace();\r
+                   } catch (IOException e) {\r
+                       e.printStackTrace();\r
+                   }\r
+            }\r
+        });\r
+       }\r
+\r
 \r
        @Override\r
        public void simulateDuration(double duration) {\r
@@ -414,11 +506,12 @@ public class SysdynGameExperiment extends SysdynExperiment {
     }\r
     \r
     public Double getCurrentValue(String name) {\r
-        Integer index = subscriptionIndexes.get(name);\r
-        if(index != null) {\r
-            return currentValues[index];\r
-        } else {\r
-            return null;\r
+        if(subscriptionIndexes != null && name != null) {\r
+            Integer index = subscriptionIndexes.get(name);\r
+            if(index != null) {\r
+                return currentValues[index];\r
+            }\r
         }\r
+        return null;\r
     }\r
  }\r
index 55a72243c3c4849aec10f68dcabe48a9d08ccec6..29f9fc7291ebe1e74ce2ef830826476c67380d72 100644 (file)
@@ -53,6 +53,7 @@ import org.simantics.sysdyn.adapter.VariableValueSubscription;
 import org.simantics.sysdyn.representation.Configuration;\r
 import org.simantics.sysdyn.representation.IElement;\r
 import org.simantics.sysdyn.representation.IndependentVariable;\r
+import org.simantics.sysdyn.representation.Model;\r
 import org.simantics.sysdyn.representation.Module;\r
 import org.simantics.sysdyn.representation.ParameterOverride;\r
 import org.simantics.sysdyn.representation.Sheet;\r
@@ -271,10 +272,19 @@ public class SysdynModel implements IMappingListener, IModel, VariableSubscripti
      */\r
     public synchronized boolean update(ReadGraph graph) throws DatabaseException {\r
         if(mapping.isDomainModified()) {\r
-            structureModified = true;\r
+            \r
+\r
             \r
             try {\r
-                mapping.updateRange(graph);\r
+                Collection<Object> updated = mapping.updateRange(graph);\r
+                \r
+                for(Object o : updated) {\r
+                    if(!(o instanceof Model)) {\r
+                        setStructureModified(true);\r
+                        break;\r
+                    }\r
+                }\r
+                \r
             } catch (MappingException e) {\r
                 SysdynConsole.INSTANCE.message(\r
                         "Error: Mapping is broken! Find the problem, " +\r
@@ -305,7 +315,7 @@ public class SysdynModel implements IMappingListener, IModel, VariableSubscripti
         }\r
         else\r
             return false;\r
-    }\r
+    }        \r
 \r
     /**\r
      * Update mapping.\r
@@ -560,7 +570,7 @@ public class SysdynModel implements IMappingListener, IModel, VariableSubscripti
            return structureModified;\r
        }\r
 \r
-       public void setStructureModeified(boolean structureModified) {\r
+       public void setStructureModified(boolean structureModified) {\r
            this.structureModified = structureModified;\r
        }\r
 }\r
index c7da1528475fcd5e5715e7524e2ea7a4b12500f3..0d3d096bc0d8e11239d0b9f60a6e9a1eec80610a 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.manager;\r
 \r
+import java.io.File;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
 import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.HashMap;\r
+import java.util.Random;\r
 import java.util.concurrent.ScheduledExecutorService;\r
 \r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
-import org.simantics.simulation.experiment.IDynamicExperiment;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.modelica.IModelicaMonitor;\r
+import org.simantics.modelica.ModelicaKeys;\r
+import org.simantics.modelica.ModelicaManager;\r
+import org.simantics.modelica.SimulationLocation;\r
+import org.simantics.modelica.data.CSVSimulationResult;\r
+import org.simantics.modelica.data.MatSimulationResult;\r
+import org.simantics.modelica.data.SimulationResult;\r
+import org.simantics.sysdyn.SysdynResource;\r
 \r
 /**\r
  * Sensitivity analysis experiment\r
  * @author Tuomas Miettinen\r
  *\r
  */\r
-public class SysdynSensitivityAnalysisExperiment extends SysdynExperiment implements IDynamicExperiment {\r
+public class SysdynSensitivityAnalysisExperiment extends SysdynExperiment {\r
 \r
     public enum Distribution {\r
         UNIFORM,\r
         NORMAL\r
     }\r
     \r
-    private final Distribution propabilityDistribution = DEFAULT_PROPABILITY_DISTRIBUTION;\r
+    private Distribution propabilityDistribution = DEFAULT_PROPABILITY_DISTRIBUTION;\r
+    private double minValue = DEFAULT_MIN_VALUE;\r
+    private double maxValue = DEFAULT_MAX_VALUE;\r
+    private int numValues = DEFAULT_NUM_VALUES;\r
+    private String variedParameter = "Auxiliary1";\r
+    private double mean = DEFAULT_MEAN;\r
+    public double stdDeviation = DEFAULT_STD_DEVIATION;\r
+            \r
     \r
     public static Distribution DEFAULT_PROPABILITY_DISTRIBUTION = Distribution.UNIFORM;\r
     public static double DEFAULT_MIN_VALUE = 1.0;\r
     public static double DEFAULT_MAX_VALUE = 3.0;\r
     public static int DEFAULT_NUM_VALUES = 3;\r
-    \r
-    private final Collection<Runnable> timeListeners = new ArrayList<Runnable>();\r
+    public static double DEFAULT_MEAN = 0.0;\r
+    public static double DEFAULT_STD_DEVIATION = 1.0;\r
 \r
     ScheduledExecutorService playbackExecutionService;\r
-    //SensitivityAnalysisConfiguration playbackConfiguration;\r
+    private ArrayList<MemoryResult> results = null;\r
 \r
     public SysdynSensitivityAnalysisExperiment(Resource experiment, Resource model) {\r
         super(experiment, model);\r
     }\r
 \r
+    @Override\r
+    protected void runModelica(SimulationLocation simulationLocation, String modelText, IModelicaMonitor monitor, IProgressMonitor progressMonitor, HashMap<String, String> experimentParameters, HashMap<String, String> changes) throws IOException {\r
+        results = null;\r
+        \r
+        loadConfiguration();\r
+        if (changes == null) {\r
+            changes = new HashMap<String, String>();\r
+        }\r
+        \r
+        String version = ModelicaManager.getOMCVersion(simulationLocation.omcHome);\r
+        experimentParameters.put(ModelicaManager.OMC_VERSION, version);\r
 \r
-    /**\r
-     * Interrupts a possible ongoing playback\r
-     * \r
-     * @param time\r
-     */\r
-//    public void setTimeInterrupting(double time) {\r
-//        stopPlayback();\r
-//        setTime(time);\r
-//    }\r
-//\r
-//    /**\r
-//     * Sets a new time and continues playback from that point if \r
-//     * playback was running  \r
-//     * @param time\r
-//     */\r
-//    public void setTimeAndContinue(double time) {\r
-//        if(isPlaybackRunning()) {\r
-//            stopPlayback();\r
-//            setTime(time);\r
-//            startPlayback(500);\r
-//        } else {\r
-//            setTime(time);\r
-//        }\r
-//    }\r
-/*\r
-  private void setTime(double time) {\r
-        this.time = time;\r
-        resultsChanged(); \r
-    }\r
+        for (int i = 0; i < numValues; ++i) {\r
+            progressMonitor.subTask("Simulation iteration " + (i+1));\r
 \r
-    public double getTime() {\r
-        return this.time;\r
-    }\r
+            double value = 0;\r
 \r
-    public double getStartTime() {\r
-        return this.startTime;\r
-    }\r
+            if (propabilityDistribution == Distribution.UNIFORM) {\r
+                double intervalLength = (maxValue - minValue) / (numValues - 1);\r
+                value = minValue + (intervalLength * i);\r
+            } else if (propabilityDistribution == Distribution.NORMAL) {\r
+                Random random = new Random();\r
+                do {\r
+                    value = random.nextGaussian() * stdDeviation + mean;\r
+                } while (mean > minValue && mean < maxValue && (value < minValue || value > maxValue));\r
+            } else {\r
+                break;\r
+            }\r
+\r
+            // TODO: What if changes already include similarly named variable?\r
+            /* If the changes is altered, it affects also to the next simulation. So,\r
+             * All the parameters that are to be altered need to be defined explicitly\r
+             * before each new simulation.   \r
+             */\r
+            changes.put(variedParameter, Double.toString(value));\r
 \r
-    public double getEndTime() {\r
-        return this.endTime;\r
-    }\r
 \r
-    public void setPlaybackDuration(long duration) {\r
-        this.playbackDuration = duration;\r
-        if(isPlaybackRunning()) {\r
-            //Restart playback with different time settings\r
-            startPlayback();\r
+            // Specify result file name\r
+\r
+            int indexOfDot = simulationLocation.resFile.toString().lastIndexOf('.');\r
+            if (indexOfDot > 1) {\r
+                String resFile = simulationLocation.resFile.toString();\r
+                String newResFile = resFile.substring(0, indexOfDot) + i + resFile.substring(indexOfDot);\r
+                experimentParameters.put(ModelicaManager.RESULT_FILE_NAME, newResFile);\r
+            }                \r
+            // Simulate the model for one parameter set\r
+            runModelica(simulationLocation, modelText, monitor, progressMonitor, experimentParameters, changes, i);\r
+            progressMonitor.worked(1);\r
         }\r
     }\r
 \r
-    public long getPlaybackDuration() {\r
-        return this.playbackDuration;\r
+    private void loadConfiguration(){\r
+        try {\r
+            session.syncRequest(new ReadRequest() {\r
+                @Override\r
+                public void run(ReadGraph graph) throws DatabaseException {\r
+                    \r
+                    SysdynResource sr = SysdynResource.getInstance(graph);\r
+                    maxValue = graph.getPossibleRelatedValue(experiment, sr.SensitivityAnalysisExperiment_maxValue, Bindings.DOUBLE);\r
+                    minValue = graph.getPossibleRelatedValue(experiment, sr.SensitivityAnalysisExperiment_minValue, Bindings.DOUBLE);\r
+                    numValues = graph.getPossibleRelatedValue(experiment, sr.SensitivityAnalysisExperiment_numValues, Bindings.INTEGER);\r
+                    variedParameter = graph.getPossibleRelatedValue(experiment, sr.SensitivityAnalysisExperiment_variedParameter, Bindings.STRING);\r
+                    String propabilityDistributionTemp = graph.getPossibleRelatedValue(experiment, sr.SensitivityAnalysisExperiment_propabilityDistribution, Bindings.STRING);\r
+                    if (propabilityDistributionTemp.equalsIgnoreCase("uniform"))\r
+                        propabilityDistribution = Distribution.UNIFORM;\r
+                    else if (propabilityDistributionTemp.equalsIgnoreCase("normal"))\r
+                        propabilityDistribution = Distribution.NORMAL;\r
+                    else\r
+                        propabilityDistribution = DEFAULT_PROPABILITY_DISTRIBUTION;\r
+                    \r
+                    mean = graph.getPossibleRelatedValue(experiment, sr.SensitivityAnalysisExperiment_mean, Bindings.DOUBLE);\r
+                    stdDeviation = graph.getPossibleRelatedValue(experiment, sr.SensitivityAnalysisExperiment_stdDeviation, Bindings.DOUBLE);\r
+\r
+                }\r
+            });\r
+        } catch (DatabaseException e) {\r
+            e.printStackTrace();\r
+        }\r
     }\r
+    \r
+    protected void runModelica(SimulationLocation simulationLocation, \r
+            String modelText, \r
+            IModelicaMonitor monitor, \r
+            IProgressMonitor progressMonitor, \r
+            HashMap<String, String> experimentParameters, \r
+            HashMap<String, String> changes, \r
+            int resFileIndex) throws IOException {\r
+        process = ModelicaManager.runModelica(\r
+                simulationLocation,\r
+                monitor,\r
+                experimentParameters, \r
+                changes\r
+                );\r
 \r
-    @Override\r
-    public void init(ReadGraph g) {\r
-        super.init(g);\r
-        this.session = g.getSession();\r
-        session.asyncRequest(new ReadRequest() {\r
+        ModelicaManager.printProcessOutput(process, monitor);\r
 \r
-            @Override\r
-            public void run(ReadGraph graph) throws DatabaseException {\r
-                changeState(ExperimentState.RUNNING);\r
-                final Resource configuration = graph.getPossibleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
-                sysdynModel = SysdynModelManager.getInstance(session).getModel(graph, configuration);\r
-                toggleActivation(graph, true);\r
-                //getPlaybackConfiguration(graph);\r
-                startSimulationJob();\r
-            }\r
-        });\r
+        File resFile = new File(experimentParameters.get(ModelicaManager.RESULT_FILE_NAME));\r
+        Thread resultThread = getResultThread(resFile, experimentParameters, monitor, progressMonitor);\r
+        resultThread.run();\r
+\r
+        process = null;\r
     }\r
+    \r
+    /**\r
+     * Get a thread for reading and saving reuslts from a normal simulation\r
+     * @param simulationLocation\r
+     * @param inits\r
+     * @param monitor\r
+     * @param progressMonitor\r
+     * @param resFileIndex \r
+     * @return\r
+     */\r
+    protected Thread getResultThread(final File resFile, \r
+            final HashMap<String, String> experimentParameters, \r
+            final IModelicaMonitor monitor, \r
+            final IProgressMonitor progressMonitor) {\r
+        return new Thread() {\r
+            @Override\r
+            public void run() {\r
+                try {\r
+                    process.waitFor();\r
 \r
+                    if(!canceled) {\r
+                        // Get and store results\r
+                        SimulationResult result;\r
+                        if(resFile.getName().endsWith(".csv"))\r
+                            result = new CSVSimulationResult();\r
+                        else if(resFile.getName().endsWith(".plt"))\r
+                            result = new SimulationResult();\r
+                        else\r
+                            result = new MatSimulationResult(); // The latest format\r
 \r
+                        // The interval of results saved. Every result? Every other result? etc...\r
+                        int outIntervalInt = 1;\r
+                        String outputInterval = experimentParameters.get(ModelicaKeys.OUTPUT_INTERVAL);\r
+                        if(outputInterval != null) {\r
+                            String stepTime = experimentParameters.get(ModelicaKeys.STEP_VALUE);\r
+                            String stopTime = experimentParameters.get(ModelicaKeys.STOP_VALUE);\r
+                            \r
+                            Double step = Double.parseDouble(stepTime);\r
+                            Double stop = Double.parseDouble(stopTime);\r
+                            Double outInterval = Double.parseDouble(outputInterval);\r
 \r
-    private class SensitivityAnalysisConfiguration {\r
-        public double simulationDuration, simulationStepLength, intervals, endTime, startTime;\r
-        public long playbackDuration;\r
-    }\r
+                            outIntervalInt = (int)getInterval(outInterval, step);\r
+                            // Actually you might be able to use an outInterval one or two longer. \r
+                            int maxIntervalInt = (int)Math.round(stop / step);\r
+                            if (outIntervalInt > maxIntervalInt)\r
+                                outIntervalInt = maxIntervalInt;\r
+                        }\r
 \r
-    @Override\r
-    protected void localStateChange() {\r
-        super.localStateChange();\r
-    }\r
+                        result.initRead(resFile);\r
+                        result.readTime(resFile, outIntervalInt);\r
+                        //result.readInits(simulationLocation.initFile); // Parameter values are read from .mat\r
+                        result.filter();\r
+                        \r
+                        MemoryResult currentResult = new MemoryResult(null, null);\r
+                        getCurrentResults().add(currentResult);\r
+                        currentResult.setResult(result);\r
+                        currentResult.setResultFile(resFile);\r
+                        \r
+                        resultsChanged();\r
 \r
-    // TIME LISTENERS\r
-    public void addTimeListener(Runnable timeListener) {\r
-        if(!this.timeListeners.contains(timeListener))\r
-            this.timeListeners.add(timeListener);\r
-    }\r
+                        simulate(false);\r
 \r
-    public Collection<Runnable> getTimeListeners() {\r
-        return this.timeListeners;\r
+                        String errorString = result.getResultReadErrors();\r
+                        if(errorString != null && !errorString.isEmpty())\r
+                            monitor.message(errorString);\r
+                    }\r
+                } catch (FileNotFoundException e) {\r
+                    e.printStackTrace();\r
+                } catch (IOException e) {\r
+                    e.printStackTrace();\r
+                } catch (InterruptedException e) {\r
+                    e.printStackTrace();\r
+                }\r
+            }\r
+        };\r
     }\r
-\r
-    public void removeTimeListener(Runnable timeListener) {\r
-        this.timeListeners.remove(timeListener);\r
+    \r
+    public ArrayList<MemoryResult> getCurrentResults() {\r
+        if(this.results == null) {\r
+            this.results = new ArrayList<MemoryResult>();\r
+        }\r
+        return this.results;\r
     }\r
-\r
+    \r
     @Override\r
-    public void resultsChanged() {\r
-        for(Runnable listener : timeListeners) {\r
-            listener.run();\r
+    public Collection<SysdynResult> getActiveResults() {\r
+        ArrayList<SysdynResult> result = new ArrayList<SysdynResult>();\r
+        result.addAll(getCurrentResults());\r
+        result.addAll(sysdynModel.getDisplayedResults());\r
+        return result;\r
+    }\r
+    \r
+    @Override\r
+    public MemoryResult getCurrentResult() {\r
+        if (this.results == null || this.results.size() < 1)\r
+            return null;\r
+        /* There should be a better alternative solution for this. Currently\r
+         * the return value is next to nonsense.\r
+         */\r
+        return this.results.get(0);\r
+    }\r
+    \r
+    @Override\r
+    public void saveState() {\r
+        if(results == null || !(results instanceof ArrayList<?>)) \r
+            return;\r
+        //SaveResultJob saveResultJob = new SaveResultJob(SysdynSensitivityAnalysisExperiment.this, session, results);\r
+        //saveResultJob.schedule();\r
+    }\r
+    \r
+    @Override\r
+    public int numberOfSimulationRunSteps() {\r
+        /*\r
+         * From normal experiment:\r
+         * 1. Write modelica files\r
+         * 2. Write other simulation files\r
+         * 3. Build model OR update parameters\r
+         * \r
+         * Sensitivity:\r
+         * 4 - n. Number of iterations\r
+         */\r
+        try {\r
+            Integer numberOfIterations = session.syncRequest(new Read<Integer>() {\r
+                @Override\r
+                public Integer perform(ReadGraph graph) throws DatabaseException {\r
+                    SysdynResource sr = SysdynResource.getInstance(graph);\r
+                    return graph.getPossibleRelatedValue(experiment, sr.SensitivityAnalysisExperiment_numValues, Bindings.INTEGER);\r
+                }\r
+            });\r
+            return 3 + numberOfIterations; \r
+        } catch (DatabaseException e) {\r
+            e.printStackTrace();\r
         }\r
-        super.resultsChanged();\r
+        \r
+        return super.numberOfSimulationRunSteps();\r
 \r
     }\r
-*/\r
+    \r
 }\r
index 0c9a0e53ffaf87c76a0add5cb2230a1bc9d0a528..3e19f43c65dad4d33dc37511e102ec8f7e5407c3 100644 (file)
@@ -45,7 +45,7 @@ public class TGRefactoring {
         boolean fixed = GraphRefactoringUtils.fixIncorrectRoot(tg1.identities);\r
         IdentityStore idStore = TransferableGraphConversion.extractIdentities(tg1);\r
         TIntHashSet parentsAffected = new TIntHashSet(); \r
-        GraphRefactoringUtils.refactor(idStore, spec, parentsAffected);\r
+        GraphRefactoringUtils.refactor(tg1, idStore, spec, parentsAffected);\r
         tg1.resourceCount = idStore.getResourceCount();\r
         tg1.identities = idStore.toArray();\r
 //        GraphRefactoringUtils.compactify(tg1, parentsAffected);\r
index 92226cc84f732ec068f51308700a77920f4f784d..db41a5bbb103a3e6bf44d7d3369aaf507ac87cfd 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.representation;\r
 \r
+import gnu.trove.map.hash.THashMap;\r
+import gnu.trove.set.hash.THashSet;\r
+\r
 import java.util.ArrayList;\r
-import java.util.HashMap;\r
 import java.util.HashSet;\r
 \r
 import org.simantics.Simantics;\r
@@ -41,8 +43,8 @@ public class Sheet extends org.simantics.sysdyn.representation.Variable {
     @RelatedElement(Layer0.URIs.PartOf)\r
     protected Book book;\r
     \r
-    HashMap<String, Object> cells = new HashMap<String, Object>();\r
-    HashSet<String> usedRanges = new HashSet<String>();\r
+    THashMap<String, Object> cells = new THashMap<String, Object>();\r
+    THashSet<String> usedRanges = new THashSet<String>();\r
     \r
     Resource resource;\r
 \r
@@ -52,12 +54,10 @@ public class Sheet extends org.simantics.sysdyn.representation.Variable {
     \r
     @UpdateMethod\r
     public boolean updateCells(ReadGraph g, Resource r) throws DatabaseException {\r
-        cells.clear();\r
-        usedRanges.clear();\r
-        this.resource = null;\r
-\r
         if(g.hasStatement(r)) {\r
             this.resource = r;\r
+            THashMap<String, Object> newCells = new THashMap<String, Object>();\r
+            \r
             g.getObjects(r, Layer0.getInstance(g).ConsistsOf);\r
             Variable v = g.adapt(r, Variable.class);\r
             for(Variable child : v.getChildren(g)) {\r
@@ -65,14 +65,33 @@ public class Sheet extends org.simantics.sysdyn.representation.Variable {
                 try {\r
                     SpreadsheetUtils.decodeCellAbsolute(name);\r
                     Variant value = child.getPropertyValue(g, SheetVariables.CONTENT, Bindings.VARIANT);\r
-                    cells.put(name, value.getValue());\r
+                    newCells.put(name, value.getValue());\r
                 } catch (CellParseException e) {\r
                 } catch (MissingVariableException e) {\r
                     System.out.println("missing content for: " + name);\r
                 }\r
             }\r
+            \r
+            boolean update = false;\r
+            if(newCells.size() == this.cells.size()) {\r
+                // Cells are the same size. There might not be changes. Next up: content\r
+                for(String key : this.cells.keySet()) {\r
+                    if(!this.cells.get(key).equals(newCells.get(key))) {\r
+                        update = true;\r
+                        break;\r
+                    }\r
+                }\r
+            } else {\r
+                update = true;\r
+            }\r
+            \r
+            if(update) {\r
+                this.cells = newCells;\r
+                this.usedRanges.clear();\r
+                return true;\r
+            }\r
         }\r
-        return true;\r
+        return false;\r
     }\r
     \r
     public String getStringRepresentation() {\r
@@ -200,7 +219,7 @@ public class Sheet extends org.simantics.sysdyn.representation.Variable {
     }\r
 \r
     \r
-    public HashMap<String, Object> getCells() {\r
+    public THashMap<String, Object> getCells() {\r
         return cells;\r
     }\r
     \r
index f61c40c1fe0daf84f189a24ef5eb63a822f1f952..2823b33e12e12bb1c0284fa99ff138566975cf55 100644 (file)
@@ -20,7 +20,6 @@ import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;\r
 import org.eclipse.ui.PlatformUI;\r
 import org.simantics.modelica.IModelicaMonitor;\r
-import org.simantics.simulation.experiment.Experiment;\r
 import org.simantics.sysdyn.manager.SysdynConsole;\r
 import org.simantics.sysdyn.manager.SysdynExperiment;\r
 import org.simantics.sysdyn.manager.SysdynModel;\r
@@ -28,10 +27,10 @@ import org.simantics.sysdyn.manager.SysdynModel;
 public class SimulationJob extends Job {\r
 \r
     private SysdynModel model;\r
-    private Experiment experiment;\r
+    private SysdynExperiment experiment;\r
     private IModelicaMonitor monitor;\r
     \r
-    public SimulationJob(SysdynModel model, Experiment experiment) {\r
+    public SimulationJob(SysdynModel model, SysdynExperiment experiment) {\r
         super("Simulate " + model.getConfiguration().getLabel());\r
         this.model = model;\r
         this.experiment = experiment;\r
@@ -45,13 +44,14 @@ public class SimulationJob extends Job {
 \r
     @Override\r
     protected IStatus run(IProgressMonitor monitor) {\r
-        monitor.beginTask("Simulate " + model.getConfiguration().getLabel(), 5);        \r
+        monitor.beginTask("Simulate " + model.getConfiguration().getLabel(), experiment.numberOfSimulationRunSteps());        \r
         this.monitor.message("Simulate " + model.getConfiguration().getLabel());\r
         try {\r
             model.update();\r
-            if(experiment instanceof SysdynExperiment)\r
+            if(experiment instanceof SysdynExperiment) {\r
                ((SysdynExperiment)experiment).simulate(this.monitor, monitor);\r
-//            model.simulate(this.monitor, monitor, experiment);\r
+               model.setStructureModified(false);\r
+            }\r
         } catch (Exception e) {\r
             e.printStackTrace();\r
             this.monitor.showConsole();\r
index eb9ac911ec37a7f27a09ca85652db3a68a23e49f..0ee92dc8cb7fff3abb149adaa80e1a3457cc82fe 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.simulation;\r
 \r
-import org.simantics.simulation.experiment.Experiment;\r
+import org.simantics.sysdyn.manager.SysdynExperiment;\r
 import org.simantics.sysdyn.manager.SysdynModel;\r
 \r
 public class SimulationScheduler {\r
     SysdynModel model;\r
-    Experiment experiment;\r
+    SysdynExperiment experiment;\r
     SimulationJob job;\r
     \r
-    private SimulationScheduler(SysdynModel model, Experiment experiment) {    \r
+    private SimulationScheduler(SysdynModel model, SysdynExperiment experiment) {    \r
         this.model = model;\r
         this.experiment = experiment;\r
         this.job = new SimulationJob(model, experiment);\r
@@ -29,7 +29,7 @@ public class SimulationScheduler {
         job.schedule();\r
     }\r
 \r
-    public static synchronized SimulationScheduler start(SysdynModel model, Experiment experiment) {\r
+    public static synchronized SimulationScheduler start(SysdynModel model, SysdynExperiment experiment) {\r
         SimulationScheduler scheduler = model.getService(SimulationScheduler.class);\r
         if(scheduler == null || !scheduler.experiment.equals(experiment)) {\r
             scheduler = new SimulationScheduler(model, experiment);\r