]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Refactoring handlers package. The package contained too many handlers. Added comments...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 8 Nov 2011 12:51:09 +0000 (12:51 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 8 Nov 2011 12:51:09 +0000 (12:51 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@23229 ac1ea38d-2e2b-0410-8846-a27921b304fc

22 files changed:
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportModuleHandler.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportExternalFunctionFilesHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportExternalFunctionFilesHandler.java with 82% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportFunctionLibrary.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportFunctionLibrary.java with 89% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportModelHandler.java with 88% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModuleHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportModuleHandler.java with 91% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportExternalFunctionFilesHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportExternalFunctionFilesHandler.java with 82% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportFunctionLibrary.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportFunctionLibrary.java with 83% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportMdlHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportMdlHandler.java with 88% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModelHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportModelHandler.java with 91% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModuleHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewEnumerationNodeHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewEnumerationNodeHandler.java with 72% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewExperimentNodeHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewExperimentNodeHandler.java with 81% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewFunctionHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionHandler.java with 87% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewFunctionLibraryHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionLibraryHandler.java with 93% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewModelHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java with 63% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewModuleNodeHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java with 94% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewPlaybackExperimentNodeHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewPlaybackExperimentNodeHandler.java with 92% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSharedFunctionLibraryHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewSharedFunctionLibraryHandler.java with 88% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSpreadSheetHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewSpreadSheetHandler.java with 58% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ExternalFilesTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/models/WizardModelsImportPage.java

index 2fa55a78e4c51efa26767e6e1b3e89f7a5e58def..336964455d1f78019ebac3f5394478da0f4a7259 100644 (file)
          </state>\r
       </command>\r
       <command\r
-            defaultHandler="org.simantics.sysdyn.ui.handlers.NewModuleNodeHandler"\r
+            defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewModuleNodeHandler"\r
             id="org.simantics.sysdyn.ui.newModuleNode"\r
             name="New Module">\r
       </command>\r
             name="Show in charts">\r
       </command>\r
       <command\r
-            defaultHandler="org.simantics.sysdyn.ui.handlers.NewExperimentNodeHandler"\r
+            defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewExperimentNodeHandler"\r
             id="org.simantics.sysdyn.ui.newExperiment"\r
             name="New Experiment">\r
       </command>\r
             name="Import .mdl">\r
       </command>\r
       <command\r
-            defaultHandler="org.simantics.sysdyn.ui.handlers.NewFunctionHandler"\r
+            defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewFunctionHandler"\r
             id="org.simantics.sysdyn.ui.newFunction"\r
             name="NewFunction">\r
       </command>\r
          </activeWhen>\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.ImportModelHandler"\r
+            class="org.simantics.sysdyn.ui.handlers.imports.ImportModelHandler"\r
             commandId="org.simantics.sysdyn.ui.importModel">\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.ExportModelHandler"\r
+            class="org.simantics.sysdyn.ui.handlers.exports.ExportModelHandler"\r
             commandId="org.simantics.sysdyn.ui.exportModel">\r
          <activeWhen>\r
             <with\r
          </activeWhen>\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.ImportMdlHandler"\r
+            class="org.simantics.sysdyn.ui.handlers.imports.ImportMdlHandler"\r
             commandId="org.simantics.sysdyn.ui.importMdl">\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.NewEnumerationNodeHandler"\r
+            class="org.simantics.sysdyn.ui.handlers.newComponents.NewEnumerationNodeHandler"\r
             commandId="org.simantics.sysdyn.ui.newEnumeration">\r
          <activeWhen>\r
             <with\r
          </activeWhen>\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.ImportExternalFunctionFilesHandler"\r
+            class="org.simantics.sysdyn.ui.handlers.imports.ImportExternalFunctionFilesHandler"\r
             commandId="org.simantics.sysdyn.ui.importExternalFunctionFile">\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.ExportExternalFunctionFilesHandler"\r
+            class="org.simantics.sysdyn.ui.handlers.exports.ExportExternalFunctionFilesHandler"\r
             commandId="org.simantics.sysdyn.ui.exportExternalFunctionFile">\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.NewFunctionLibraryHandler"\r
+            class="org.simantics.sysdyn.ui.handlers.newComponents.NewFunctionLibraryHandler"\r
             commandId="org.simantics.sysdyn.ui.newFunctionLibrary">\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.NewSharedFunctionLibraryHandler"\r
+            class="org.simantics.sysdyn.ui.handlers.newComponents.NewSharedFunctionLibraryHandler"\r
             commandId="org.simantics.sysdyn.ui.newSharedFunctionLibrary">\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.ExportFunctionLibrary"\r
+            class="org.simantics.sysdyn.ui.handlers.exports.ExportFunctionLibrary"\r
             commandId="org.simantics.sysdyn.ui.exportFunctionLibrary">\r
          <activeWhen>\r
             <with\r
          </activeWhen>\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.ImportFunctionLibrary"\r
+            class="org.simantics.sysdyn.ui.handlers.imports.ImportFunctionLibrary"\r
             commandId="org.simantics.sysdyn.ui.importFunctionLibrary">\r
          <activeWhen>\r
             <with\r
          </activeWhen>\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.ImportModuleHandler"\r
+            class="org.simantics.sysdyn.ui.handlers.imports.ImportModuleHandler"\r
             commandId="org.simantics.sysdyn.ui.importModule">\r
          <activeWhen>\r
             <with\r
          </activeWhen>\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.ExportModuleHandler"\r
+            class="org.simantics.sysdyn.ui.handlers.exports.ExportModuleHandler"\r
             commandId="org.simantics.sysdyn.ui.exportModule">\r
          <activeWhen>\r
             <with\r
          </activeWhen>\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.NewSpreadSheetHandler"\r
+            class="org.simantics.sysdyn.ui.handlers.newComponents.NewSpreadSheetHandler"\r
             commandId="org.simantics.sysdyn.ui.newSpreadSheet">\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.NewModelHandler"\r
+            class="org.simantics.sysdyn.ui.handlers.newComponents.NewModelHandler"\r
             commandId="org.simantics.sysdyn.ui.newModel">\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.NewPlaybackExperimentNodeHandler"\r
+            class="org.simantics.sysdyn.ui.handlers.newComponents.NewPlaybackExperimentNodeHandler"\r
             commandId="org.simantics.sysdyn.ui.newPlaybackExperiment">\r
       </handler>\r
    </extension>\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportModuleHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportModuleHandler.java
deleted file mode 100644 (file)
index acbfc95..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 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
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\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.core.runtime.Platform;\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.widgets.FileDialog;\r
-import org.eclipse.swt.widgets.MessageBox;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.ui.handlers.HandlerUtil;\r
-import org.simantics.browsing.ui.common.node.AbstractNode;\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.Files;\r
-import org.simantics.databoard.binding.error.RuntimeBindingConstructionException;\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.NameUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.adapter.impl.DefaultPasteHandler;\r
-import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor;\r
-import org.simantics.graph.db.MissingDependencyException;\r
-import org.simantics.graph.representation.TransferableGraph1;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
-\r
-public class ImportModuleHandler extends AbstractHandler {\r
-\r
-       public static String IMPORTMODULETPATH = "IMPORT_MODULE_PATH";\r
-       \r
-       @Override\r
-       public Object execute(ExecutionEvent event) throws ExecutionException {\r
-        ISelection sel = HandlerUtil.getCurrentSelection(event);\r
-        \r
-        @SuppressWarnings("unchecked")\r
-               AbstractNode<Resource> node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class);\r
-        if (node == null)\r
-            return null;\r
-\r
-        final Resource model = node.data;\r
-        \r
-               final 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(IMPORTMODULETPATH);\r
-               if(path.isEmpty() || !(new File(path).exists()))\r
-                       path = Platform.getLocation().toOSString();\r
-               fd.setFilterPath(path);\r
-               String[] filterExt = {"*.tg"};\r
-               fd.setFilterExtensions(filterExt);\r
-               String selected = fd.open();\r
-               if(selected == null) return null;\r
-\r
-               Activator.getDefault().getPreferenceStore().setValue(IMPORTMODULETPATH, (new File(selected)).getParent());\r
-               \r
-               TransferableGraph1 tg = null;\r
-               try {\r
-                       tg = (TransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class));\r
-               } catch (RuntimeBindingConstructionException e) {\r
-                       e.printStackTrace();\r
-               } catch (IOException e) {\r
-                       MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ERROR);\r
-                       mb.setText("Error");\r
-                       mb.setMessage("The imported file is not of type: Module Type");\r
-                       mb.open();\r
-                       return null;\r
-               }\r
-               if(tg == null) return null;\r
-\r
-               \r
-               DefaultPasteImportAdvisor ia = new DefaultPasteImportAdvisor(model);\r
-               try {\r
-                       DefaultPasteHandler.defaultExecute(tg, model, ia);\r
-               } catch (MissingDependencyException e) {\r
-                       e.printStackTrace();\r
-               } catch (Exception e) {\r
-                       e.printStackTrace();\r
-               }\r
-               \r
-               final Resource root = ia.getRoot();\r
-               \r
-               SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
-                       \r
-                       @Override\r
-                       public void perform(WriteGraph graph) throws DatabaseException {\r
-                               if(!graph.isInheritedFrom(root, SysdynResource.getInstance(graph).Module)) {\r
-                                       Resource instanceOf = graph.getPossibleObject(root, Layer0.getInstance(graph).InstanceOf);\r
-                                       String type = "...";\r
-                                       if(instanceOf != null)\r
-                                               type = NameUtils.getSafeName(graph, instanceOf);\r
-                                       else {\r
-                                               Resource inheritedFrom = graph.getPossibleObject(root, Layer0.getInstance(graph).Inherits);\r
-                                               if(inheritedFrom != null)\r
-                                                       type = NameUtils.getSafeName(graph, inheritedFrom);\r
-                                       }\r
-                                       final String ft = type; \r
-                                       graph.deny(root, Layer0.getInstance(graph).PartOf);\r
-                                       \r
-                                       shell.getDisplay().asyncExec(new Runnable() {\r
-                                               \r
-                                               @Override\r
-                                               public void run() {\r
-                                                       MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ERROR);\r
-                                                       mb.setText("Error");\r
-                                                       mb.setMessage("The imported file is not of type: System Dynamics Module (" + ft +")");\r
-                                                       mb.open();                                                              \r
-                                               }\r
-                                       });\r
-                               } \r
-                       }\r
-               });\r
-               return null;\r
-       }\r
-\r
-}\r
similarity index 82%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportExternalFunctionFilesHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportExternalFunctionFilesHandler.java
index 727bb8be423ec09769fcb7371276e470759b1d98..53b012c59286fff2800dec430734ae2fcec7daa1 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.handlers;\r
+package org.simantics.sysdyn.ui.handlers.exports;\r
 \r
 import java.io.FileOutputStream;\r
 import java.io.IOException;\r
@@ -32,12 +32,17 @@ import org.simantics.sysdyn.SysdynResource;
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.ResourceAdaptionUtils;\r
 \r
+/**\r
+ * Exports external function files from SysdynModelicaFunctions\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class ExportExternalFunctionFilesHandler extends AbstractHandler {\r
 \r
        @Override\r
        public Object execute(ExecutionEvent event) throws ExecutionException {\r
-\r
-               \r
+           // Find shell and resources to be exported\r
                Shell shell = HandlerUtil.getActiveShellChecked(event);\r
                ISelection sel = HandlerUtil.getCurrentSelection(event);\r
                final Resource[] resources = ResourceAdaptionUtils.toResources(sel);\r
@@ -47,7 +52,16 @@ public class ExportExternalFunctionFilesHandler extends AbstractHandler {
                return exportFiles(shell, resources);\r
        }\r
        \r
+       /**\r
+        * Exports selected file resources to files on disk. Assumes all resources are external files.\r
+        * \r
+        * @param shell SWT Shell\r
+        * @param resources External file resources\r
+        * @return null\r
+        */\r
        public static Object exportFiles(Shell shell, final Resource[] resources) {\r
+           \r
+           // Select a path where to export the files\r
                DirectoryDialog dd = new DirectoryDialog(shell);\r
                dd.setFilterPath(Platform.getLocation().toOSString());\r
                dd.setText("Export files to...");\r
@@ -62,6 +76,7 @@ public class ExportExternalFunctionFilesHandler extends AbstractHandler {
                        @Override\r
                        public void run(ReadGraph graph) throws DatabaseException {\r
                                SysdynResource sr = SysdynResource.getInstance(graph);\r
+                               // Get byte arrays from each resource and write them to disk\r
                                for(Resource r : resources) {\r
                                        try {\r
                                                String name = NameUtils.getSafeName(graph, r);\r
similarity index 89%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportFunctionLibrary.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportFunctionLibrary.java
index 38054f78c2f08506c3514824dd41b39eb9ffa016..0b65cfd8e4ed6270dd7ee0e30aebb47454527935 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.handlers;\r
+package org.simantics.sysdyn.ui.handlers.exports;\r
 \r
 import java.io.File;\r
 import java.io.IOException;\r
@@ -37,10 +37,17 @@ import org.simantics.db.request.Read;
 import org.simantics.graph.representation.TransferableGraph1;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.sysdyn.ui.handlers.imports.ImportFunctionLibrary;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.ResourceAdaptionUtils;\r
 import org.simantics.utils.datastructures.Pair;\r
 \r
+/**\r
+ * Exports a function library\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class ExportFunctionLibrary  extends AbstractHandler {\r
 \r
        @Override\r
@@ -68,8 +75,10 @@ public class ExportFunctionLibrary  extends AbstractHandler {
                } catch (DatabaseException e1) {\r
                        e1.printStackTrace();\r
                }\r
+               // Do not export if the resource has no name\r
                if(name == null) return null;\r
                \r
+               // Find a location (and name) for the exported library using FileDialog\r
                Shell shell = HandlerUtil.getActiveShellChecked(event);\r
                FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
                fd.setText("Export Function Library");\r
@@ -83,8 +92,10 @@ public class ExportFunctionLibrary  extends AbstractHandler {
                final String selected = fd.open();\r
                if(selected == null) return null;\r
                \r
+               // Save location to preference store\r
                Activator.getDefault().getPreferenceStore().setValue(ImportFunctionLibrary.IMPORTFUNCTIONLIBRARYPATH, (new File(selected)).getParent());\r
 \r
+               // Asynchronously create the file using transferable graph\r
                SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
                        \r
                        @Override\r
similarity index 88%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportModelHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelHandler.java
index f4e007dfb7b079023ebc2e8a5bcc868bf8c3329f..2c58e90c9bd0a311d6c6e1be7b515fc15395216b 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.handlers;\r
+package org.simantics.sysdyn.ui.handlers.exports;\r
 \r
 import java.io.File;\r
 import java.io.IOException;\r
@@ -37,10 +37,17 @@ import org.simantics.db.request.Read;
 import org.simantics.graph.representation.TransferableGraph1;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.sysdyn.ui.handlers.imports.ImportModelHandler;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.ResourceAdaptionUtils;\r
 import org.simantics.utils.datastructures.Pair;\r
 \r
+/**\r
+ * Exports a selected model\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class ExportModelHandler extends AbstractHandler {\r
 \r
        @Override\r
@@ -69,8 +76,10 @@ public class ExportModelHandler extends AbstractHandler {
                } catch (DatabaseException e1) {\r
                        e1.printStackTrace();\r
                }\r
+               // Do not export if the resource has no name\r
                if(name == null) return null;\r
                \r
+        // Find a location (and name) for the exported library using FileDialog\r
                Shell shell = HandlerUtil.getActiveShellChecked(event);\r
                FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
                fd.setText("Export Model");\r
@@ -84,8 +93,10 @@ public class ExportModelHandler extends AbstractHandler {
                final String selected = fd.open();\r
                if(selected == null) return null;\r
                \r
+        // Save location to preference store\r
                Activator.getDefault().getPreferenceStore().setValue(ImportModelHandler.IMPORTMODELTPATH, (new File(selected)).getParent());\r
                \r
+        // Asynchronously create the file using transferable graph\r
                SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
                        \r
                        @Override\r
similarity index 91%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportModuleHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModuleHandler.java
index 88bb8d8f3e08685e31aa3503bd37231d5855b0ea..ab804371a84f311cf81654486ac8139f5fd34361 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.handlers;\r
+package org.simantics.sysdyn.ui.handlers.exports;\r
 \r
 import java.io.File;\r
 import java.io.IOException;\r
@@ -46,17 +46,23 @@ 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.handlers.imports.ImportModuleHandler;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.ResourceAdaptionUtils;\r
 import org.simantics.utils.datastructures.Pair;\r
 \r
-public class ExportModuleHandler  extends AbstractHandler {\r
+/**\r
+ * Exports a selected module\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class ExportModuleHandler extends AbstractHandler {\r
 \r
        /**\r
         * Temporary exception. At this phase, the system will not support exporting modules\r
         * that depend on other modules. \r
         * \r
-        * @author TLTEEMU\r
+        * @author Teemu Lempinen\r
         *\r
         */\r
        class ContainsDependenciesException extends DatabaseException {\r
@@ -92,6 +98,7 @@ public class ExportModuleHandler  extends AbstractHandler {
                                        SysdynResource sr = SysdynResource.getInstance(graph);\r
                                        Layer0 l0 = Layer0.getInstance(graph);\r
                                        \r
+                                       // Start checking for module dependencies\r
                                        Resource component = graph.getPossibleObject(modulesymbol, mr.SymbolToComponentType);\r
                                        if (component == null || !graph.hasStatement(component, Layer0.getInstance(graph).PartOf))\r
                                                return null;\r
@@ -110,6 +117,7 @@ public class ExportModuleHandler  extends AbstractHandler {
                                        }\r
                                        if(dependencies != null && !dependencies.isEmpty())\r
                                                throw new ContainsDependenciesException(dependencies);\r
+                                       // End checking for module dependencies. If dependencies were found, an exception was thrown\r
                                        \r
                                        String name = graph.getPossibleRelatedValue(component, l0.HasName, Bindings.STRING);\r
                                        return name;\r
@@ -132,8 +140,11 @@ public class ExportModuleHandler  extends AbstractHandler {
                } catch (DatabaseException e1) {\r
                        e1.printStackTrace();\r
                }\r
+               \r
+        // Do not export if the resource has no name\r
                if(name == null) return null;\r
                \r
+        // Find a location (and name) for the exported library using FileDialog\r
                Shell shell = HandlerUtil.getActiveShellChecked(event);\r
                FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
                fd.setText("Export Module");\r
@@ -147,8 +158,10 @@ public class ExportModuleHandler  extends AbstractHandler {
                final String selected = fd.open();\r
                if(selected == null) return null;\r
                \r
+        // Save location to preference store\r
                Activator.getDefault().getPreferenceStore().setValue(ImportModuleHandler.IMPORTMODULETPATH, (new File(selected)).getParent());\r
                \r
+        // Asynchronously create the file using transferable graph\r
                SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
                        \r
                        @Override\r
similarity index 82%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportExternalFunctionFilesHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportExternalFunctionFilesHandler.java
index 2115825793ce2aacffd0092793bed779b80e8b33..f0052c6d6e573032727535c17231960ac1d1a8bc 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.handlers;\r
+package org.simantics.sysdyn.ui.handlers.imports;\r
 \r
 import java.io.File;\r
 import java.io.FileInputStream;\r
@@ -35,6 +35,12 @@ import org.simantics.sysdyn.manager.FunctionUtils;
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.datastructures.Pair;\r
 \r
+/**\r
+ * Imports external functions to SysdynModelicaFunctions using FileDialog.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class ImportExternalFunctionFilesHandler extends AbstractHandler {\r
 \r
        public static final String[] C_EXTENSIONS = {"*.c","*.h","*.a","*.o"};\r
@@ -56,10 +62,12 @@ public class ImportExternalFunctionFilesHandler extends AbstractHandler {
        }\r
        \r
        /**\r
-        * Import \r
-        * \r
-        * @param shell\r
-        * @return\r
+        * Opens a {@link FileDialog} to select the imported files.\r
+        *  \r
+        * @param shell SWT Shell\r
+        * @param text Header text for the FileDialog\r
+        * @param filter Filters for the FileDialog\r
+        * @return File names and paths for the files to be imported\r
         */\r
        public static Pair<String, String[]> importFiles(Shell shell, String text, String[] filter) {\r
                FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
@@ -70,6 +78,15 @@ public class ImportExternalFunctionFilesHandler extends AbstractHandler {
                return new Pair<String, String[]>(fd.getFilterPath(), fd.getFileNames());\r
        }\r
        \r
+       \r
+       /**\r
+        * Saves the given files as byte arrays to a function\r
+        * \r
+        * @param graph WriteGraph\r
+        * @param function Function where the files are to be added\r
+        * @param files Files to be added\r
+        * @throws DatabaseException\r
+        */\r
        public static void addFilesToFunction(WriteGraph graph, Resource function, Pair<String, String[]> files) throws DatabaseException {\r
                SysdynResource sr = SysdynResource.getInstance(graph);\r
                Layer0 l0 = Layer0.getInstance(graph);\r
similarity index 83%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportFunctionLibrary.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportFunctionLibrary.java
index 4730432ce4fd656b5d10150083de7a7b801a3773..b20206c43b08102b72e9f0aa61576ed3b37101c3 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.handlers;\r
+package org.simantics.sysdyn.ui.handlers.imports;\r
 \r
 import java.io.File;\r
 import java.io.IOException;\r
@@ -50,10 +50,18 @@ import org.simantics.ui.SimanticsUI;
 import org.simantics.ui.utils.AdaptionUtils;\r
 import org.simantics.ui.utils.ResourceAdaptionUtils;\r
 \r
+/**\r
+ * Imports an exported function library (or shared function library) transferable graph. \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class ImportFunctionLibrary  extends AbstractHandler {\r
        \r
        public static String IMPORTFUNCTIONLIBRARYPATH = "IMPORT_FUNCTION_LIBRARY_PATH";\r
 \r
+       /**\r
+        * Called from a functions folder node\r
+        */\r
        @Override\r
        public Object execute(ExecutionEvent event) throws ExecutionException {\r
         ISelection sel = HandlerUtil.getCurrentSelection(event);\r
@@ -66,6 +74,8 @@ public class ImportFunctionLibrary  extends AbstractHandler {
         \r
         final Resource functionLibrary = r;\r
         \r
+        \r
+        // Get a transferable graph file\r
                final Shell shell = HandlerUtil.getActiveShellChecked(event);\r
                FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
                fd.setText("Import Function Library");\r
@@ -81,6 +91,7 @@ public class ImportFunctionLibrary  extends AbstractHandler {
 \r
                Activator.getDefault().getPreferenceStore().setValue(IMPORTFUNCTIONLIBRARYPATH, (new File(selected)).getParent());\r
                \r
+               // Load the transferable graph\r
                TransferableGraph1 tg = null;\r
                try {\r
                        tg = (TransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class));\r
@@ -96,7 +107,7 @@ public class ImportFunctionLibrary  extends AbstractHandler {
                } \r
                if(tg == null) return null;\r
 \r
-       \r
+               // Make sure the "http://SharedOntologies resource exists\r
                try {\r
                        Boolean hasSharedOntologies;\r
                        hasSharedOntologies = SimanticsUI.getSession().syncRequest(new Read<Boolean>() {\r
@@ -131,6 +142,7 @@ public class ImportFunctionLibrary  extends AbstractHandler {
                }\r
 \r
                \r
+               // Import a function library from the transferable graph\r
                SysdynFunctionLibraryImportAdvisor ia = new SysdynFunctionLibraryImportAdvisor(functionLibrary);\r
                try {\r
                        DefaultPasteHandler.defaultExecute(tg, functionLibrary, ia);\r
@@ -138,19 +150,26 @@ public class ImportFunctionLibrary  extends AbstractHandler {
                        e.printStackTrace();\r
                }\r
                \r
-               final Resource root = ia.getRoot();\r
+               final Resource root = ia.getRoot(); // Root of the library\r
                \r
+               // Link the imported library to the selected resource (functionLibrary)\r
                SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
                        \r
+                   /**\r
+                    * Link the imported library to the selected resource (functionLibrary)\r
+                    * The imported library can be either SysdynModelicaFunctionLibrary or SysdynFunctionOntology\r
+                    */\r
                        @Override\r
                        public void perform(WriteGraph graph) throws DatabaseException {\r
                            Layer0 l0 = Layer0.getInstance(graph);\r
+                           // Case: SharedFunctionOntology. Link to SharedOntologies\r
                            if(graph.isInstanceOf(root, SysdynResource.getInstance(graph).SharedFunctionOntology)) {\r
                                Resource library = graph.getResource("http://SharedOntologies");\r
                                if(!graph.hasStatement(library, l0.ConsistsOf, root)) {\r
                                    graph.claim(library, l0.ConsistsOf, root);\r
                                }\r
 \r
+                               // Link model to the shared library\r
                                SysdynResource sr = SysdynResource.getInstance(graph);\r
                                Resource model = functionLibrary;\r
                                while(!graph.isInstanceOf(model, sr.SysdynModel) && graph.isInstanceOf(model, l0.Ontology))\r
@@ -159,6 +178,7 @@ public class ImportFunctionLibrary  extends AbstractHandler {
                                    graph.claim(model, l0.IsLinkedTo, l0.IsLinkedTo_Inverse, root);\r
                                }\r
 \r
+                               // Case: not SharedFunctionOntology or SysdynModelicaFunctionLibrary. \r
                            } else if(!graph.isInstanceOf(root, SysdynResource.getInstance(graph).SysdynModelicaFunctionLibrary)) {\r
                                        Resource instanceOf = graph.getPossibleObject(root,l0.InstanceOf);\r
                                        String type = "...";\r
@@ -170,8 +190,11 @@ public class ImportFunctionLibrary  extends AbstractHandler {
                                                        type = NameUtils.getSafeName(graph, inheritedFrom);\r
                                        }\r
                                        final String ft = type; \r
+                                       \r
+                                       // Remove the functionLibrary ConsistsOf root relation\r
                                        graph.deny(root, l0.PartOf);\r
                                        \r
+                                       // Display error message\r
                                        shell.getDisplay().asyncExec(new Runnable() {\r
                                                \r
                                                @Override\r
@@ -183,6 +206,7 @@ public class ImportFunctionLibrary  extends AbstractHandler {
                                                }\r
                                        });\r
                                } else {\r
+                                   // imported library is already in the right place. Update function library files.\r
                                        FunctionUtils.updateFunctionFileForLibrary(graph, functionLibrary);\r
                                }\r
 \r
@@ -191,6 +215,12 @@ public class ImportFunctionLibrary  extends AbstractHandler {
                return null;\r
        }\r
        \r
+       /**\r
+        * Import advisor for importing function libraries to SysDyn\r
+        * \r
+        * @author Teemu Lempinen\r
+        *\r
+        */\r
        private class SysdynFunctionLibraryImportAdvisor extends DefaultPasteImportAdvisor {\r
                \r
                public SysdynFunctionLibraryImportAdvisor(Resource library) {\r
@@ -199,6 +229,7 @@ public class ImportFunctionLibrary  extends AbstractHandler {
                \r
                @Override\r
                public void analyzeType(ReadGraph graph, Root root) throws DatabaseException {\r
+                   // Change the library to http://SharedOntologies, if the imported library is of type SharedFunctionOntology\r
                        if(root.type.equals(SysdynResource.URIs.SharedFunctionOntology)) {\r
                                try {\r
                                        library = graph.getResource("http://SharedOntologies");\r
similarity index 88%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportMdlHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportMdlHandler.java
index 156ab7bc7b7dcb2be4bc84a871dfd99ed05e478e..2ce39ec68466fffcd0fe29d97c54653c1de5e041 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.handlers;\r
+package org.simantics.sysdyn.ui.handlers.imports;\r
 \r
 import java.io.File;\r
 \r
@@ -30,6 +30,12 @@ import org.simantics.sysdyn.mdlImport.mdlElements.Model;
 import org.simantics.sysdyn.ui.Activator;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
+/**\r
+ * Class for importing Vensim models (.mdl) to Simantics SysDyn using MdlParser \r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class ImportMdlHandler extends AbstractHandler {\r
 \r
        public static String IMPORTMDLTPATH = "IMPORT_MDL_PATH";\r
@@ -40,6 +46,7 @@ public class ImportMdlHandler extends AbstractHandler {
                final Resource project = SimanticsUI.getProject().get();\r
                if(project == null) return null;\r
 \r
+               // Get the .mdl file\r
                Shell shell = HandlerUtil.getActiveShellChecked(event);\r
                FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
                fd.setText("Import .mdl");\r
@@ -57,6 +64,7 @@ public class ImportMdlHandler extends AbstractHandler {
                \r
                Activator.getDefault().getPreferenceStore().setValue(IMPORTMDLTPATH, (new File(selected)).getParent());\r
                \r
+               // Convert Vensim model to Simantics SysDyn format using MdlParser\r
                final Model model = MdlParser.parse(file);\r
                \r
                SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
similarity index 91%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportModelHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModelHandler.java
index 0bf887a33f3002b1ff9480368aad7458d25c0ec6..ccecf5bbebac2ea2d0d6d55a6304033212bfcc45 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.handlers;\r
+package org.simantics.sysdyn.ui.handlers.imports;\r
 \r
 import java.io.File;\r
 import java.io.IOException;\r
@@ -50,6 +50,12 @@ import org.simantics.sysdyn.ui.utils.OldTransferableGraph1;
 import org.simantics.sysdyn.ui.utils.SheetUtils;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
+/**\r
+ * Imports models from exported transferable graph files.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class ImportModelHandler extends AbstractHandler {\r
        \r
        public static String IMPORTMODELTPATH = "IMPORT_MODEL_PATH";\r
@@ -60,6 +66,7 @@ public class ImportModelHandler extends AbstractHandler {
                Resource project = SimanticsUI.getProject().get();\r
                if(project == null) return null;\r
 \r
+               // Get imported transferable graph file using FileDialog\r
                final Shell shell = HandlerUtil.getActiveShellChecked(event);\r
                FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
                fd.setText("Import Model");\r
@@ -75,7 +82,7 @@ public class ImportModelHandler extends AbstractHandler {
                \r
                Activator.getDefault().getPreferenceStore().setValue(IMPORTMODELTPATH, (new File(selected)).getParent());\r
                \r
-\r
+               // Get the transferable graph from file\r
                TransferableGraph1 tg = null;\r
                try {\r
                        tg = (TransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class));\r
@@ -83,6 +90,7 @@ public class ImportModelHandler extends AbstractHandler {
                        e.printStackTrace();\r
                } catch (IOException e) {       \r
                        try {\r
+                           // "Version migration". Use OldTransferableGraph1 if the file was imported using old methods\r
                                OldTransferableGraph1 otg = (OldTransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(OldTransferableGraph1.class));\r
                                tg = new TransferableGraph1(otg.resourceCount, otg.identities, otg.statements, otg.values);\r
                        } catch (RuntimeBindingConstructionException e1) {\r
@@ -112,6 +120,7 @@ public class ImportModelHandler extends AbstractHandler {
                                public void perform(WriteGraph graph) throws DatabaseException {\r
                                        \r
                                        if(!graph.isInstanceOf(root, SysdynResource.getInstance(graph).SysdynModel)) {\r
+                                           // Imported model was not a SysdynModel, display error message.\r
                                                Resource instanceOf = graph.getPossibleObject(root, Layer0.getInstance(graph).InstanceOf);\r
                                                String type = "...";\r
                                                if(instanceOf != null)\r
@@ -140,6 +149,7 @@ public class ImportModelHandler extends AbstractHandler {
                                    Resource project = SimanticsUI.getProject().get();\r
                                    graph.claim(root, Layer0X.getInstance(graph).IsActivatedBy, project);\r
                                            \r
+                                   // Do all modifications that are necessary\r
                                                updateOldConfigurationToBaseRealization(graph, root);\r
                                                addDefaultOntologyLinks(graph, root);\r
                                                addURIsToDiagrams(graph, root);\r
@@ -197,6 +207,12 @@ public class ImportModelHandler extends AbstractHandler {
        }\r
        \r
        \r
+       /**\r
+        * Add a container for providing URIs to diagrams. \r
+        * \r
+        * @param graph WriteGraph\r
+        * @param model Imported model\r
+        */\r
        private static void addURIsToDiagrams(WriteGraph graph, Resource model) {\r
                Layer0 l0 = Layer0.getInstance(graph);\r
                SimulationResource simu = SimulationResource.getInstance(graph);\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModuleHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportModuleHandler.java
new file mode 100644 (file)
index 0000000..9a0cfce
--- /dev/null
@@ -0,0 +1,145 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers.imports;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\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.core.runtime.Platform;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.FileDialog;\r
+import org.eclipse.swt.widgets.MessageBox;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.Files;\r
+import org.simantics.databoard.binding.error.RuntimeBindingConstructionException;\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.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.adapter.impl.DefaultPasteHandler;\r
+import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor;\r
+import org.simantics.graph.db.MissingDependencyException;\r
+import org.simantics.graph.representation.TransferableGraph1;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+\r
+/**\r
+ * Imports modules from exported transferable graph files.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class ImportModuleHandler extends AbstractHandler {\r
+\r
+    public static String IMPORTMODULETPATH = "IMPORT_MODULE_PATH";\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+\r
+        @SuppressWarnings("unchecked")\r
+        AbstractNode<Resource> node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class);\r
+        if (node == null)\r
+            return null;\r
+\r
+        final Resource model = node.data;\r
+\r
+        // Get imported transferable graph file using FileDialog\r
+        final 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(IMPORTMODULETPATH);\r
+        if(path.isEmpty() || !(new File(path).exists()))\r
+            path = Platform.getLocation().toOSString();\r
+        fd.setFilterPath(path);\r
+        String[] filterExt = {"*.tg"};\r
+        fd.setFilterExtensions(filterExt);\r
+        String selected = fd.open();\r
+        if(selected == null) return null;\r
+\r
+        Activator.getDefault().getPreferenceStore().setValue(IMPORTMODULETPATH, (new File(selected)).getParent());\r
+\r
+        // Get the transferable graph from file\r
+        TransferableGraph1 tg = null;\r
+        try {\r
+            tg = (TransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class));\r
+        } catch (RuntimeBindingConstructionException e) {\r
+            e.printStackTrace();\r
+        } catch (IOException e) {\r
+            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ERROR);\r
+            mb.setText("Error");\r
+            mb.setMessage("The imported file is not of type: Module Type");\r
+            mb.open();\r
+            return null;\r
+        }\r
+        if(tg == null) return null;\r
+\r
+\r
+        // Import the module to model\r
+        DefaultPasteImportAdvisor ia = new DefaultPasteImportAdvisor(model);\r
+        try {\r
+            DefaultPasteHandler.defaultExecute(tg, model, ia);\r
+        } catch (MissingDependencyException e) {\r
+            e.printStackTrace();\r
+        } catch (Exception e) {\r
+            e.printStackTrace();\r
+        }\r
+\r
+        final Resource root = ia.getRoot();\r
+\r
+        // Check that the imported file actually was a module. Display error message otherwise.\r
+        SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+            @Override\r
+            public void perform(WriteGraph graph) throws DatabaseException {\r
+                if(!graph.isInheritedFrom(root, SysdynResource.getInstance(graph).Module)) {\r
+                    Resource instanceOf = graph.getPossibleObject(root, Layer0.getInstance(graph).InstanceOf);\r
+                    String type = "...";\r
+                    if(instanceOf != null)\r
+                        type = NameUtils.getSafeName(graph, instanceOf);\r
+                    else {\r
+                        Resource inheritedFrom = graph.getPossibleObject(root, Layer0.getInstance(graph).Inherits);\r
+                        if(inheritedFrom != null)\r
+                            type = NameUtils.getSafeName(graph, inheritedFrom);\r
+                    }\r
+                    final String ft = type; \r
+                    graph.deny(root, Layer0.getInstance(graph).PartOf);\r
+\r
+                    shell.getDisplay().asyncExec(new Runnable() {\r
+\r
+                        @Override\r
+                        public void run() {\r
+                            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ERROR);\r
+                            mb.setText("Error");\r
+                            mb.setMessage("The imported file is not of type: System Dynamics Module (" + ft +")");\r
+                            mb.open();                                                         \r
+                        }\r
+                    });\r
+                } \r
+            }\r
+        });\r
+        return null;\r
+    }\r
+\r
+}\r
similarity index 72%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewEnumerationNodeHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewEnumerationNodeHandler.java
index 49b3f023d3602f176b72d79500f7a1123db3bf2e..fbd774ff158a943c67b75d68f160b9641f68bc05 100644 (file)
@@ -1,4 +1,15 @@
-package org.simantics.sysdyn.ui.handlers;\r
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
 \r
 import org.eclipse.core.commands.AbstractHandler;\r
 import org.eclipse.core.commands.ExecutionEvent;\r
@@ -19,6 +30,12 @@ import org.simantics.sysdyn.SysdynResource;
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.AdaptionUtils;\r
 \r
+/**\r
+ * Creates a new Enumeration node to a configuration or module\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class NewEnumerationNodeHandler extends AbstractHandler {\r
 \r
        @Override\r
@@ -35,6 +52,7 @@ public class NewEnumerationNodeHandler extends AbstractHandler {
                SysdynResource sr = SysdynResource.getInstance(g);\r
                Layer0 l0 = Layer0.getInstance(g);\r
                \r
+               // Find the actual configuration. Possible cases for resource are sr.Configuration, sr.ModuleSymbol or sr.Module.\r
                Resource configuration = null;\r
                if(g.isInstanceOf(resource, sr.Configuration)) {\r
                        configuration = resource;\r
@@ -50,6 +68,7 @@ public class NewEnumerationNodeHandler extends AbstractHandler {
                        }\r
                }\r
 \r
+               // Create the enumeartion\r
                Resource enumerationIndexes = OrderedSetUtils.create(g, sr.EnumerationIndexes);\r
                \r
                String name = NameUtils.findFreshName(g, "Enum", configuration, l0.ConsistsOf, "%s%d");\r
similarity index 81%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewExperimentNodeHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewExperimentNodeHandler.java
index 0d854f022ca840189be78d844cce73ac6534a1eb..f8e1f331daa73d9560de77677624d43cb97d45f8 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.handlers;\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
 \r
 import org.eclipse.core.commands.AbstractHandler;\r
 import org.eclipse.core.commands.ExecutionEvent;\r
@@ -30,8 +30,17 @@ import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.AdaptionUtils;\r
 \r
+/**\r
+ * Creates a new normal SysDyn experiment\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class NewExperimentNodeHandler extends AbstractHandler {\r
 \r
+    /**\r
+     * Assumes that it is called from a node that has a SysDyn model as its resource.\r
+     */\r
     @Override\r
     public Object execute(ExecutionEvent event) throws ExecutionException {\r
         ISelection sel = HandlerUtil.getCurrentSelection(event);\r
@@ -71,10 +80,22 @@ public class NewExperimentNodeHandler extends AbstractHandler {
         \r
     }\r
     \r
+    /**\r
+     * Get the type of this experiment.\r
+     * \r
+     * @param g ReadGraph\r
+     * @return The type resource of this experiment\r
+     */\r
     protected Resource getExperimentType(ReadGraph g) {\r
         return SysdynResource.getInstance(g).BasicExperiment;\r
     }\r
     \r
+    /**\r
+     * Returns the suggested name for this experiment.\r
+     * If the name has already been taken, appropriate prefix needs to be added. \r
+     *  \r
+     * @return Suggested name for this experiment. \r
+     */\r
     protected String getNameSuggestion() {\r
         return "Experiment";\r
     }\r
similarity index 87%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewFunctionHandler.java
index 881281f0591058d175164febc0090089b48da9fc..a9a970db947d2032787bd29ec557075848cf1d64 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.handlers;\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
 \r
 import org.eclipse.core.commands.AbstractHandler;\r
 import org.eclipse.core.commands.ExecutionEvent;\r
@@ -29,8 +29,17 @@ import org.simantics.sysdyn.manager.FunctionUtils;
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.AdaptionUtils;\r
 \r
+/**\r
+ * Creates a new function to a SysdynModel or Library.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class NewFunctionHandler extends AbstractHandler {\r
 \r
+    /**\r
+     * Assumes to be called from a node with SysdynModel, Library or SysdynModelicaFunction as its resource\r
+     */\r
        @Override\r
        public Object execute(ExecutionEvent event) throws ExecutionException {\r
 \r
@@ -50,6 +59,7 @@ public class NewFunctionHandler extends AbstractHandler {
                Layer0 l0 = Layer0.getInstance(g);\r
                 SysdynResource sr = SysdynResource.getInstance(g);\r
 \r
+                // Library can be either SysdynModel or L0.Library. \r
                 Resource library = null;\r
                 if(g.isInstanceOf(data, sr.SysdynModel) || g.isInstanceOf(data, l0.Library))\r
                        library = data;\r
similarity index 93%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionLibraryHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewFunctionLibraryHandler.java
index 3465aa12e4df3ccaed6bfaa2dd8ace128e5b0ac7..98f40231c70dc73755fefb1d89b603b29723242d 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.handlers;\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
 \r
 import org.eclipse.core.commands.AbstractHandler;\r
 import org.eclipse.core.commands.ExecutionEvent;\r
@@ -30,6 +30,12 @@ import org.simantics.sysdyn.manager.FunctionUtils;
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.AdaptionUtils;\r
 \r
+/**\r
+ * Creates a new function library to a model or other library.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class NewFunctionLibraryHandler extends AbstractHandler {\r
 \r
        @Override\r
similarity index 63%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewModelHandler.java
index 90778d94713c4fcc98bca74b6101d0711552aafa..393d5ae889083bc9e21b43fb3dcf5fa17624747c 100644 (file)
@@ -1,4 +1,15 @@
-package org.simantics.sysdyn.ui.handlers;\r
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
 \r
 import org.eclipse.core.commands.AbstractHandler;\r
 import org.eclipse.core.commands.ExecutionEvent;\r
@@ -14,6 +25,12 @@ import org.simantics.sysdyn.ui.Activator;
 import org.simantics.sysdyn.ui.utils.ModelUtils;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
+/**\r
+ * Creates a new SysDyn model.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class NewModelHandler extends AbstractHandler {\r
 \r
     @Override\r
@@ -27,6 +44,7 @@ public class NewModelHandler extends AbstractHandler {
                     SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
                         @Override\r
                         public void perform(WriteGraph graph) throws DatabaseException {\r
+                            // Use ModelUtils to keep all model creations up-to-date\r
                             ModelUtils.createModel(graph);\r
                         }\r
                     });\r
similarity index 94%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewModuleNodeHandler.java
index 4478bae7c74c1e6a51c2d1e3dbd5f20ef3955fab..441bef3cc5a9c684f2055c752a0f54cd5c0c8179 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.handlers;\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
 \r
 import org.eclipse.core.commands.AbstractHandler;\r
 import org.eclipse.core.commands.ExecutionEvent;\r
@@ -35,8 +35,17 @@ import org.simantics.ui.SimanticsUI;
 import org.simantics.ui.utils.AdaptionUtils;\r
 import org.simantics.utils.datastructures.ArrayMap;\r
 \r
+/**\r
+ * Creates a new module node for a model.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class NewModuleNodeHandler extends AbstractHandler {\r
 \r
+    /**\r
+     * Assumes to be called from a node that has a SysDyn model as its resource.\r
+     */\r
     @Override\r
     public Object execute(ExecutionEvent event) throws ExecutionException {\r
         \r
@@ -52,7 +61,6 @@ public class NewModuleNodeHandler extends AbstractHandler {
             \r
             @Override\r
             public void perform(WriteGraph g) throws DatabaseException {\r
-                // Same as in SysdynProject.java. Should use the same code, not copy.\r
                 SysdynResource sr = SysdynResource.getInstance(g);\r
                 Layer0 l0 = Layer0.getInstance(g);\r
                 Layer0X L0X = Layer0X.getInstance(g);\r
similarity index 92%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewPlaybackExperimentNodeHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewPlaybackExperimentNodeHandler.java
index 9eb53798e9955adc7dcfd79b2046c4275a9e9868..a54ce36f68100af2fb62a0e7255bb1fcc4366366 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.handlers;\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
 \r
 import java.awt.Color;\r
 \r
@@ -21,7 +21,12 @@ import org.simantics.diagram.stubs.G2DResource;
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
 \r
-\r
+/**\r
+ * Creates a new playback experiment.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class NewPlaybackExperimentNodeHandler  extends NewExperimentNodeHandler  {\r
 \r
     protected void configureExperiment(WriteGraph graph, Resource experiment) throws DatabaseException {\r
similarity index 88%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewSharedFunctionLibraryHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSharedFunctionLibraryHandler.java
index 83ab344236b6b580d6b833eea9b9d188d0b1710b..5eba69cdfeea749ea5c91dfefe62815530a8f0a1 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.handlers;\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
 \r
 import org.eclipse.core.commands.ExecutionEvent;\r
 import org.eclipse.core.commands.ExecutionException;\r
@@ -19,6 +19,12 @@ import org.simantics.browsing.ui.common.node.AbstractNode;
 import org.simantics.db.Resource;\r
 import org.simantics.ui.utils.AdaptionUtils;\r
 \r
+/**\r
+ * Creates a new shared function library.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class NewSharedFunctionLibraryHandler extends NewFunctionLibraryHandler {\r
 \r
        @Override\r
similarity index 58%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewSpreadSheetHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSpreadSheetHandler.java
index 3f467ea50e806de62a817e5aa066f3727bfa517d..16c6a3dab32ba30b0989422fea482c1a33316fa6 100644 (file)
@@ -1,4 +1,15 @@
-package org.simantics.sysdyn.ui.handlers;\r
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
 \r
 import org.eclipse.core.commands.AbstractHandler;\r
 import org.eclipse.core.commands.ExecutionEvent;\r
@@ -13,8 +24,16 @@ import org.simantics.sysdyn.ui.utils.SheetUtils;
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.ResourceAdaptionUtils;\r
 \r
+/**\r
+ * Creates a new spreadsheet sheet to a book.\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class NewSpreadSheetHandler extends AbstractHandler {\r
 \r
+    /**\r
+     * Called from a node that has a book as its resource.\r
+     */\r
     @Override\r
     public Object execute(ExecutionEvent event) throws ExecutionException {\r
         ISelection sel = HandlerUtil.getCurrentSelection(event);\r
index 88c72a6f37c0857405225b6eb02517cdbb3a4491..47ba4e84da952509804d6d3d6de593c710ef8d10 100644 (file)
@@ -39,13 +39,19 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.handlers.ExportExternalFunctionFilesHandler;\r
-import org.simantics.sysdyn.ui.handlers.ImportExternalFunctionFilesHandler;\r
 import org.simantics.sysdyn.ui.handlers.RemoveNodeHandler;\r
+import org.simantics.sysdyn.ui.handlers.exports.ExportExternalFunctionFilesHandler;\r
+import org.simantics.sysdyn.ui.handlers.imports.ImportExternalFunctionFilesHandler;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.datastructures.ArrayMap;\r
 import org.simantics.utils.datastructures.Pair;\r
 \r
+/**\r
+ * Tab for properties of a SysdynModelicaFunction containing all external files added to that function \r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class ExternalFilesTab extends LabelPropertyTabContributor implements Widget {\r
 \r
        GraphExplorerComposite externalFilesExplorer;\r
@@ -59,7 +65,8 @@ public class ExternalFilesTab extends LabelPropertyTabContributor implements Wid
         Composite composite = new Composite(body, SWT.NONE);\r
         GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
         GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite);\r
-               \r
+        \r
+        // Create the graph explorer displaying external files                 \r
                externalFilesExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
                                "displaySelectors", "displayFilter").values(false, false), site, composite, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI);\r
                \r
@@ -79,6 +86,7 @@ public class ExternalFilesTab extends LabelPropertyTabContributor implements Wid
                        ((Tree) c).setLinesVisible(true);\r
                \r
                \r
+               // Create controls for importing, exporting and removing external files\r
                Composite buttonRow = new Composite(composite, SWT.NONE);\r
                GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonRow);\r
                GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonRow);\r
@@ -174,6 +182,11 @@ public class ExternalFilesTab extends LabelPropertyTabContributor implements Wid
                externalFilesExplorer.setInput(context, input);\r
        }\r
 \r
+       /**\r
+        * Method for retreiving selected resources from a GraphExplorerComposite\r
+        * @param explorer\r
+        * @return\r
+        */\r
        private List<Resource> getSelectedResources(GraphExplorerComposite explorer) {\r
                List<Resource> result = new ArrayList<Resource>();\r
                \r
index e778d60ca0304b17bcfc0678b9652ad4f3eceef9..39a6487f60e3a2a4cc28e747fc5fd6892c15bf0a 100644 (file)
@@ -43,7 +43,7 @@ import org.simantics.spreadsheet.resource.SpreadsheetResource;
 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.handlers.ImportModelHandler;\r
+import org.simantics.sysdyn.ui.handlers.imports.ImportModelHandler;\r
 import org.simantics.sysdyn.ui.utils.OldTransferableGraph1;\r
 import org.simantics.ui.SimanticsUI;\r
 \r