@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
adapters.xml,\\r
icons/,\\r
doc/,\\r
- cheatsheet/\r
+ cheatsheet/,\\r
+ splash.bmp\r
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
*******************************************************************************/\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
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
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
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
\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
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
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
*******************************************************************************/\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
}\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
* @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
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