\r
public static String getOMCVersion(File OMHome) throws IOException {\r
ArrayList<String> parameters = new ArrayList<String>();\r
- parameters.add(OMHome + "\\bin\\omc.exe");\r
+ parameters.add(new File(OMHome, "/bin/omc").getAbsolutePath());\r
parameters.add("++v");\r
\r
// Create the build process\r
import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.layer0.adapter.ActionFactory;\r
-import org.simantics.sysdyn.ui.utils.SheetUtils;\r
+import org.simantics.sysdyn.utils.SheetUtils;\r
import org.simantics.ui.SimanticsUI;\r
\r
/**\r
import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.utils.ModelUtils;\r
+import org.simantics.sysdyn.utils.ModelUtils;\r
import org.simantics.ui.SimanticsUI;\r
\r
/**\r
import org.simantics.db.WriteGraph;\r
import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.sysdyn.ui.utils.SheetUtils;\r
+import org.simantics.sysdyn.utils.SheetUtils;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
\r
\r
@Override\r
public void run() {\r
+ if (component.isDisposed()) return;\r
component.setGraph((Graph)getObject(), "dot");\r
component.fit(); \r
}\r
import org.simantics.sysdyn.representation.IElement;\r
import org.simantics.sysdyn.representation.Variable;\r
import org.simantics.sysdyn.ui.properties.widgets.expressions.ExpressionField;\r
+import org.simantics.sysdyn.utils.ModelUtils;\r
\r
public class ArrayVariableUtils {\r
\r
import org.simantics.sysdyn.representation.Configuration;\r
import org.simantics.sysdyn.representation.Model;\r
import org.simantics.sysdyn.representation.ModuleType;\r
+import org.simantics.sysdyn.utils.ModelUtils;\r
import org.simantics.ui.SimanticsUI;\r
\r
/**\r
org.simantics.sysdyn.representation.visitors,
org.simantics.sysdyn.simulation,
org.simantics.sysdyn.tableParser,
+ org.simantics.sysdyn.utils,
org.simantics.sysdyn.utils.imports
Bundle-Activator: org.simantics.sysdyn.Activator
Bundle-ActivationPolicy: lazy
-package org.simantics.sysdyn.ui.utils;\r
+package org.simantics.sysdyn.utils;\r
\r
import java.util.UUID;\r
\r
+import org.simantics.Simantics;\r
import org.simantics.databoard.Bindings;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.manager.SysdynModel;\r
import org.simantics.sysdyn.manager.SysdynModelManager;\r
-import org.simantics.ui.SimanticsUI;\r
import org.simantics.utils.datastructures.ArrayMap;\r
\r
public class ModelUtils {\r
Resource configuration = graph.getPossibleObject(variable, l0.PartOf);\r
if(configuration == null)\r
return null;\r
- SysdynModelManager sdm = SysdynModelManager.getInstance(SimanticsUI.getSession());\r
+ SysdynModelManager sdm = SysdynModelManager.getInstance(Simantics.getSession());\r
SysdynModel model = sdm.getModel(graph, configuration);\r
try {\r
model.update(graph);\r
}\r
\r
public static void createModel(WriteGraph graph) {\r
- createModelAt(graph, SimanticsUI.getProject().get());\r
+ createModelAt(graph, Simantics.getProject().get());\r
}\r
\r
public static void createModelAt(WriteGraph g, Resource library) {\r
\r
String modelName = NameUtils.findFreshName(g, "Model", library, l0.ConsistsOf, "%s%d");\r
\r
- Resource project = SimanticsUI.getProject().get();\r
+ Resource project = Simantics.getProject().get();\r
Resource model = GraphUtils.create2(g,\r
sr.SysdynModel,\r
l0.PartOf, project,\r
}\r
}\r
\r
- GraphUtils.create2(g,\r
- l0.SCLModule,\r
- l0.PartOf, model,\r
- l0.HasName, "SCLMain",\r
- l0.SCLModule_definition, "include \"http:\\\\www.simantics.org\\DB\"\ninclude \"http:\\\\www.simantics.org\\Variables\"\n"\r
- );\r
+ createSCLMain(g, model);\r
\r
ProfileEntries.createStandardProfiles(g, model);\r
\r
Logger.defaultLogError(e);\r
}\r
}\r
+ \r
+ public static void createSCLMain(WriteGraph graph, Resource model) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ Resource SCLModule = GraphUtils.create2(graph,\r
+ L0.SCLModule,\r
+ L0.PartOf, model,\r
+ L0.HasName, "SCLMain"\r
+ );\r
+ \r
+ if(graph.hasStatement(SCLModule, L0.SCLModule_definition))\r
+ graph.deny(SCLModule, L0.SCLModule_definition);\r
+ graph.claimLiteral(SCLModule, L0.SCLModule_definition, \r
+ "include \"http://www.simantics.org/DB\"\n" +\r
+ "include \"http://www.simantics.org/Variables\"\n" + \r
+ "include \"" + graph.getURI(model) + "\"\n" +\r
+ "include \"http://www.simantics.org/Documentation-1.1/Components\"\n" + \r
+ "include \"http://www.simantics.org/Documentation-1.1/Properties\" as Properties\n" +\r
+ "include \"http://www.simantics.org/Documentation-1.1/Relations\" as Relations", Bindings.STRING);\r
+ }\r
}\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.utils;\r
+package org.simantics.sysdyn.utils;\r
\r
import org.simantics.db.Resource;\r
import org.simantics.db.WriteGraph;\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.utils;\r
+package org.simantics.sysdyn.utils;\r
\r
import org.simantics.databoard.Bindings;\r
import org.simantics.db.Resource;\r
import org.simantics.structural.stubs.StructuralResource2;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.Activator;\r
+import org.simantics.sysdyn.utils.ModelUtils;\r
\r
/**\r
* Utilities for importing tg files: Models, Modules and Function libraries\r
final Resource project = Simantics.getProject().get();\r
if(project == null) return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model: project not found", null);\r
\r
- beginTask(monitor, "Import model", 9);\r
+ beginTask(monitor, "Import model", 10);\r
\r
MigrationState state = MigrationUtils.newState();\r
state.setProperty(MigrationStateKeys.BASE_URI, SysdynResource.URIs.Migration);\r
worked(monitor, 1);\r
subTask(monitor, "Add shadow profile");\r
addShadowProfile(graph, ModelRoot);\r
- worked(monitor, 1); \r
+ worked(monitor, 1); \r
+ subTask(monitor, "Add SCL Main");\r
+ addSCLMain(graph, ModelRoot);\r
+ worked(monitor, 1); \r
subTask(monitor, "Activate model");\r
activateModel(graph, ModelRoot);\r
worked(monitor, 1);\r
}\r
}\r
\r
+ protected static void addSCLMain(WriteGraph graph, Resource modelRoot) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ SysdynResource SR = SysdynResource.getInstance(graph);\r
+ \r
+ Collection<Resource> SCLModules = graph.syncRequest(new ObjectsWithType(modelRoot, L0.ConsistsOf, L0.SCLModule));\r
+ \r
+ boolean hasIt = false;\r
+ \r
+ for(Resource r : SCLModules) {\r
+ if("SCLMain".equals(NameUtils.getSafeName(graph, r))) {\r
+ hasIt = true;\r
+ break;\r
+ }\r
+ }\r
+ \r
+ if(!hasIt) {\r
+ ModelUtils.createSCLMain(graph, modelRoot);\r
+ }\r
+ \r
+ }\r
+\r
private static void removeIssueSourcesFromModules(WriteGraph graph, Resource modelRoot) throws DatabaseException {\r
Layer0 L0 = Layer0.getInstance(graph);\r
IssueResource ISSUE = IssueResource.getInstance(graph);\r