*******************************************************************************/\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