]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Moved some import and result handling from sysdyn.ui to sysdyn (fixes #4314)
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 6 Jun 2013 05:34:04 +0000 (05:34 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 6 Jun 2013 05:34:04 +0000 (05:34 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27506 ac1ea38d-2e2b-0410-8846-a27921b304fc

21 files changed:
org.simantics.sysdyn.ontology/graph.tg
org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportFunctionLibrary.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModuleHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportFunctionLibrary.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModelHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModuleHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/imports/ImportUtilsUI.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/functions/WizardFunctionsImportPage.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/models/WizardModelsImportPage.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/modules/WizardModulesImportPage.java
org.simantics.sysdyn/META-INF/MANIFEST.MF
org.simantics.sysdyn/src/org/simantics/sysdyn/Activator.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/ActiveResults.java [new file with mode: 0644]
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SaveResultJob.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java
org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/imports/ImportUtils.java with 90% similarity]
org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/SysdynFunctionLibraryImportAdvisor.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/imports/SysdynFunctionLibraryImportAdvisor.java with 95% similarity]
org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/SysdynImportFormatHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/imports/SysdynImportFormatHandler.java with 95% similarity]

index 66e2ea9e8141a34ad0e972fc6fa54460534b1138..91680a01d01b3ff3b2082be580408d8504300464 100644 (file)
Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ
index 9fa3788b7f7159780e00bbce6369a36b8fb51d02..809a1425befc1ffe0597c5b355238d841755a672 100644 (file)
@@ -392,6 +392,8 @@ SYSDYN.Result <T L0.Entity
     >-- SYSDYN.Result.resultFile --> L0.String <R L0.HasProperty
     >-- SYSDYN.Result.showResult --> SYSDYN.Result <R L0.IsRelatedTo : L0.Tag
         @L0.symmetric
+    >-- SYSDYN.Result.time --> L0.Long <R L0.HasProperty : L0.FunctionalRelation
+        
         
 SYSDYN.HistoryDataset <T SYSDYN.Result
     @L0.singleProperty L0.HasName
index 6f63e23e93c944af0cc0370c2e8c6e78f5f519d9..97525b65a01d7acb39365c2ea40a22affd83542e 100644 (file)
@@ -543,6 +543,8 @@ public class SysdynResource {
     public final Resource Result_resultFile;\r
     public final Resource Result_resultFile_Inverse;\r
     public final Resource Result_showResult;\r
+    public final Resource Result_time;\r
+    public final Resource Result_time_Inverse;\r
     public final Resource Right;\r
     public final Resource SelectedSharedFunctionLibraries;\r
     public final Resource SensitivityAnalysisExperiment;\r
@@ -1269,6 +1271,8 @@ public class SysdynResource {
         public static final String Result_resultFile = "http://www.simantics.org/Sysdyn-1.1/Result/resultFile";\r
         public static final String Result_resultFile_Inverse = "http://www.simantics.org/Sysdyn-1.1/Result/resultFile/Inverse";\r
         public static final String Result_showResult = "http://www.simantics.org/Sysdyn-1.1/Result/showResult";\r
+        public static final String Result_time = "http://www.simantics.org/Sysdyn-1.1/Result/time";\r
+        public static final String Result_time_Inverse = "http://www.simantics.org/Sysdyn-1.1/Result/time/Inverse";\r
         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
@@ -2005,6 +2009,8 @@ public class SysdynResource {
         Result_resultFile = getResourceOrNull(graph, URIs.Result_resultFile);\r
         Result_resultFile_Inverse = getResourceOrNull(graph, URIs.Result_resultFile_Inverse);\r
         Result_showResult = getResourceOrNull(graph, URIs.Result_showResult);\r
+        Result_time = getResourceOrNull(graph, URIs.Result_time);\r
+        Result_time_Inverse = getResourceOrNull(graph, URIs.Result_time_Inverse);\r
         Right = getResourceOrNull(graph, URIs.Right);\r
         SelectedSharedFunctionLibraries = getResourceOrNull(graph, URIs.SelectedSharedFunctionLibraries);\r
         SensitivityAnalysisExperiment = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment);\r
index e583355eaf41e5657ea1a91579fe66e89fb08350..002abbbd1716049e4e18040c244480ab46da9b57 100644 (file)
@@ -35,7 +35,7 @@ import org.simantics.graph.db.TransferableGraphSource;
 import org.simantics.graph.db.TransferableGraphs;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.ResourceAdaptionUtils;\r
 \r
@@ -81,7 +81,7 @@ public class ExportFunctionLibrary  extends AbstractHandler {
                FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
                fd.setText("Export Function Library");\r
                fd.setFileName(name);\r
-               String path = Activator.getDefault().getPreferenceStore().getString(ImportUtils.IMPORTFUNCTIONLIBRARYPATH);\r
+               String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTFUNCTIONLIBRARYPATH);\r
                if(path.isEmpty() || !(new File(path).exists()))\r
                        path = Platform.getLocation().toOSString();\r
                fd.setFilterPath(path);\r
@@ -92,7 +92,7 @@ public class ExportFunctionLibrary  extends AbstractHandler {
                if(selected == null) return null;\r
                \r
                // Save location to preference store\r
-               Activator.getDefault().getPreferenceStore().setValue(ImportUtils.IMPORTFUNCTIONLIBRARYPATH, (new File(selected)).getParent());\r
+               Activator.getDefault().getPreferenceStore().setValue(ImportUtilsUI.IMPORTFUNCTIONLIBRARYPATH, (new File(selected)).getParent());\r
 \r
                // Asynchronously create the file using transferable graph\r
                SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
index c8c106b14633a31df7f56cc2a145ce3f6b53c38e..e82df8580c84ba5b6e6a9bd7ef8be9ab2c737bc7 100644 (file)
@@ -35,7 +35,7 @@ import org.simantics.graph.db.TransferableGraphSource;
 import org.simantics.graph.db.TransferableGraphs;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.ResourceAdaptionUtils;\r
 \r
@@ -82,7 +82,7 @@ public class ExportModelHandler extends AbstractHandler {
                FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
                fd.setText("Export Model");\r
                fd.setFileName(name);\r
-               String path = Activator.getDefault().getPreferenceStore().getString(ImportUtils.IMPORTMODELTPATH);\r
+               String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTMODELTPATH);\r
                if(path.isEmpty() || !(new File(path).exists()))\r
                        path = Platform.getLocation().toOSString();\r
                fd.setFilterPath(path);\r
@@ -93,7 +93,7 @@ public class ExportModelHandler extends AbstractHandler {
                if(selected == null) return null;\r
 \r
                // Save location to preference store\r
-               Activator.getDefault().getPreferenceStore().setValue(ImportUtils.IMPORTMODELTPATH, (new File(selected)).getParent());\r
+               Activator.getDefault().getPreferenceStore().setValue(ImportUtilsUI.IMPORTMODELTPATH, (new File(selected)).getParent());\r
 \r
                // Asynchronously create the file using transferable graph\r
                SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
index 53bb5203565b83bb4c29a352bdbfbbb140e12f0a..7d7e7fcf62c91827dc197eae6db360ca33615958 100644 (file)
@@ -46,7 +46,7 @@ import org.simantics.modeling.ModelingResources;
 import org.simantics.structural.stubs.StructuralResource2;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.ResourceAdaptionUtils;\r
 import org.simantics.utils.datastructures.Pair;\r
@@ -150,7 +150,7 @@ public class ExportModuleHandler extends AbstractHandler {
                FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
                fd.setText("Export Module");\r
                fd.setFileName(name);\r
-               String path = Activator.getDefault().getPreferenceStore().getString(ImportUtils.IMPORTMODULETPATH);\r
+               String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTMODULETPATH);\r
                if(path.isEmpty() || !(new File(path).exists()))\r
                        path = Platform.getLocation().toOSString();\r
                fd.setFilterPath(path);\r
@@ -161,7 +161,7 @@ public class ExportModuleHandler extends AbstractHandler {
                if(selected == null) return null;\r
                \r
         // Save location to preference store\r
-               Activator.getDefault().getPreferenceStore().setValue(ImportUtils.IMPORTMODULETPATH, (new File(selected)).getParent());\r
+               Activator.getDefault().getPreferenceStore().setValue(ImportUtilsUI.IMPORTMODULETPATH, (new File(selected)).getParent());\r
                \r
         // Asynchronously create the file using transferable graph\r
                SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
index 5eb21b0af3b23a5aa169675faaf2a195897bbab1..cdd40a04ca91c5fae0d3f2bd75b77d549d23780d 100644 (file)
@@ -29,7 +29,7 @@ import org.simantics.DatabaseJob;
 import org.simantics.db.Resource;\r
 import org.simantics.sysdyn.ui.Activator;\r
 import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
 import org.simantics.ui.utils.ResourceAdaptionUtils;\r
 import org.simantics.utils.ui.AdaptionUtils;\r
 \r
@@ -57,11 +57,11 @@ public class ImportFunctionLibrary  extends AbstractHandler {
         \r
         \r
         // Get a transferable graph file\r
-               final Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+               Shell shell = HandlerUtil.getActiveShellChecked(event);\r
                FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
                fd.setText("Import Function Library");\r
                \r
-               String path = Activator.getDefault().getPreferenceStore().getString(ImportUtils.IMPORTFUNCTIONLIBRARYPATH);\r
+               String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTFUNCTIONLIBRARYPATH);\r
                if(path.isEmpty() || !(new File(path).exists()))\r
                    path = Platform.getLocation().toOSString();\r
                fd.setFilterPath(path);\r
@@ -74,7 +74,7 @@ public class ImportFunctionLibrary  extends AbstractHandler {
 \r
                    @Override\r
                    protected IStatus run(IProgressMonitor monitor) {\r
-                       IStatus status = ImportUtils.importFunctionLibrary(functionLibrary, selected, shell, monitor);\r
+                       IStatus status = ImportUtilsUI.importFunctionLibrary(functionLibrary, selected, monitor);\r
                        return status;\r
                    }\r
                };\r
index f08a7b76a3bb7dc90e325173084b8a1f49f7e8ff..daba04a424de264218d46b265c2655fec7afd282 100644 (file)
@@ -26,7 +26,7 @@ import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.handlers.HandlerUtil;\r
 import org.simantics.DatabaseJob;\r
 import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
 \r
 /**\r
  * Imports models from exported transferable graph files.\r
@@ -40,11 +40,11 @@ public class ImportModelHandler extends AbstractHandler {
     public Object execute(ExecutionEvent event) throws ExecutionException {\r
 \r
         // Get imported transferable graph file using FileDialog\r
-        final Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+        Shell shell = HandlerUtil.getActiveShellChecked(event);\r
         FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
         fd.setText("Import Model");\r
 \r
-        String path = Activator.getDefault().getPreferenceStore().getString(ImportUtils.IMPORTMODELTPATH);\r
+        String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTMODELTPATH);\r
         if(path.isEmpty() || !(new File(path).exists()))\r
             path = Platform.getLocation().toOSString();\r
         fd.setFilterPath(path);\r
@@ -57,7 +57,7 @@ public class ImportModelHandler extends AbstractHandler {
 \r
             @Override\r
             protected IStatus run(IProgressMonitor monitor) {\r
-                IStatus status = ImportUtils.importModelFile(selected, shell, monitor);\r
+                IStatus status = ImportUtilsUI.importModelFile(selected, monitor);\r
                 return status;\r
             }\r
         };\r
index 9b7f587761de38ae5ca859b7072909e178767ef6..e4645106910a8684544a0a9f3eb3c3f0352b0aa7 100644 (file)
@@ -29,7 +29,7 @@ import org.simantics.DatabaseJob;
 import org.simantics.browsing.ui.common.node.AbstractNode;\r
 import org.simantics.db.Resource;\r
 import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
 import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
@@ -53,11 +53,11 @@ public class ImportModuleHandler extends AbstractHandler {
                final Resource model = node.data;\r
 \r
                // Get imported transferable graph file using FileDialog\r
-               final Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+               Shell shell = HandlerUtil.getActiveShellChecked(event);\r
                FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
                fd.setText("Import Module");\r
 \r
-               String path = Activator.getDefault().getPreferenceStore().getString(ImportUtils.IMPORTMODULETPATH);\r
+               String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTMODULETPATH);\r
                if(path.isEmpty() || !(new File(path).exists()))\r
                        path = Platform.getLocation().toOSString();\r
                fd.setFilterPath(path);\r
@@ -70,7 +70,7 @@ public class ImportModuleHandler extends AbstractHandler {
 \r
             @Override\r
             protected IStatus run(IProgressMonitor monitor) {\r
-                IStatus status = ImportUtils.importModuleFile(model, selected, shell, monitor);\r
+                IStatus status = ImportUtilsUI.importModuleFile(model, selected, monitor);\r
                 return status;\r
             }\r
         };\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/imports/ImportUtilsUI.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/imports/ImportUtilsUI.java
new file mode 100644 (file)
index 0000000..3e0eed5
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************\r
+ * Copyright (c) 2012 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
+ *     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
+import java.io.File;\r
+\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.simantics.db.Resource;\r
+import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.sysdyn.utils.imports.ImportUtils;\r
+\r
+/**\r
+ * Utilities for importing tg files: Models, Modules and Function libraries\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class ImportUtilsUI {\r
+\r
+    public static String IMPORTMODELTPATH = "IMPORT_MODEL_PATH";\r
+    public static String IMPORTMODULETPATH = "IMPORT_MODULE_PATH";\r
+    public static String IMPORTFUNCTIONLIBRARYPATH = "IMPORT_FUNCTION_LIBRARY_PATH";\r
+\r
+\r
+    /* ********************************* */\r
+    /* *******   IMPORT MODEL  ********* */\r
+    /* ********************************* */\r
+    public static IStatus importModelFile(String path, IProgressMonitor monitor) {\r
+        Activator.getDefault().getPreferenceStore().setValue(IMPORTMODELTPATH, (new File(path)).getParent());\r
+        return ImportUtils.importModelFile(path, monitor);\r
+    }\r
+\r
+\r
+    /* ********************************* */\r
+    /* *******  IMPORT MODULE  ********* */\r
+    /* ********************************* */\r
+    public static IStatus importModuleFile(Resource model, String path, IProgressMonitor monitor) {\r
+        Activator.getDefault().getPreferenceStore().setValue(IMPORTMODULETPATH, (new File(path)).getParent());\r
+        return ImportUtils.importModuleFile(model, path, monitor);\r
+    }\r
+\r
+\r
+\r
+    /* ********************************* */\r
+    /* ***  IMPORT FUNCTION LIBRARY  *** */\r
+    /* ********************************* */\r
+\r
+    public static IStatus importFunctionLibrary(Resource functionLibrary, String path, IProgressMonitor monitor) {\r
+        Activator.getDefault().getPreferenceStore().setValue(IMPORTFUNCTIONLIBRARYPATH, (new File(path)).getParent());\r
+        return ImportUtils.importFunctionLibrary(functionLibrary, path, monitor);\r
+    }\r
+\r
+}\r
index ee210702f23e2a94a7259fc5f65d736656c8b80a..3e5600aeb1f5395c20a713f7119ae23cb9383f0e 100644 (file)
@@ -33,7 +33,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.datastructures.ArrayMap;\r
 \r
@@ -281,7 +281,7 @@ public class WizardFunctionsImportPage extends WizardPage{
                        return false;\r
                }\r
                \r
-               IStatus status = ImportUtils.importFunctionLibrary(selectedModel, selected, shell, null);\r
+               IStatus status = ImportUtilsUI.importFunctionLibrary(selectedModel, selected, null);\r
 \r
                /*\r
                TransferableGraph1 tg = null;\r
index 3f041ee5841956626ca0897e79938eec50caa32f..636fd688f1bee30f439de0cc0bed74f463da25d1 100644 (file)
@@ -24,7 +24,7 @@ import org.eclipse.swt.widgets.Text;
 import org.simantics.db.Resource;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
 public class WizardModelsImportPage extends WizardPage{\r
@@ -160,7 +160,7 @@ public class WizardModelsImportPage extends WizardPage{
                \r
                dialog.setText("Import Model");\r
 \r
-               String path = Activator.getDefault().getPreferenceStore().getString(ImportUtils.IMPORTMODELTPATH);\r
+               String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTMODELTPATH);\r
                if(path.isEmpty() || !(new File(path).exists()))\r
                        path = Platform.getLocation().toOSString();\r
                dialog.setFilterPath(path);\r
@@ -188,7 +188,7 @@ public class WizardModelsImportPage extends WizardPage{
                        return false;\r
                }\r
                \r
-               IStatus status = ImportUtils.importModelFile(selected, shell, null);\r
+               IStatus status = ImportUtilsUI.importModelFile(selected, null);\r
                \r
         /*\r
                TransferableGraph1 tg = null;\r
index 9c08c02e780cdb42e933e0ec29e83ca9cf97331f..659767910c84867983b0f40aae8f2b27fb4907e6 100644 (file)
@@ -33,7 +33,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.datastructures.ArrayMap;\r
 \r
@@ -283,7 +283,7 @@ public class WizardModulesImportPage extends WizardPage{
                        return false;\r
                }\r
                \r
-               IStatus status = ImportUtils.importModuleFile(selectedModel, selected, shell, null);\r
+               IStatus status = ImportUtilsUI.importModuleFile(selectedModel, selected, null);\r
                \r
                /*\r
                TransferableGraph1 tg = null;\r
index 8e6fd2e3bd88efcf9e93b1bc7399878f469a1293..39ecd3f7bb6bd3cec5b3b2aaf1f825b555333297 100644 (file)
@@ -27,7 +27,9 @@ Require-Bundle: org.simantics.objmap;bundle-version="0.1.0",
  org.eclipse.jface.text;bundle-version="3.6.1",
  org.simantics.spreadsheet.ontology;bundle-version="1.2.0",
  org.simantics.fmu;bundle-version="1.0.0",
- org.simantics.fmu.me.win32;bundle-version="1.0.0"
+ org.simantics.fmu.me.win32;bundle-version="1.0.0",
+ org.simantics.issues;bundle-version="1.1.0",
+ org.simantics.issues.common;bundle-version="1.1.0"
 Export-Package: org.simantics.sysdyn,
  org.simantics.sysdyn.adapter,
  org.simantics.sysdyn.expressionParser,
@@ -41,7 +43,8 @@ Export-Package: org.simantics.sysdyn,
  org.simantics.sysdyn.representation.utils,
  org.simantics.sysdyn.representation.visitors,
  org.simantics.sysdyn.simulation,
- org.simantics.sysdyn.tableParser
+ org.simantics.sysdyn.tableParser,
+ org.simantics.sysdyn.utils.imports
 Bundle-Activator: org.simantics.sysdyn.Activator
 Bundle-ActivationPolicy: lazy
 Import-Package: org.eclipse.ui
index 375e21b30fe166ae59014d7792997728b2dee83a..640c85fe6842974434cdcb48feb81e31d1e88e19 100644 (file)
@@ -20,6 +20,12 @@ public class Activator implements BundleActivator {
 \r
     private static BundleContext bundleContext;\r
     \r
+    // The plug-in ID\r
+    public static final String PLUGIN_ID = "org.simantics.sysdyn";\r
+    \r
+    // The shared instance\r
+    private static Activator plugin;\r
+    \r
     @Override\r
     public void start(BundleContext context) throws Exception {\r
         bundleContext = context;\r
@@ -27,6 +33,7 @@ public class Activator implements BundleActivator {
         if (!modelsDir.exists()) {\r
             modelsDir.mkdir();\r
         }\r
+        plugin = this;\r
     }\r
 \r
     @Override\r
@@ -35,6 +42,12 @@ public class Activator implements BundleActivator {
         if (modelsDir.exists()) {\r
             recursiveDelete(modelsDir);\r
         }\r
+        plugin = null;\r
+\r
+    }\r
+\r
+    public static Activator getDefault() {\r
+        return plugin;\r
     }\r
 \r
     public static BundleContext getBundleContext() {\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/ActiveResults.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/ActiveResults.java
new file mode 100644 (file)
index 0000000..5e1f3fa
--- /dev/null
@@ -0,0 +1,62 @@
+/*******************************************************************************\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.manager;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class ActiveResults implements Read<Collection<Resource>>{\r
+    \r
+    private Resource resource;\r
+    \r
+    public ActiveResults(Resource resource) {\r
+        this.resource = resource;\r
+    }\r
+\r
+    @Override\r
+    public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {\r
+        Layer0 L0 = Layer0.getInstance(graph);\r
+        SysdynResource SR = SysdynResource.getInstance(graph);\r
+        ModelingResources MR = ModelingResources.getInstance(graph);\r
+        \r
+        Collection<Resource> result = new ArrayList<Resource>();\r
+        \r
+        Collection<Resource> experiments;\r
+        if(graph.isInstanceOf(resource, MR.StructuralModel))\r
+            experiments = graph.syncRequest(new ObjectsWithType(resource, L0.ConsistsOf, SR.Experiment));\r
+        else {\r
+            experiments = new ArrayList<Resource>();\r
+            experiments.add(resource);\r
+        }\r
+            \r
+        for(Resource experiment : experiments) {\r
+            Collection<Resource> experimentResults = graph.getObjects(experiment, SR.Experiment_result);\r
+            for(Resource r : experimentResults) {\r
+                if(graph.hasStatement(r, SR.Result_showResult)) {\r
+                   result.add(r);\r
+                }\r
+            }\r
+        }\r
+        \r
+        return result;\r
+    }\r
+\r
+}\r
index 797bdc6865b7cf8a251a85b12b43dabb64bda44a..7b0ea6baadd62f9b6246932e9af4322dd4ffb633 100644 (file)
@@ -94,7 +94,8 @@ public class SaveResultJob extends Job {
                             l0.HasLabel, name,\r
                             l0.HasName, name,\r
                             l0.PartOf, model,\r
-                            sr.Result_resultFile, file.getAbsolutePath());\r
+                            sr.Result_resultFile, file.getAbsolutePath(),\r
+                            sr.Result_time, System.currentTimeMillis());\r
                     graph.claim(experiment.getResource(), sr.Experiment_result, res);\r
                 }\r
             });\r
index e4c554339f7baa42f9d14dec3bb57842a9a91a24..4d091dc64cee19bf6acbe0073412df52a616433c 100644 (file)
@@ -26,7 +26,6 @@ import org.simantics.Simantics;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.Session;\r
-import org.simantics.db.common.request.ObjectsWithType;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
@@ -195,27 +194,24 @@ public class SysdynModel implements IMappingListener, IModel, VariableSubscripti
                     Resource model = graph.getPossibleObject(getConfigurationResource(), SIMU.IsConfigurationOf);\r
                     if(model == null)\r
                         return null;\r
-                    Collection<Resource> experiments = graph.syncRequest(new ObjectsWithType(model, l0.ConsistsOf, sr.Experiment));\r
-                    for(Resource experiment : experiments) {\r
-                        Collection<Resource> experimentResults = graph.getObjects(experiment, sr.Experiment_result);\r
-                        for(Resource result : experimentResults) {\r
-                            if(graph.hasStatement(result, sr.Result_showResult)) {\r
-                                SysdynResult sysdynResult = null;\r
-                                if(graph.isInstanceOf(result, sr.HistoryDataset)) {\r
-                                    HistoryDatasetResult r = new HistoryDatasetResult();\r
-                                    listeningHistories.add(r);\r
-                                    sysdynResult = new MemoryResult(r, NameUtils.getSafeLabel(graph, result));\r
-                                    r.read((MemoryResult)sysdynResult, result);\r
-                                } else {\r
-                                    sysdynResult = new FileResult(\r
-                                            (String) graph.getPossibleRelatedValue(result, l0.HasLabel),\r
-                                            (String) graph.getPossibleRelatedValue(result, sr.Result_resultFile));\r
-                                }\r
-                                \r
-                                if(sysdynResult != null)\r
-                                    displayedResults.add(sysdynResult);\r
-\r
+                    \r
+                    Collection<Resource> results = graph.syncRequest(new ActiveResults(model));\r
+                    for(Resource result : results) {\r
+                        if(graph.hasStatement(result, sr.Result_showResult)) {\r
+                            SysdynResult sysdynResult = null;\r
+                            if(graph.isInstanceOf(result, sr.HistoryDataset)) {\r
+                                HistoryDatasetResult r = new HistoryDatasetResult();\r
+                                listeningHistories.add(r);\r
+                                sysdynResult = new MemoryResult(r, NameUtils.getSafeLabel(graph, result));\r
+                                r.read((MemoryResult)sysdynResult, result);\r
+                            } else {\r
+                                sysdynResult = new FileResult(\r
+                                        (String) graph.getPossibleRelatedValue(result, l0.HasLabel),\r
+                                        (String) graph.getPossibleRelatedValue(result, sr.Result_resultFile));\r
                             }\r
+\r
+                            if(sysdynResult != null)\r
+                                displayedResults.add(sysdynResult);\r
                         }\r
                     }\r
                 } catch (Exception e) {\r
similarity index 90%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/imports/ImportUtils.java
rename to org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java
index d7fae469215f8e05ae7238f9cbd60a5d36a5fbea..48ee948cca9a44c52128bf6082ed4a1b0a019434 100644 (file)
@@ -10,7 +10,7 @@
  *     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
+package org.simantics.sysdyn.utils.imports;\r
 \r
 import java.io.File;\r
 import java.io.IOException;\r
@@ -26,7 +26,6 @@ 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.SubMonitor;\r
-import org.eclipse.swt.widgets.Shell;\r
 import org.simantics.Simantics;\r
 import org.simantics.databoard.container.DataContainers;\r
 import org.simantics.databoard.container.DataFormatException;\r
@@ -61,8 +60,7 @@ import org.simantics.operation.Layer0X;
 import org.simantics.simulation.ontology.SimulationResource;\r
 import org.simantics.structural.stubs.StructuralResource2;\r
 import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.ui.SimanticsUI;\r
+import org.simantics.sysdyn.Activator;\r
 \r
 /**\r
  * Utilities for importing tg files: Models, Modules and Function libraries\r
@@ -71,10 +69,6 @@ import org.simantics.ui.SimanticsUI;
  */\r
 public class ImportUtils {\r
 \r
-    public static String IMPORTMODELTPATH = "IMPORT_MODEL_PATH";\r
-    public static String IMPORTMODULETPATH = "IMPORT_MODULE_PATH";\r
-    public static String IMPORTFUNCTIONLIBRARYPATH = "IMPORT_FUNCTION_LIBRARY_PATH";\r
-\r
     /**\r
      * Null-checked begin task for monitor\r
      * @param monitor\r
@@ -139,21 +133,19 @@ public class ImportUtils {
     /* ********************************* */\r
     /* *******   IMPORT MODEL  ********* */\r
     /* ********************************* */\r
-    public static IStatus importModelFile(String path, final Shell shell, final IProgressMonitor monitor) {\r
-        final Resource project = SimanticsUI.getProject().get();\r
+    public static IStatus importModelFile(String path, final IProgressMonitor monitor) {\r
+        final Resource project = Simantics.getProject().get();\r
         if(project == null) return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model: project not found", null);\r
 \r
         beginTask(monitor, "Import model", 9);\r
 \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
         Resource result = null;\r
         try {\r
-            result = MigrationUtils.importMigrated(monitor, SimanticsUI.getSession(), new File(path), state, new DefaultPasteImportAdvisor(project), project);\r
+            result = MigrationUtils.importMigrated(monitor, Simantics.getSession(), new File(path), state, new DefaultPasteImportAdvisor(project), project);\r
         } catch (Exception e1) {\r
             e1.printStackTrace();\r
         }\r
@@ -163,7 +155,7 @@ public class ImportUtils {
         } else {\r
             try {\r
                 final Resource ModelRoot = result;\r
-                IStatus status = SimanticsUI.getSession().syncRequest(new WriteResultRequest<IStatus>()  {\r
+                IStatus status = Simantics.getSession().syncRequest(new WriteResultRequest<IStatus>()  {\r
 \r
                     @Override\r
                     public IStatus perform(WriteGraph graph) throws DatabaseException {\r
@@ -213,7 +205,7 @@ public class ImportUtils {
                     return status;\r
 \r
                 subTask(monitor, "Validate model");\r
-                Collection<Resource> confs = SimanticsUI.getSession().syncRequest(new Read<Collection<Resource>>() {\r
+                Collection<Resource> confs = Simantics.getSession().syncRequest(new Read<Collection<Resource>>() {\r
 \r
                     @Override\r
                     public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {\r
@@ -399,19 +391,16 @@ public class ImportUtils {
     /* ********************************* */\r
     /* *******  IMPORT MODULE  ********* */\r
     /* ********************************* */\r
-    public static IStatus importModuleFile(final Resource model, String path, final Shell shell, final IProgressMonitor monitor) {\r
+    public static IStatus importModuleFile(final Resource model, String path, final IProgressMonitor monitor) {\r
         beginTask(monitor, "Import Module", 3);\r
 \r
-\r
-        Activator.getDefault().getPreferenceStore().setValue(IMPORTMODULETPATH, (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
         Resource result = null;\r
         try {\r
-            result = MigrationUtils.importMigrated(monitor, SimanticsUI.getSession(), new File(path), state, new DefaultPasteImportAdvisor(model), model);\r
+            result = MigrationUtils.importMigrated(monitor, Simantics.getSession(), new File(path), state, new DefaultPasteImportAdvisor(model), model);\r
         } catch (Exception e1) {\r
             e1.printStackTrace();\r
         }\r
@@ -424,7 +413,7 @@ public class ImportUtils {
             // Check that the imported file actually was a module. Display error message otherwise.\r
             try {\r
                 subTask(monitor, "Validate model");\r
-                IStatus status = SimanticsUI.getSession().syncRequest(new WriteResultRequest<IStatus>()  {\r
+                IStatus status = Simantics.getSession().syncRequest(new WriteResultRequest<IStatus>()  {\r
 \r
                     @Override\r
                     public IStatus perform(WriteGraph graph) throws DatabaseException {\r
@@ -465,11 +454,9 @@ public class ImportUtils {
     /* ***  IMPORT FUNCTION LIBRARY  *** */\r
     /* ********************************* */\r
 \r
-    public static IStatus importFunctionLibrary(final Resource functionLibrary, final String path, final Shell shell, final IProgressMonitor monitor) {\r
+    public static IStatus importFunctionLibrary(final Resource functionLibrary, final String path, final IProgressMonitor monitor) {\r
         beginTask(monitor, "Import Module", 3);\r
 \r
-        Activator.getDefault().getPreferenceStore().setValue(IMPORTFUNCTIONLIBRARYPATH, (new File(path)).getParent());\r
-\r
         // Ensure that shared functions ontology exists\r
         ensureSharedOntologies();\r
         \r
@@ -479,7 +466,7 @@ public class ImportUtils {
 \r
         Resource result = null;\r
         try {\r
-            result = MigrationUtils.importMigrated(monitor, SimanticsUI.getSession(), new File(path), state, new DefaultPasteImportAdvisor(functionLibrary), functionLibrary);\r
+            result = MigrationUtils.importMigrated(monitor, Simantics.getSession(), new File(path), state, new DefaultPasteImportAdvisor(functionLibrary), functionLibrary);\r
         } catch (Exception e1) {\r
             e1.printStackTrace();\r
         }\r
@@ -491,7 +478,7 @@ public class ImportUtils {
             // Link the imported library to the selected resource (functionLibrary)\r
             try {\r
                 subTask(monitor, "Validate model");\r
-                IStatus status = SimanticsUI.getSession().syncRequest(new WriteResultRequest<IStatus>()  {\r
+                IStatus status = Simantics.getSession().syncRequest(new WriteResultRequest<IStatus>()  {\r
 \r
                     /**\r
                      * Link the imported library to the selected resource (functionLibrary)\r
@@ -556,7 +543,7 @@ public class ImportUtils {
         // Make sure the "http://SharedOntologies resource exists\r
         try {\r
             Boolean hasSharedOntologies;\r
-            hasSharedOntologies = SimanticsUI.getSession().syncRequest(new Read<Boolean>() {\r
+            hasSharedOntologies = Simantics.getSession().syncRequest(new Read<Boolean>() {\r
 \r
                 @Override\r
                 public Boolean perform(ReadGraph graph) throws DatabaseException {\r
@@ -570,7 +557,7 @@ public class ImportUtils {
             });\r
 \r
             if(!hasSharedOntologies) {\r
-                SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+                Simantics.getSession().syncRequest(new WriteRequest() {\r
 \r
                     @Override\r
                     public void perform(WriteGraph graph) throws DatabaseException {\r
similarity index 95%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/imports/SysdynFunctionLibraryImportAdvisor.java
rename to org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/SysdynFunctionLibraryImportAdvisor.java
index b23385af215b0ec089b37bdc32e44e7db95b611b..3373d68fc4961892c8b88be66b678a0fcacd3df1 100644 (file)
@@ -9,7 +9,7 @@
  * Contributors:\r
  *     VTT Technical Research Centre of Finland - initial API and implementation\r
  *******************************************************************************/\r
-package org.simantics.sysdyn.ui.utils.imports;\r
+package org.simantics.sysdyn.utils.imports;\r
 \r
 import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
similarity index 95%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/imports/SysdynImportFormatHandler.java
rename to org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/SysdynImportFormatHandler.java
index a7ae412909622ec6795f2ad53eadb90887f13e63..260c058b164e60bb42a0f197cb383ce78f6b8516 100644 (file)
@@ -9,7 +9,7 @@
  * Contributors:\r
  *     VTT Technical Research Centre of Finland - initial API and implementation\r
  *******************************************************************************/\r
-package org.simantics.sysdyn.ui.utils.imports;\r
+package org.simantics.sysdyn.utils.imports;\r
 \r
 import org.eclipse.core.runtime.IProgressMonitor;\r
 import org.eclipse.core.runtime.IStatus;\r
@@ -27,7 +27,7 @@ import org.simantics.db.layer0.migration.MigrationStateKeys;
 import org.simantics.db.layer0.migration.MigrationStep;\r
 import org.simantics.db.layer0.migration.MigrationUtils;\r
 import org.simantics.graph.representation.TransferableGraph1;\r
-import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.sysdyn.Activator;\r
 \r
 /**\r
  * Handler for migrating a tg and importing it to database\r