]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches@21041 ac1ea38d...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 20 May 2011 08:03:06 +0000 (08:03 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 20 May 2011 08:03:06 +0000 (08:03 +0000)
simantics-1.4/org.simantics.sysdyn.ontology/graph.tg
simantics-1.4/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
simantics-1.4/org.simantics.sysdyn.ui/build.properties
simantics-1.4/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java
simantics-1.4/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/modelica/SysdynModelicaEditor.java
simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ChildVariable.java
simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java
simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Redeclaration.java
simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/ParameterExpression.java

index 9249c4122a42b528f10e68ddcb7c6e925f0ee30e..ddf5cc1bb8e7b6a74b73fb3d0b0a115c2542fe18 100644 (file)
Binary files a/simantics-1.4/org.simantics.sysdyn.ontology/graph.tg and b/simantics-1.4/org.simantics.sysdyn.ontology/graph.tg differ
index e714c7c884c5682ac9286949cfe966e1766c09c1..3428e820e48f36b9932dba151d31216130310e73 100644 (file)
@@ -88,6 +88,7 @@ SYSDYN.Variable <T STR.Component
     @L0.singleProperty L0.HasType
     @L0.optionalProperty SYSDYN.HasArrayIndexes    
     @L0.optionalProperty SYSDYN.HasExpressions    
+    @L0.assert L0.HasDataType $Double
 
 SYSDYN.HasExpressions <R L0.DependsOn : L0.FunctionalRelation
     L0.HasDomain SYSDYN.Variable
index 0e7312f7a67a6ec66f3119c9f59fab51d0684508..8658bc3595b00f567778d373e37a5261a31e5139 100644 (file)
@@ -17,4 +17,5 @@ bin.includes = META-INF/,\
                adapters.xml,\\r
                icons/,\\r
                doc/,\\r
-               cheatsheet/\r
+               cheatsheet/,\\r
+               splash.bmp\r
index 4b5aac4819960cb4760c42a7294353ed7b3c5de0..3e0614a07b0a9cd5b5f84f43f5aa70fa22d86fd9 100644 (file)
@@ -222,9 +222,12 @@ public class InputFactory extends SysdynElementFactory {
                 size = new Rectangle2D.Double();\r
             if (name != null)\r
                 size.setRect(name.getBoundsInLocal());\r
+            \r
             if(reference != null) {\r
+               /* Only the main text box as bounds\r
                 if (reference.getBoundsInLocal().getWidth() > size.getWidth())\r
                     size.setRect(size.getX(), size.getY(), reference.getBoundsInLocal().getWidth(), size.getHeight());\r
+                */\r
             }\r
             else\r
                 size.setFrame(0, 0, 0, 0);\r
index 96dffc7480d145e21ce229dbe17756ced59d521e..c5a2ed3449d8e432d4b2ba6101c13ea573f4d48f 100644 (file)
@@ -11,6 +11,9 @@
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.modelica;\r
 \r
+import java.util.HashSet;\r
+import java.util.Set;\r
+\r
 import org.eclipse.core.runtime.CoreException;\r
 import org.eclipse.core.runtime.IProgressMonitor;\r
 import org.eclipse.jface.operation.IRunnableContext;\r
@@ -25,13 +28,19 @@ import org.eclipse.jface.text.source.MatchingCharacterPainter;
 import org.eclipse.swt.graphics.Color;\r
 import org.eclipse.swt.graphics.RGB;\r
 import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.ui.IEditorInput;\r
+import org.eclipse.ui.IEditorSite;\r
+import org.eclipse.ui.PartInitException;\r
 import org.eclipse.ui.PlatformUI;\r
 import org.eclipse.ui.editors.text.TextEditor;\r
 import org.eclipse.ui.texteditor.AbstractDocumentProvider;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.sysdyn.modelica.ModelicaWriter;\r
 import org.simantics.sysdyn.representation.Configuration;\r
+import org.simantics.sysdyn.representation.IElement;\r
 import org.simantics.sysdyn.representation.LoadRepresentation;\r
+import org.simantics.sysdyn.representation.Module;\r
+import org.simantics.sysdyn.representation.ModuleType;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.workbench.ResourceEditorInput;\r
 \r
@@ -41,6 +50,19 @@ public class SysdynModelicaEditor extends TextEditor {
     AnnotationModel annotationModel = new AnnotationModel();\r
     AnnotationPainter apainter;\r
     \r
+    \r
+       public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {\r
+               super.init(site, input);\r
+        try {\r
+                       Configuration configuration =\r
+                           LoadRepresentation.loadConfiguration(SimanticsUI.getSession(), ((ResourceEditorInput)input).getResource());\r
+                       setPartName(configuration.getLabel());\r
+               } catch (DatabaseException e) {\r
+                       e.printStackTrace();\r
+               }\r
+\r
+       }\r
+               \r
     public SysdynModelicaEditor() {\r
         super();\r
         showOverviewRuler();\r
@@ -59,7 +81,13 @@ public class SysdynModelicaEditor extends TextEditor {
                     Configuration configuration =\r
                         LoadRepresentation.loadConfiguration(SimanticsUI.getSession(), ((ResourceEditorInput)element).getResource());\r
                     ModelicaWriter writer = new ModelicaWriter();\r
-                    writer.write(configuration);\r
+                    \r
+                    HashSet<Configuration> configurations = new HashSet<Configuration>();\r
+                    configurations.add(configuration);\r
+                    getConfigurations(configuration, configurations);\r
+                    \r
+                    for(Configuration c : configurations)\r
+                       writer.write(c);\r
                     \r
                     return new Document(writer.toString());\r
                 } catch (DatabaseException e) {\r
@@ -96,6 +124,16 @@ public class SysdynModelicaEditor extends TextEditor {
                 \r
     }\r
     \r
+    private void getConfigurations(Configuration configuration, Set<Configuration> configurations) {\r
+       for(IElement e : configuration.getElements()) {\r
+               if(e instanceof Module) {\r
+                       ModuleType mt = ((Module) e).getType();\r
+                       configurations.add(mt.getConfiguration());\r
+                       getConfigurations(mt.getConfiguration(), configurations);\r
+               }\r
+       }\r
+    }\r
+    \r
     @Override\r
     protected void createActions() {\r
         super.createActions();\r
index ffd4a0a5af2adcf04ec7f5aa9daa67a9aadb9dd4..8e93bdfaa51c43b2369b26b69dd2c17f04bb5217 100644 (file)
@@ -24,7 +24,9 @@ import org.simantics.db.WriteGraph;
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.AbstractChildVariable;\r
+import org.simantics.db.layer0.variable.DatatypePropertyVariable;\r
 import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 \r
@@ -80,6 +82,13 @@ public class ChildVariable extends AbstractChildVariable {
                return super.getInterface(graph, clazz);\r
        }\r
        \r
+       @Override\r
+       public Variable getPossibleExtraProperty(ReadGraph graph, String name) throws DatabaseException {\r
+               if(Variables.DATATYPE.equals(name)) {\r
+                       return new DatatypePropertyVariable(this);\r
+               }\r
+               return super.getPossibleExtraProperty(graph, name);\r
+       }\r
        /*\r
         * \r
         * \r
index 748841a9f204e75008a2a51e29e0463fd800100c..40bbf5ae84f2d6f33fc9f4cab510314a843e041d 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.manager;\r
 \r
+import java.io.BufferedReader;\r
 import java.io.File;\r
 import java.io.FileNotFoundException;\r
 import java.io.IOException;\r
+import java.io.StringReader;\r
 import java.util.ArrayList;\r
 import java.util.Arrays;\r
 import java.util.Collection;\r
@@ -285,8 +287,45 @@ public class SysdynModel implements IMappingListener, IModel {
        }\r
 \r
        private boolean hasStructureChanged(String modelText, Map<String, String> inits) {\r
-               if (!modelText.equals(previousModelStructure))\r
+               \r
+               \r
+               BufferedReader current = new BufferedReader(\r
+                               new StringReader(modelText));\r
+               BufferedReader previous = new BufferedReader(\r
+                               new StringReader(previousModelStructure));\r
+\r
+               String c, p;\r
+               try {\r
+                       c = current.readLine();\r
+                       p = previous.readLine();\r
+                       \r
+                       while (c != null && p != null) {\r
+                               if(!c.equals(p)) {\r
+                                       if(c.contains("parameter") && p.contains("parameter")) {\r
+                                               int i = c.indexOf("=");\r
+                                               if(!c.substring(0, i).equals(p.substring(0, i))) {\r
+                                                       // different parameter definition\r
+                                                       return true;\r
+                                               }\r
+                                       } else {\r
+                                               // other than a line containing parameters differs\r
+                                               return true;\r
+                                       }\r
+                               }\r
+                               c = current.readLine();\r
+                               p = previous.readLine();\r
+                       }\r
+                       \r
+                       if((c == null && p != null) || (c != null && p == null)) {\r
+                               // different lengths\r
+                               return true;\r
+                       }\r
+\r
+               } catch(IOException e) {\r
+                       //e.printStackTrace();\r
                        return true;\r
+               }\r
+\r
                for(String key : previousImportantInits.keySet()) {\r
                        if(!inits.containsKey(key) || !previousImportantInits.get(key).equals(inits.get(key)))\r
                                return true;\r
index cdf33978734847316c43177899117852b0aa29e5..e850d9c57f0dd519eb619127262c615535ae0082 100644 (file)
@@ -67,6 +67,9 @@ public class Redeclaration {
      * @return\r
      */\r
     private String getSeparator(Redeclaration redeclaration, String separator) {\r
+       if(redeclaration == null || redeclaration.replacedEnumeration == null ||\r
+                       redeclaration.replacedEnumeration.getParentConfiguration() == null)\r
+               return separator = "_";\r
        for(IElement e : redeclaration.replacedEnumeration.getParentConfiguration().getElements()) {\r
                if(e instanceof Module) {\r
                        for(Redeclaration rd : ((Module)e).getRedeclarations()) {\r
index 47a9c8d6b5b52ad682e9633271d0684faf73b889..e5649c111cb642cf23bd2aa6f59320710e724bba 100644 (file)
@@ -55,7 +55,7 @@ public class ParameterExpression extends Expression {
        StringBuilder sb = new StringBuilder();\r
        sb.append("    " + (parameter ? "parameter " : "") + variable.getType() + " " + variable.getName() + range);\r
        if(parameter)\r
-               sb.append(" = " + 0.0 + " /* Value read from init file */");\r
+               sb.append(" = " + getValue() + " /* Actual value read from init file */");\r
        sb.append(";\n");\r
         return  sb.toString();\r
     }\r