]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@21038 ac1ea38d-2e2b...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 20 May 2011 06:26:29 +0000 (06:26 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 20 May 2011 06:26:29 +0000 (06:26 +0000)
org.simantics.sysdyn.ui/build.properties
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/modelica/SysdynModelicaEditor.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Redeclaration.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/ParameterExpression.java

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 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