From: lempinen Date: Fri, 20 May 2011 08:03:06 +0000 (+0000) Subject: git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches@21041 ac1ea38d... X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=76f73021323b3ee0ef0d2685c252a4f366ce1b61;p=simantics%2Fsysdyn.git git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches@21041 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/simantics-1.4/org.simantics.sysdyn.ontology/graph.tg b/simantics-1.4/org.simantics.sysdyn.ontology/graph.tg index 9249c412..ddf5cc1b 100644 Binary files a/simantics-1.4/org.simantics.sysdyn.ontology/graph.tg and b/simantics-1.4/org.simantics.sysdyn.ontology/graph.tg differ diff --git a/simantics-1.4/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph b/simantics-1.4/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph index e714c7c8..3428e820 100644 --- a/simantics-1.4/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph +++ b/simantics-1.4/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph @@ -88,6 +88,7 @@ SYSDYN.Variable size.getWidth()) size.setRect(size.getX(), size.getY(), reference.getBoundsInLocal().getWidth(), size.getHeight()); + */ } else size.setFrame(0, 0, 0, 0); diff --git a/simantics-1.4/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/modelica/SysdynModelicaEditor.java b/simantics-1.4/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/modelica/SysdynModelicaEditor.java index 96dffc74..c5a2ed34 100644 --- a/simantics-1.4/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/modelica/SysdynModelicaEditor.java +++ b/simantics-1.4/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/simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ChildVariable.java b/simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ChildVariable.java index ffd4a0a5..8e93bdfa 100644 --- a/simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ChildVariable.java +++ b/simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ChildVariable.java @@ -24,7 +24,9 @@ import org.simantics.db.WriteGraph; import org.simantics.db.common.utils.OrderedSetUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.variable.AbstractChildVariable; +import org.simantics.db.layer0.variable.DatatypePropertyVariable; import org.simantics.db.layer0.variable.Variable; +import org.simantics.db.layer0.variable.Variables; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; @@ -80,6 +82,13 @@ public class ChildVariable extends AbstractChildVariable { return super.getInterface(graph, clazz); } + @Override + public Variable getPossibleExtraProperty(ReadGraph graph, String name) throws DatabaseException { + if(Variables.DATATYPE.equals(name)) { + return new DatatypePropertyVariable(this); + } + return super.getPossibleExtraProperty(graph, name); + } /* * * diff --git a/simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java b/simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java index 748841a9..40bbf5ae 100644 --- a/simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java +++ b/simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java @@ -11,9 +11,11 @@ *******************************************************************************/ package org.simantics.sysdyn.manager; +import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.StringReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -285,8 +287,45 @@ public class SysdynModel implements IMappingListener, IModel { } private boolean hasStructureChanged(String modelText, Map inits) { - if (!modelText.equals(previousModelStructure)) + + + BufferedReader current = new BufferedReader( + new StringReader(modelText)); + BufferedReader previous = new BufferedReader( + new StringReader(previousModelStructure)); + + String c, p; + try { + c = current.readLine(); + p = previous.readLine(); + + while (c != null && p != null) { + if(!c.equals(p)) { + if(c.contains("parameter") && p.contains("parameter")) { + int i = c.indexOf("="); + if(!c.substring(0, i).equals(p.substring(0, i))) { + // different parameter definition + return true; + } + } else { + // other than a line containing parameters differs + return true; + } + } + c = current.readLine(); + p = previous.readLine(); + } + + if((c == null && p != null) || (c != null && p == null)) { + // different lengths + return true; + } + + } catch(IOException e) { + //e.printStackTrace(); return true; + } + for(String key : previousImportantInits.keySet()) { if(!inits.containsKey(key) || !previousImportantInits.get(key).equals(inits.get(key))) return true; diff --git a/simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Redeclaration.java b/simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Redeclaration.java index cdf33978..e850d9c5 100644 --- a/simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Redeclaration.java +++ b/simantics-1.4/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/simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/ParameterExpression.java b/simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/ParameterExpression.java index 47a9c8d6..e5649c11 100644 --- a/simantics-1.4/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/ParameterExpression.java +++ b/simantics-1.4/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(); }