From: lempinen Date: Fri, 20 May 2011 06:26:29 +0000 (+0000) Subject: git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@21038 ac1ea38d-2e2b... X-Git-Tag: simantics-1.4RC1~6 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=59cface20d4f908c6a959ea2f221b9545c117488;p=simantics%2Fsysdyn.git git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@21038 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/build.properties b/org.simantics.sysdyn.ui/build.properties index 0e7312f7..8658bc35 100644 --- a/org.simantics.sysdyn.ui/build.properties +++ b/org.simantics.sysdyn.ui/build.properties @@ -17,4 +17,5 @@ bin.includes = META-INF/,\ adapters.xml,\ icons/,\ doc/,\ - cheatsheet/ + cheatsheet/,\ + splash.bmp diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java index 4b5aac48..3e0614a0 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java @@ -222,9 +222,12 @@ public class InputFactory extends SysdynElementFactory { size = new Rectangle2D.Double(); if (name != null) size.setRect(name.getBoundsInLocal()); + if(reference != null) { + /* Only the main text box as bounds if (reference.getBoundsInLocal().getWidth() > size.getWidth()) size.setRect(size.getX(), size.getY(), reference.getBoundsInLocal().getWidth(), size.getHeight()); + */ } else size.setFrame(0, 0, 0, 0); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/modelica/SysdynModelicaEditor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/modelica/SysdynModelicaEditor.java index 96dffc74..c5a2ed34 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/modelica/SysdynModelicaEditor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/modelica/SysdynModelicaEditor.java @@ -11,6 +11,9 @@ *******************************************************************************/ package org.simantics.sysdyn.ui.modelica; +import java.util.HashSet; +import java.util.Set; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.operation.IRunnableContext; @@ -25,13 +28,19 @@ import org.eclipse.jface.text.source.MatchingCharacterPainter; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.editors.text.TextEditor; import org.eclipse.ui.texteditor.AbstractDocumentProvider; import org.simantics.db.exception.DatabaseException; import org.simantics.sysdyn.modelica.ModelicaWriter; import org.simantics.sysdyn.representation.Configuration; +import org.simantics.sysdyn.representation.IElement; import org.simantics.sysdyn.representation.LoadRepresentation; +import org.simantics.sysdyn.representation.Module; +import org.simantics.sysdyn.representation.ModuleType; import org.simantics.ui.SimanticsUI; import org.simantics.ui.workbench.ResourceEditorInput; @@ -41,6 +50,19 @@ public class SysdynModelicaEditor extends TextEditor { AnnotationModel annotationModel = new AnnotationModel(); AnnotationPainter apainter; + + public void init(final IEditorSite site, final IEditorInput input) throws PartInitException { + super.init(site, input); + try { + Configuration configuration = + LoadRepresentation.loadConfiguration(SimanticsUI.getSession(), ((ResourceEditorInput)input).getResource()); + setPartName(configuration.getLabel()); + } catch (DatabaseException e) { + e.printStackTrace(); + } + + } + public SysdynModelicaEditor() { super(); showOverviewRuler(); @@ -59,7 +81,13 @@ public class SysdynModelicaEditor extends TextEditor { Configuration configuration = LoadRepresentation.loadConfiguration(SimanticsUI.getSession(), ((ResourceEditorInput)element).getResource()); ModelicaWriter writer = new ModelicaWriter(); - writer.write(configuration); + + HashSet configurations = new HashSet(); + configurations.add(configuration); + getConfigurations(configuration, configurations); + + for(Configuration c : configurations) + writer.write(c); return new Document(writer.toString()); } catch (DatabaseException e) { @@ -96,6 +124,16 @@ public class SysdynModelicaEditor extends TextEditor { } + private void getConfigurations(Configuration configuration, Set configurations) { + for(IElement e : configuration.getElements()) { + if(e instanceof Module) { + ModuleType mt = ((Module) e).getType(); + configurations.add(mt.getConfiguration()); + getConfigurations(mt.getConfiguration(), configurations); + } + } + } + @Override protected void createActions() { super.createActions(); diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Redeclaration.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Redeclaration.java index cdf33978..e850d9c5 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Redeclaration.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Redeclaration.java @@ -67,6 +67,9 @@ public class Redeclaration { * @return */ private String getSeparator(Redeclaration redeclaration, String separator) { + if(redeclaration == null || redeclaration.replacedEnumeration == null || + redeclaration.replacedEnumeration.getParentConfiguration() == null) + return separator = "_"; for(IElement e : redeclaration.replacedEnumeration.getParentConfiguration().getElements()) { if(e instanceof Module) { for(Redeclaration rd : ((Module)e).getRedeclarations()) { diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/ParameterExpression.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/ParameterExpression.java index 47a9c8d6..e5649c11 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/ParameterExpression.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/ParameterExpression.java @@ -55,7 +55,7 @@ public class ParameterExpression extends Expression { StringBuilder sb = new StringBuilder(); sb.append(" " + (parameter ? "parameter " : "") + variable.getType() + " " + variable.getName() + range); if(parameter) - sb.append(" = " + 0.0 + " /* Value read from init file */"); + sb.append(" = " + getValue() + " /* Actual value read from init file */"); sb.append(";\n"); return sb.toString(); }