]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Minor adjustments to vensim import. Vensim import not in use.
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 31 Dec 2013 11:31:55 +0000 (11:31 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 31 Dec 2013 11:31:55 +0000 (11:31 +0000)
refs #2924

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

org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/FindReplaceHandler.java
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/ImportUtils.java
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/mdlElements/Model.java

index e5e0b510aae8fbee17eab7bf3cb369a09f675625..889e8de343a55b40730038d3ef5a32d3582d8781 100644 (file)
@@ -24,8 +24,9 @@ SYSDYN.ImportedOntologies : PROJ.NamespaceRequirement
         "http://www.simantics.org/Sysdyn-1.1" : L0.URI
         "http://www.simantics.org/Layer0-1.1" : L0.URI
         "http://www.simantics.org/SelectionView-1.2" : L0.URI
-        //"http://www.semantum.fi/Simupedia-1.0" : L0.URI // Experimental Simupedia
-        //"http://www.semantum.fi/SimupediaWorkbench-1.0" : L0.URI // Experimental Simupedia
+//        "http://www.semantum.fi/Simupedia-1.0" : L0.URI // Experimental Simupedia
+//        "http://www.semantum.fi/SimupediaWorkbench-1.0" : L0.URI // Experimental Simupedia
+//        "http://www.simantics.org/Documentation-1.2" : L0.URI // Experimental Simupedia
                 
 SYSDYN.SharedFunctionOntology <T L0.Ontology
 SYSDYN.SharedModuleOntology <T L0.Ontology      
index d0ecb92e918b3933afd2fdcbbc8afb7e5a5bf0ff..b71d836ee1ec5854857e241697f3141e610c1151 100644 (file)
                      checkEnabled="true">\r
                </visibleWhen>\r
             </command>\r
+            <!--\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.importMdl"\r
+                  label="Vensim model"\r
+                  style="push">\r
+               <visibleWhen\r
+                     checkEnabled="true">\r
+               </visibleWhen>\r
+            </command>\r
+            -->\r
             <command\r
                   commandId="org.simantics.image.ui.importImage"\r
                   icon="platform:/plugin/com.famfamfam.silk/icons/image_add.png"\r
index 86a6a39724fc96cf2ec2b9d4b95fd0fd0d5709e1..5239aec0a1068c3e97b214ffec13feb4ba3c753c 100644 (file)
@@ -31,7 +31,7 @@ public class FindReplaceHandler extends AbstractHandler {
             return null;\r
         \r
         // If there is something else in the diagram view, do not allow search in current diagram\r
-        if (!(editor instanceof DiagramEditor)) {\r
+        if (!(editor instanceof DiagramEditor) || !(((DiagramEditor) editor).getViewer() instanceof DiagramViewer)) {\r
             if (workbenchPart != null && workbenchPart instanceof SysdynBrowser) {\r
                // If focus is on model browser, allow search in all models.\r
                 FindReplaceDialog dialog = new FindReplaceDialog(shell, Scope.ALL_MODELS, false);\r
index cba41737db93e95b258b1616af3ef3e81da1256c..761663cc00d14dadc592bf5f8bd7170b8a172d4a 100644 (file)
@@ -53,8 +53,6 @@ public class ImportUtils {
                        string = sb.toString();\r
                }\r
                \r
-               string = toCamelCase(string);\r
-               \r
                return string;\r
 \r
        }\r
@@ -65,40 +63,7 @@ public class ImportUtils {
                string = string.replace("ö", "o");\r
                string = string.replace("Ö", "O");\r
                string = string.replaceAll("[^a-zA-Z 0-9]+", "");\r
-               return toCamelCase(string);\r
-       }\r
-       \r
-       \r
-       public static String toCamelCase(String string) {\r
-               if(string.length() < 1) {\r
-                       return string;\r
-               }\r
-               \r
-               try {\r
-                       String result = new String(string);\r
-                       BufferedReader br = new BufferedReader(new StringReader(string));\r
-                       Pattern p = Pattern.compile("[a-zA-Z0-9]+");\r
-                       Matcher m;\r
-                       m = p.matcher(br.readLine());\r
-                       String word;\r
-                       boolean first = true;\r
-                       while (m.find()) {\r
-                               word = m.group();\r
-                               String replacement;\r
-                               if(first) {\r
-                                       replacement = word;\r
-                                       first = false;\r
-                               } else {\r
-                                       replacement = word.substring(0, 1).toUpperCase() + word.substring(1);\r
-                               }\r
-                               result = result.replace(word, replacement);\r
-                       }\r
-                       return result.replace(" ", "");\r
-               } catch (IOException e) {\r
-                       e.printStackTrace();\r
-                       return string;\r
-               }\r
-               \r
+               return string;\r
        }\r
 \r
 }\r
index 3e0caf6dec5d99acd41e9d750399a22cce84597b..dcc7d0d1a935a0426352084a3640a49aaa96b175 100644 (file)
@@ -16,17 +16,11 @@ import java.util.HashMap;
 \r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.adapter.Template;\r
-import org.simantics.document.DocumentResource;\r
 import org.simantics.layer0.Layer0;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
-import org.simantics.modeling.ModelingResources;\r
-import org.simantics.operation.Layer0X;\r
 import org.simantics.simulation.ontology.SimulationResource;\r
 import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.utils.datastructures.ArrayMap;\r
+import org.simantics.sysdyn.utils.ModelUtils;\r
 \r
 public class Model implements IWriteableMDLObject {\r
 \r
@@ -216,67 +210,20 @@ public class Model implements IWriteableMDLObject {
                        return;\r
                \r
                try {\r
+                   \r
+                   \r
                        SysdynResource sr = SysdynResource.getInstance(graph);\r
                        Layer0 l0 = Layer0.getInstance(graph);\r
-                       Layer0X L0X = Layer0X.getInstance(graph);\r
                        SimulationResource simu = SimulationResource.getInstance(graph);\r
-                       DocumentResource DOC = DocumentResource.getInstance(graph);\r
-\r
-                       // Diagram creation copied from SysdynProject. \r
-                       // Could the same code be reused? \r
-                       \r
-                       Resource sysdyn = graph.getResource("http://www.simantics.org/Sysdyn-1.1");\r
-                       Resource layer0 = graph.getResource("http://www.simantics.org/Layer0-1.1");\r
-\r
-                       Resource model = GraphUtils.create2(\r
-                                       graph,\r
-                                       sr.SysdynModel,\r
-                                       l0.PartOf, parent,\r
-                                       l0.HasName, NameUtils.findFreshName(graph, getName(), parent, l0.ConsistsOf, "%s%d"),\r
-                                       l0.HasLabel, getName(),\r
-                                       sr.SysdynModel_startTime, startTime,\r
-                                       sr.SysdynModel_stopTime, endTime,\r
-                                       l0.IsLinkedTo, sysdyn,\r
-                                       l0.IsLinkedTo, layer0\r
-                       );\r
 \r
+            Resource model = ModelUtils.createModelAt(graph, parent);\r
+            graph.claimLiteral(model, l0.HasLabel, getName());\r
+            graph.claimLiteral(model, sr.SysdynModel_startTime, startTime);\r
+            graph.claimLiteral(model, sr.SysdynModel_stopTime, endTime);\r
+
 \r
-                       Resource conf = GraphUtils.create2(graph,\r
-                                       sr.Configuration,\r
-                                       l0.PartOf, model,\r
-                                       l0.HasName, getName()\r
-                       );\r
-                       \r
-                       Resource diagram = graph.newResource();\r
-            graph.adapt(sr.ConfigurationDiagramTemplate, Template.class).apply(graph,\r
-                    ArrayMap\r
-                    .keys("", "diagram", "name")\r
-                    .values(conf, diagram, "Diagrammi")\r
-            );\r
-            \r
+            Resource conf = graph.getSingleObject(model, simu.HasConfiguration);\r
             \r
-            ModelingResources mr = ModelingResources.getInstance(graph);\r
-            // Remove default mapping and add sysdyn mapping\r
-            for(Resource trigger : graph.getObjects(diagram, L0X.HasTrigger)) {\r
-               if(graph.isInstanceOf(trigger, mr.DiagramToCompositeMapping)) {\r
-                       graph.deny(diagram, L0X.HasTrigger, trigger);\r
-               }\r
-            }\r
-            Resource mapping = graph.newResource();\r
-            graph.claim(mapping, l0.InstanceOf, null, sr.DiagramToCompositeMapping);\r
-            graph.claim(diagram, L0X.HasTrigger, mapping);\r
-\r
-                       graph.claim(model, simu.HasConfiguration, conf);\r
-                       graph.claim(model, L0X.HasBaseRealization, conf);\r
-\r
-                       Resource report = GraphUtils.create2(graph, DOC.Report,  DOC.HasDocumentation, "===Report===");\r
-\r
-                       GraphUtils.create2(graph, simu.Experiment,\r
-                                       l0.HasName, "Experiment",\r
-                                       l0.HasLabel, "Experiment",\r
-                                       DOC.HasReportFactory, report,\r
-                                       l0.PartOf, model);\r
-\r
                        for(Subscript s : subscripts) {\r
                                s.write(graph, conf, 0, 0);\r
                        }\r