SYSDYN.SysdynModelManager : PROJ.Feature
L0.HasLabel "Sysdyn Model Manager"
L0.HasDescription "Sysdyn Model Manager."
- PROJ.RequiresFeature MOD.ModelingProject
+ PROJ.RequiresFeature WORKBENCH.Features.SymbolManager
PROJ.RequiresFeature PROJ.Features.ExperimentControl
org.simantics.data;bundle-version="0.6.3",
org.simantics.message;bundle-version="0.9.0",
org.simantics.structural2;bundle-version="1.0.0",
+ org.simantics.layer0;bundle-version="1.0.0",
org.simantics.diagram.ontology;bundle-version="1.0.0"
Bundle-Activator: org.simantics.sysdyn.ui.Activator
Bundle-ActivationPolicy: lazy
\r
import java.util.ArrayList;\r
import java.util.Collection;\r
+\r
import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
import org.simantics.db.Builtins;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.common.request.ObjectsWithType;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
\r
public Collection<?> getContribution(ReadGraph graph, ExperimentsFolder experimentsFolder) throws DatabaseException {\r
ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
Builtins b = graph.getBuiltins();\r
- for(Resource r : graph.syncRequest(new ObjectsWithType(experimentsFolder.resource, b.ConsistsOf, b.Experiment))) {\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(experimentsFolder.resource, b.ConsistsOf, SimulationResource.getInstance(graph).Experiment))) {\r
try {\r
result.add(graph.adapt(r, AbstractNode.class));\r
} catch(DatabaseException e) {\r
import org.simantics.browsing.ui.graph.contributor.labeler.LabelDecoratorContributor;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode;\r
\r
public class ExperimentLabelDecorator extends LabelDecoratorContributor<ExperimentNode> {\r
\r
@Override\r
public LabelDecorator getDecorator(ReadGraph graph, ExperimentNode experimentNode) throws DatabaseException {\r
- if (graph.hasStatement(experimentNode.resource, graph.getBuiltins().IsActive)) {\r
+ if (graph.hasStatement(experimentNode.resource, SimulationResource.getInstance(graph).IsActive)) {\r
return new LabelDecorator.Stub() {\r
@Override\r
public String decorateLabel(String label, String column, int itemIndex) {\r
\r
import java.util.ArrayList;\r
import java.util.Collection;\r
+\r
import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
result.add(new ConfigurationNode(\r
graph.getSingleObject(\r
- model.resource, \r
- graph.getBuiltins().HasConfiguration))\r
+ model.resource,\r
+ SimulationResource.getInstance(graph).HasConfiguration))\r
);\r
result.add(new ExperimentsFolder(model.resource));\r
result.add(new OperatingInterfacesFolder(model.resource));\r
import org.eclipse.swt.SWT;\r
import org.simantics.browsing.ui.content.LabelDecorator;\r
import org.simantics.browsing.ui.graph.contributor.labeler.LabelDecoratorContributor;\r
-import org.simantics.db.Builtins;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode;\r
\r
public class SimulationResultDecorator extends LabelDecoratorContributor<SimulationResultNode>{\r
\r
@Override\r
public LabelDecorator getDecorator(ReadGraph graph, SimulationResultNode result) throws DatabaseException {\r
- Builtins b = graph.getBuiltins();\r
- if (graph.hasStatement(result.resource, b.IsActive)) {\r
+ if (graph.hasStatement(result.resource, SimulationResource.getInstance(graph).IsActive)) {\r
return new LabelDecorator.Stub() {\r
\r
@SuppressWarnings("unchecked")\r
import org.simantics.browsing.ui.swt.ImagerContributor;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.ui.Activator;\r
import org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode;\r
\r
\r
@Override\r
public ImageDescriptor getDescriptor(ReadGraph graph, SimulationResultNode result) throws DatabaseException {\r
- if(graph.hasStatement(result.resource, graph.getBuiltins().IsActive))\r
+ if(graph.hasStatement(result.resource, SimulationResource.getInstance(graph).IsActive))\r
return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_bar.png"));\r
else\r
return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_bar_blackAndWhite.png"));\r
import org.simantics.db.exception.ServiceException;\r
import org.simantics.db.request.Read;\r
import org.simantics.modeling.ModelingResources;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.structural.stubs.StructuralResource2;\r
import org.simantics.ui.SimanticsUI;\r
\r
});\r
} catch (DatabaseException e) {\r
e.printStackTrace();\r
- } \r
+ }\r
\r
return modifier;\r
}\r
\r
Resource type = graph.getPossibleObject(resource, mr.SymbolToComponentType);\r
Resource model = graph.getSingleObject(type, b.PartOf);\r
- Resource modelConfiguration = graph.getSingleObject(model, b.HasConfiguration);\r
+ Resource modelConfiguration = graph.getSingleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
if (!graph.syncRequest(new ObjectsWithType(modelConfiguration, b.ConsistsOf, type)).isEmpty()) {\r
System.out.println("The module is used at the model configuration");\r
return;\r
import org.simantics.objmap.MappingException;\r
import org.simantics.objmap.Mappings;\r
import org.simantics.scenegraph.INode;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.ui.actions.ConnectDependency;\r
import org.simantics.sysdyn.ui.actions.ConnectFlow;\r
import org.simantics.sysdyn.ui.actions.CreateAuxiliary;\r
IDiagram diagram;\r
IMapping mapping;\r
Frame frame;\r
- boolean disposed = false; \r
+ boolean disposed = false;\r
Composite frameComposite;\r
Resource diagramResource;\r
protected ISessionContextProvider sessionContextProvider;\r
@Override\r
public void run() {\r
try {\r
- session.syncRequest(new WriteRequest() { \r
+ session.syncRequest(new WriteRequest() {\r
@Override\r
public void perform(WriteGraph graph)\r
throws DatabaseException {\r
mapping.updateDomain(graph);\r
- } \r
+ }\r
});\r
} catch (DatabaseException e) {\r
e.printStackTrace();\r
- } \r
+ }\r
}\r
\r
- }); \r
+ });\r
}\r
\r
@Override\r
@Override\r
public void run() {\r
try {\r
- session.syncRequest(new ReadRequest() { \r
+ session.syncRequest(new ReadRequest() {\r
@Override\r
public void run(ReadGraph graph) throws DatabaseException {\r
mapping.updateRange(graph);\r
});\r
} catch (DatabaseException e) {\r
e.printStackTrace();\r
- } \r
+ }\r
}\r
\r
- }); \r
+ });\r
}\r
\r
});\r
\r
@Override\r
public void elementAdded(IElement element) {\r
- mapping.rangeModified(diagram); \r
+ mapping.rangeModified(diagram);\r
element.addListener(elementUpdateListener);\r
}\r
\r
@Override\r
public void elementRemoved(IElement element) {\r
mapping.rangeModified(element);\r
- mapping.rangeModified(diagram); \r
+ mapping.rangeModified(diagram);\r
}\r
\r
});\r
@Override\r
public void run(ReadGraph g) throws DatabaseException {\r
diagramResource = g.getSingleObject(getInputResource(), ModelingResources.getInstance(g).CompositeToDiagram);\r
- readDiagram(g); \r
+ readDiagram(g);\r
}\r
\r
});\r
Builtins b = graph.getBuiltins();\r
Resource r = graph.getSingleObject(\r
getResourceInput().getResource(),\r
- b.IsConfigurationOf);\r
+ SimulationResource.getInstance(graph).IsConfigurationOf);\r
String label = graph.getPossibleRelatedValue(r, b.HasLabel);\r
return label;\r
}\r
}));\r
} catch (DatabaseException e) {\r
e.printStackTrace();\r
- } \r
+ }\r
}\r
\r
@Override\r
public void createPartControl(final Composite parent) {\r
- frameComposite = new Composite(parent, \r
+ frameComposite = new Composite(parent,\r
SWT.NO_BACKGROUND | SWT.EMBEDDED);\r
frame = SWT_AWT.new_Frame(frameComposite);\r
- \r
- \r
+\r
+\r
/// KOKEILLAAN\r
- \r
+\r
/*\r
sessionContextProvider = SimanticsUI.getSessionContextProvider();\r
sessionContext = sessionContextProvider.getSessionContext();\r
if (activationManager != null) {\r
activation = activationManager.activate(diagramResource);\r
}\r
- */\r
+ */\r
/// LOPPUU\r
\r
final ActiveSelectionProvider selectionProvider = new ActiveSelectionProvider();\r
SwingUtilities.invokeLater(new Runnable() {\r
\r
@Override\r
- public void run() { \r
- DiagramEditor editor = new DiagramEditor(null, diagram); \r
+ public void run() {\r
+ DiagramEditor editor = new DiagramEditor(null, diagram);\r
\r
DefaultEventHandlers.configure(editor);\r
editor.addEventHandler(1, "key(A)", new CreateAuxiliary());\r
editor.addEventHandler(1, "key(C)", new CreateCloud());\r
editor.addEventHandler(1, "drag(alt+left)", new ConnectDependency());\r
editor.addEventHandler(1, "drag(alt+right)", new ConnectFlow());\r
- editor.addEventHandler(1, "release(right)", openContextMenu); \r
+ editor.addEventHandler(1, "release(right)", openContextMenu);\r
\r
canvas = new EditorCanvas(editor);\r
frame.add(canvas);\r
\r
- frameComposite.getDisplay().asyncExec(new Runnable() { \r
+ frameComposite.getDisplay().asyncExec(new Runnable() {\r
@Override\r
public void run() {\r
setFocus();\r
}\r
\r
@Override\r
- public void setFocus() { \r
+ public void setFocus() {\r
if(frameComposite != null && !frameComposite.isDisposed()) {\r
frameComposite.setFocus();\r
if(canvas!=null)\r
import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
System.out.println("New Experiment");\r
- \r
+\r
ISelection sel = HandlerUtil.getCurrentSelection(event);\r
Resource[] resources = ResourceAdaptionUtils.toResources(sel);\r
if (resources.length != 1)\r
return null;\r
- \r
+\r
final Resource model = resources[0];\r
- \r
+\r
SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
- \r
+\r
@Override\r
public void perform(WriteGraph g) throws DatabaseException {\r
Builtins b = g.getBuiltins();\r
Resource report = GraphUtils.create2(g, b.Report, b.HasDocumentation, "===Report===");\r
- \r
+\r
String name = GraphUtils.findFreshName(g, "Experiment", model, b.ConsistsOf, "%s%d");\r
- \r
+\r
@SuppressWarnings("unused")\r
- Resource experiment = GraphUtils.create2(g, b.Experiment,\r
+ Resource experiment = GraphUtils.create2(g, SimulationResource.getInstance(g).Experiment,\r
b.HasName, name,\r
b.HasLabel, name,\r
b.HasReportFactory, report,\r
\r
import org.eclipse.core.commands.AbstractHandler;\r
import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException; \r
+import org.eclipse.core.commands.ExecutionException;\r
import org.simantics.databoard.binding.java.StringBindingDefault;\r
import org.simantics.db.Builtins;\r
import org.simantics.db.Resource;\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
- \r
+\r
@Override\r
public void perform(WriteGraph g) throws DatabaseException {\r
// Same as in SysdynProject.java. Should use the same code, not copy.\r
SysdynResource sr = SysdynResource.getInstance(g);\r
ModelingResources mr = ModelingResources.getInstance(g);\r
ModelingUtils mu = new ModelingUtils(g);\r
- \r
+\r
String modelName = GraphUtils.findFreshName(g, "Model", SimanticsUI.getProject().get(), b.ConsistsOf, "%s%d");\r
- \r
+\r
Resource model = g.newResource();\r
g.claimValue(model, b.HasName, modelName);\r
g.claimValue(model, b.HasLabel, modelName);\r
g.claim(model, b.InstanceOf, sr.SysdynModel);\r
g.claim(model, b.PartOf, SimanticsUI.getProject().get());\r
- \r
- \r
+\r
+\r
Resource diagram = OrderedSetUtils.create(g, sr.ConfigurationDiagram);\r
GraphLayer l = new GraphLayerUtil(g).createLayer(DiagramConstants.DEFAULT_LAYER_NAME, true);\r
g.claim(diagram, mu.dr.HasLayer, l.getLayer());\r
g.claimValue(diagram, b.HasName, "Diagrammi", StringBindingDefault.INSTANCE);\r
- \r
- Resource conf = GraphUtils.create2(g, \r
+\r
+ Resource conf = GraphUtils.create2(g,\r
sr.Configuration,\r
b.PartOf, model,\r
b.HasName, modelName+"Configuration"\r
- );\r
+ );\r
\r
g.claim(conf, mr.CompositeToDiagram, diagram);\r
- g.claim(model, b.HasConfiguration, conf);\r
- \r
+ g.claim(model, mu.SIMU.HasConfiguration, conf);\r
+\r
Resource mapping = g.newResource();\r
g.claim(mapping, b.InstanceOf, null, sr.DiagramToCompositeMapping);\r
g.claim(diagram, b.HasTrigger, mapping);\r
- \r
+\r
Resource report = GraphUtils.create2(g, mu.b.Report, mu.b.HasDocumentation, "===Report===");\r
\r
- GraphUtils.create2(g, mu.b.Experiment,\r
+ GraphUtils.create2(g, mu.SIMU.Experiment,\r
mu.b.HasName, "Experiment",\r
mu.b.HasLabel, "Experiment",\r
mu.b.HasReportFactory, report,\r
import org.eclipse.core.commands.ExecutionException;\r
import org.eclipse.jface.viewers.ISelection;\r
import org.eclipse.ui.handlers.HandlerUtil;\r
-import org.simantics.db.Builtins;\r
import org.simantics.db.Resource;\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.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
Resource[] resources = ResourceAdaptionUtils.toResources(sel);\r
if (resources.length == 0)\r
return null;\r
- \r
+\r
toggleActivation(resources);\r
- \r
+\r
return null;\r
}\r
\r
@Override\r
public void perform(WriteGraph graph) throws DatabaseException {\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
- Builtins b = graph.getBuiltins();\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
for(Resource r : resources) {\r
if(graph.isInstanceOf(r, sr.Result)) {\r
- if (graph.hasStatement(r, b.IsActive)) {\r
- graph.denyStatement(r, b.IsActive, r);\r
+ if (graph.hasStatement(r, SIMU.IsActive)) {\r
+ graph.denyStatement(r, SIMU.IsActive, r);\r
} else {\r
- graph.claim(r, b.IsActive, r);\r
+ graph.claim(r, SIMU.IsActive, r);\r
}\r
}\r
}\r
}\r
- \r
+\r
});\r
} catch (DatabaseException e) {\r
- \r
+\r
}\r
}\r
}\r
import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.exception.CancelTransactionException;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.editor.SysdynDiagramEditor;\r
import org.simantics.ui.SimanticsUI;\r
@Override\r
public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
for (Resource r : resources) {\r
if (graph.isInstanceOf(r, sr.SysdynModel)) {\r
unlinkModel(graph, r);\r
- configurations.add(graph.getSingleObject(r, graph.getBuiltins().HasConfiguration));\r
+ configurations.add(graph.getSingleObject(r, SIMU.HasConfiguration));\r
}\r
- else if (graph.isInstanceOf(r, graph.getBuiltins().Experiment))\r
+ else if (graph.isInstanceOf(r, SIMU.Experiment))\r
unlinkExperiment(graph, r);\r
else if (graph.isInstanceOf(r, sr.Result))\r
unlinkResult(graph, r);\r
Builtins b = graph.getBuiltins();\r
Collection<Resource> results = graph.getObjects(experiment, SysdynResource.getInstance(graph).HasResult);\r
if(results != null)\r
- for(Resource result : results) \r
+ for(Resource result : results)\r
unlinkResult(graph, result);\r
graph.deny(experiment, b.PartOf);\r
\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.layer0.adapter.RealizationVirtualGraph;\r
import org.simantics.db.layer0.adapter.ResourceData;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.SysdynResource;\r
\r
public class DefaultRealizationVirtualGraph extends RealizationVirtualGraph {\r
@Override\r
public void initialize(final VirtualGraphContext context, WriteGraph graph) throws DatabaseException {\r
\r
- Resource configuration = graph.getPossibleObject(model, b.HasConfiguration);\r
+ Resource configuration = graph.getPossibleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
\r
Resource defaultsResource = graph.newResource();\r
int modelNode = context.getIndex(model);\r
import org.simantics.db.layer0.adapter.ResourceData;\r
import org.simantics.db.layer0.adapter.RuntimeValuations;\r
import org.simantics.db.request.Read;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.SysdynResource;\r
\r
public class HistoryRealizationVirtualGraph extends RealizationVirtualGraph {\r
// System.out.println("Compute runs starts");\r
HashSet<Resource> result = new HashSet<Resource>();\r
Builtins b = graph.getBuiltins();\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
for(Resource config : graph.getObjects(model, b.ConsistsOf)) {\r
- if(graph.isInstanceOf(config, b.Experiment)) {\r
+ if(graph.isInstanceOf(config, SIMU.Experiment)) {\r
for(Resource run : graph.getObjects(config, b.ConsistsOf)) {\r
- if(graph.isInstanceOf(run, b.Run)) {\r
+ if(graph.isInstanceOf(run, SIMU.Run)) {\r
// System.out.println("found run " + run);\r
result.add(run);\r
}\r
@Override\r
public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {\r
HashSet<Resource> result = new HashSet<Resource>();\r
- Resource configuration = graph.getPossibleObject(model, b.HasConfiguration);\r
+ Resource configuration = graph.getPossibleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
for(Resource part : graph.getObjects(configuration, b.ConsistsOf)) {\r
result.add(part);\r
}\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.layer0.variable.ResourceVariable;\r
import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.manager.SysdynDataSet;\r
import org.simantics.sysdyn.manager.SysdynModel;\r
import org.simantics.sysdyn.manager.SysdynModelManager;\r
public <T> T getInterface(ReadGraph graph, Class<T> clazz) throws DatabaseException {\r
if(Accessor.class.equals(clazz)) {\r
\r
- Builtins b = graph.getBuiltins();\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
Resource model = Variables.getModel(graph, this);\r
- Resource configuration = graph.getPossibleObject(model, b.HasConfiguration);\r
+ Resource configuration = graph.getPossibleObject(model, SIMU.HasConfiguration);\r
SysdynModel sm = SysdynModelManager.getInstance(graph.getSession()).getModel(graph, configuration);\r
SysdynResult sr = sm.getSysdynResult();\r
String rvi = Variables.getRVI(graph, this);\r
g.claim(conf, b.InstanceOf, sr.Configuration);\r
\r
g.claim(conf, mr.CompositeToDiagram, diagram);\r
- g.claim(model, b.HasConfiguration, conf);\r
+ g.claim(model, mu.SIMU.HasConfiguration, conf);\r
\r
Resource mapping = g.newResource();\r
g.claim(mapping, b.InstanceOf, null, mr.DiagramToCompositeMapping);\r
\r
Resource report = GraphUtils.create2(g, mu.b.Report, mu.b.HasDocumentation, "===Report===");\r
\r
- GraphUtils.create2(g, mu.b.Experiment,\r
+ GraphUtils.create2(g, mu.SIMU.Experiment,\r
mu.b.HasName, "Experiment",\r
mu.b.HasLabel, "Experiment",\r
mu.b.HasReportFactory, report,\r
addToCollectionHint(ProjectKeys.PERSPECTIVES, DEFAULT_PERSPECTIVE);\r
addToCollectionHint(ProjectKeys.OPEN_PERSPECTIVES, DEFAULT_PERSPECTIVE);\r
getProjectElement().setHint(ProjectKeys.DEFAULT_PERSPECTIVE, DEFAULT_PERSPECTIVE);\r
- \r
+\r
getProjectElement().setHint(IEditorNamingService.KEY_EDITOR_NAMING_SERVICE, new EditorNamingService2());\r
\r
mm = new ModelManager();\r
import org.simantics.databoard.accessor.Accessor;\r
import org.simantics.db.Builtins;\r
import org.simantics.db.ReadGraph;\r
-import org.simantics.db.RequestProcessor;\r
import org.simantics.db.Resource;\r
import org.simantics.db.Session;\r
import org.simantics.db.VirtualGraph;\r
import org.simantics.db.layer0.adapter.RuntimeValuations;\r
import org.simantics.db.layer0.adapter.TrendVariable;\r
import org.simantics.db.layer0.util.Simantics;\r
-import org.simantics.db.management.ISessionContext;\r
import org.simantics.db.request.Read;\r
import org.simantics.db.service.VirtualGraphSupport;\r
import org.simantics.project.IProject;\r
import org.simantics.project.IProjectLifeCycle;\r
+import org.simantics.project.exception.ProjectException;\r
import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.simulation.project.IExperimentManager;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.ui.SimanticsUI;\r
-import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
-import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;\r
import org.simantics.utils.ui.ErrorLogger;\r
\r
public class SysdynProjectLifeCycle implements IProjectLifeCycle{\r
\r
- public static final Key INITIALIZED = new KeyOf(Boolean.class, "SYSDYN_LIFECYCLE_INITIALIZED");\r
private static final String CHEATSHEET_ID = "org.simantics.sysdyn.ui.cheatsheet1";\r
private static final String FIRST_SYSDYN_PROJECT = "firstSysdynProject";\r
\r
@Override\r
- public void onActivated(RequestProcessor processor, final IProject project) {\r
+ public void onActivated(final Session session, final IProject project) throws ProjectException {\r
\r
- ISessionContext context = SimanticsUI.getSessionContext();\r
- if (context.getHint(INITIALIZED) == null) {\r
-\r
- try {\r
-\r
- Resource projectResource = project.get();\r
+ try {\r
\r
- final Session session = context.getSession();\r
+ Resource projectResource = project.get();\r
\r
- session.registerService(RuntimeValuations.class, new RuntimeValuations() {\r
+ session.registerService(RuntimeValuations.class, new RuntimeValuations() {\r
\r
- @Override\r
- public boolean supports(String valuation) {\r
+ @Override\r
+ public boolean supports(String valuation) {\r
\r
- IExperimentManager expMan = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
- IExperiment experiment = expMan.getExperiment(valuation);\r
+ IExperimentManager expMan = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ IExperiment experiment = expMan.getExperiment(valuation);\r
\r
- return experiment != null;\r
+ return experiment != null;\r
\r
- }\r
+ }\r
\r
- @Override\r
- public Accessor getAccessor(String variableIdentityPrefix, String valuation, String suffix) {\r
- return null;\r
- }\r
+ @Override\r
+ public Accessor getAccessor(String variableIdentityPrefix, String valuation, String suffix) {\r
+ return null;\r
+ }\r
\r
- @Override\r
- public TrendVariable getVariable(String variableIdentityPrefix, String valuation, String suffix) {\r
+ @Override\r
+ public TrendVariable getVariable(String variableIdentityPrefix, String valuation, String suffix) {\r
\r
- return null;\r
+ return null;\r
\r
- }\r
+ }\r
\r
- });\r
+ });\r
\r
\r
\r
- final Builtins b = session.getBuiltins();\r
- ActivationManager activationManager = session.getService(ActivationManager.class);\r
- if (activationManager != null) {\r
- activationManager.activate(processor, projectResource);\r
- }\r
+ final Builtins b = session.getBuiltins();\r
+ ActivationManager activationManager = session.getService(ActivationManager.class);\r
+ if (activationManager != null) {\r
+ activationManager.activate(session, projectResource);\r
+ }\r
\r
\r
- VirtualGraphSupport support = session.getService(VirtualGraphSupport.class);\r
- final VirtualGraph graph = session.getService(VirtualGraph.class);\r
+ VirtualGraphSupport support = session.getService(VirtualGraphSupport.class);\r
+ final VirtualGraph graph = session.getService(VirtualGraph.class);\r
\r
- processor.asyncRequest(new ObjectsWithType(projectResource, b.ConsistsOf, b.Model), new SingleSetListener<Resource>() {\r
+ SimulationResource SIMU = SimulationResource.getInstance(session);\r
+ session.asyncRequest(new ObjectsWithType(projectResource, b.ConsistsOf, SIMU.Model), new SingleSetListener<Resource>() {\r
\r
- @Override\r
- public void add(final Resource model) {\r
- // FIXME:\r
- Simantics.async(new Runnable() {\r
-\r
- @Override\r
- public void run() {\r
- try {\r
- // This creates experiment realizations\r
- graph.register(new HistoryRealizationVirtualGraph(session, model));\r
- // This creates the BaseRealization\r
- graph.register(new DefaultRealizationVirtualGraph(session, model));\r
- } catch (DatabaseException e) {\r
- e.printStackTrace();\r
- }\r
+ @Override\r
+ public void add(final Resource model) {\r
+ // FIXME:\r
+ Simantics.async(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ try {\r
+ // This creates experiment realizations\r
+ graph.register(new HistoryRealizationVirtualGraph(session, model));\r
+ // This creates the BaseRealization\r
+ graph.register(new DefaultRealizationVirtualGraph(session, model));\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
}\r
+ }\r
\r
- });\r
- }\r
+ });\r
+ }\r
\r
- @Override\r
- public void exception(Throwable t) {\r
- t.printStackTrace();\r
- }\r
+ @Override\r
+ public void exception(Throwable t) {\r
+ t.printStackTrace();\r
+ }\r
\r
- @Override\r
- public boolean isDisposed() {\r
- return false;\r
- }\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return false;\r
+ }\r
\r
- });\r
+ });\r
\r
- support.getWorkspacePersistent("experiments");\r
+ support.getWorkspacePersistent("experiments");\r
\r
- } catch (DatabaseException e) {\r
+ } catch (DatabaseException e) {\r
\r
- e.printStackTrace();\r
+ throw new ProjectException(e);\r
\r
- }\r
+ }\r
\r
\r
- cleanProjectFolder(processor, project.get());\r
- context.setHint(INITIALIZED, Boolean.TRUE);\r
+ cleanProjectFolder(session, project.get());\r
\r
\r
- // Open cheatsheets view on the first time the user creates a sysdyn project\r
- // for a particular workspace.\r
- IEclipsePreferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);\r
- boolean firstSysdynProject = prefs.getBoolean(FIRST_SYSDYN_PROJECT, true);\r
- if (firstSysdynProject) {\r
- // This should not be here\r
+ // Open cheatsheets view on the first time the user creates a sysdyn project\r
+ // for a particular workspace.\r
+ IEclipsePreferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);\r
+ boolean firstSysdynProject = prefs.getBoolean(FIRST_SYSDYN_PROJECT, true);\r
+ if (firstSysdynProject) {\r
+ // This should not be here\r
// Display.getDefault().asyncExec(new Runnable() {\r
// @Override\r
// public void run() {\r
// new OpenCheatSheetAction(CHEATSHEET_ID).run();\r
// }});\r
\r
- // Make a note that the user has created a sysdyn project.\r
- try {\r
- prefs.putBoolean(FIRST_SYSDYN_PROJECT, false);\r
- prefs.flush();\r
- } catch (BackingStoreException e) {\r
- ErrorLogger.defaultLogError(e);\r
- }\r
+ // Make a note that the user has created a sysdyn project.\r
+ try {\r
+ prefs.putBoolean(FIRST_SYSDYN_PROJECT, false);\r
+ prefs.flush();\r
+ } catch (BackingStoreException e) {\r
+ ErrorLogger.defaultLogError(e);\r
}\r
-\r
}\r
-\r
}\r
\r
@Override\r
- public void onDeactivated(IProject project) {\r
+ public void onDeactivated(Session session, IProject project) {\r
}\r
\r
- public void cleanProjectFolder(RequestProcessor processor, final Resource projectResource) {\r
- ISessionContext context = SimanticsUI.getSessionContext();\r
- final Session session = context.getSession();\r
+ public void cleanProjectFolder(Session session, final Resource projectResource) throws ProjectException {\r
String projectName = null;\r
final HashMap<String, Resource> resultPaths = new HashMap<String, Resource>();\r
try {\r
- projectName = processor.syncRequest(new Read<String>() {\r
+ projectName = session.syncRequest(new Read<String>() {\r
\r
@Override\r
public String perform(ReadGraph graph) throws DatabaseException {\r
Builtins b = graph.getBuiltins();\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
for(Resource model : graph.getObjects(projectResource, b.ConsistsOf)) {\r
if(graph.isInstanceOf(model, sr.SysdynModel)){\r
for(Resource experiment : graph.getObjects(model, b.ConsistsOf)) {\r
- if(graph.isInstanceOf(experiment, b.Experiment)) {\r
+ if(graph.isInstanceOf(experiment, SIMU.Experiment)) {\r
for(Resource result : graph.getObjects(experiment, sr.HasResult)) {\r
String resultFile = (String)graph.getPossibleRelatedValue(result, sr.HasResultFile);\r
if(result != null) resultPaths.put(resultFile, result);\r
}\r
});\r
} catch (DatabaseException e) {\r
- e.printStackTrace();\r
+ throw new ProjectException(e);\r
}\r
\r
if(projectName != null) {\r
import org.simantics.db.exception.ServiceException;\r
import org.simantics.diagram.stubs.DiagramResource;\r
import org.simantics.modeling.ModelingResources;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.ui.utils.AdaptionUtils;\r
\r
if (backend.isInstanceOf(r, sr.Configuration) || (backend.isInstanceOf(r, sr.SysdynModel))) {\r
Resource model;\r
if (backend.isInstanceOf(r, sr.Configuration))\r
- model = backend.getPossibleObject(r, b.IsConfigurationOf);\r
+ model = backend.getPossibleObject(r, SimulationResource.getInstance(backend).IsConfigurationOf);\r
else\r
model = r;\r
if (model != null)\r
import org.simantics.db.layer0.variable.Variables;\r
import org.simantics.diagram.stubs.DiagramResource;\r
import org.simantics.modeling.ModelingUtils;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.manager.SysdynDataSet;\r
import org.simantics.sysdyn.manager.SysdynModel;\r
}\r
\r
@Override\r
- public Comparable<String> getSeriesKey(int series) { \r
+ public Comparable<String> getSeriesKey(int series) {\r
SysdynDataSet sds = sets[series];\r
if(sds.result == null)\r
return sds.name;\r
}\r
\r
@Override\r
- public int getSeriesCount() { \r
+ public int getSeriesCount() {\r
return sets.length;\r
}\r
\r
}\r
\r
@Override\r
- public void createPartControl(Composite parent) { \r
+ public void createPartControl(Composite parent) {\r
final ActiveSelectionProvider selectionProvider = new ActiveSelectionProvider();\r
getSite().setSelectionProvider(selectionProvider);\r
\r
- final Composite composite = new Composite(parent, \r
+ final Composite composite = new Composite(parent,\r
SWT.NO_BACKGROUND | SWT.EMBEDDED);\r
frame = SWT_AWT.new_Frame(composite);\r
\r
SwingUtilities.invokeLater(new Runnable() {\r
\r
@Override\r
- public void run() { \r
+ public void run() {\r
XYPlot plot = new XYPlot(\r
sysdynDatasets,\r
new NumberAxis("time"),\r
return;\r
Resource runtime = runtimes.get(0);\r
setSelection(ress.toArray(Resource.NONE), runtime);\r
- } \r
+ }\r
}\r
});\r
\r
SwingUtilities.invokeLater(new Runnable() {\r
\r
@Override\r
- public void run() { \r
+ public void run() {\r
sysdynDatasets.setDatasets(datasets.toArray(new SysdynDataSet[datasets.size()]));\r
}\r
\r
@Override\r
public void setFocus() {\r
if(panel != null)\r
- panel.requestFocus(); \r
+ panel.requestFocus();\r
}\r
\r
protected Collection<SysdynDataSet> loadAllActive(ReadGraph g, Resource element, Resource runtime) throws DatabaseException {\r
System.out.println("load dataset for '" + item.getURI(g) + "'");\r
\r
Resource model = Variables.getModel(g, item);\r
- Resource configuration = g.getPossibleObject(model, b.HasConfiguration);\r
+ Resource configuration = g.getPossibleObject(model, SimulationResource.getInstance(g).HasConfiguration);\r
SysdynModel sm = SysdynModelManager.getInstance(g.getSession()).getModel(g, configuration);\r
\r
Collection<SysdynResult> activeResults = sm.getActiveResults(g);\r
org.eclipse.jface;bundle-version="3.5.2",
org.simantics.project;bundle-version="1.0.0",
org.simantics.layer0.utils;bundle-version="0.8.0",
- org.simantics.sysdyn.ontology;bundle-version="1.0.0",
- org.simantics.structural.ontology;bundle-version="1.0.0"
+ org.simantics.layer0;bundle-version="1.0.0",
+ org.simantics.structural.ontology;bundle-version="1.0.0",
+ org.simantics.sysdyn.ontology;bundle-version="1.0.0"
Export-Package: org.simantics.sysdyn,
org.simantics.sysdyn.expressionParser,
org.simantics.sysdyn.manager,
import org.simantics.simulation.experiment.Experiment;\r
import org.simantics.simulation.experiment.ExperimentState;\r
import org.simantics.simulation.experiment.IDynamicExperiment;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.simulation.SimulationScheduler;\r
\r
\r
@Override\r
public void run(ReadGraph graph) throws DatabaseException {\r
- final Resource configuration = graph.getPossibleObject(model, graph.getBuiltins().HasConfiguration);\r
+ final Resource configuration = graph.getPossibleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
sysdynModel = SysdynModelManager.getInstance(session).getModel(graph, configuration);\r
toggleActivation(graph, true);\r
\r
\r
@Override\r
public void perform(WriteGraph graph) throws DatabaseException {\r
- Builtins b = graph.getBuiltins();\r
- if(activate) \r
- graph.claim(experiment, b.IsActive, experiment);\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+ if(activate)\r
+ graph.claim(experiment, SIMU.IsActive, experiment);\r
else\r
- graph.denyStatement(experiment, b.IsActive, experiment);\r
+ graph.denyStatement(experiment, SIMU.IsActive, experiment);\r
}\r
\r
});\r
import org.simantics.objmap.Mappings;\r
import org.simantics.simulation.experiment.IExperiment;\r
import org.simantics.simulation.model.IModel;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.simulation.project.IExperimentActivationListener;\r
import org.simantics.structural.stubs.StructuralResource2;\r
import org.simantics.sysdyn.Activator;\r
\r
IMapping mapping;\r
\r
- Resource configurationResource; \r
+ Resource configurationResource;\r
Configuration configuration;\r
\r
Set<Configuration> modules = new HashSet<Configuration>();\r
simulationDir = Activator.getBundleContext().getDataFile("models/" + configName);\r
if (!simulationDir.exists()) {\r
simulationDir.mkdir();\r
- } \r
+ }\r
}\r
\r
\r
* some dummy(?) stuff for experiments\r
*/\r
public SysdynModel(Resource configurationResource) {\r
- this.configurationResource = configurationResource; \r
+ this.configurationResource = configurationResource;\r
}\r
\r
public synchronized void simulate(IModelicaMonitor monitor, final IProgressMonitor progressMonitor) throws IOException {\r
final SimulationLocation simulationLocation = ModelicaManager.createInputFiles(\r
simulationDir,\r
configuration.getName(),\r
- writer.toString(), \r
- inits); \r
+ writer.toString(),\r
+ inits);\r
\r
progressMonitor.worked(20);\r
\r
\r
ModelicaManager.buildModel(simulationLocation, monitor);\r
\r
- } \r
+ }\r
\r
progressMonitor.worked(20);\r
\r
result = new SimulationResult();\r
result.read(simulationLocation.outputFile);\r
result.readInits(simulationLocation.initFile);\r
- result.filter(); \r
+ result.filter();\r
progressMonitor.worked(20);\r
sysdynResult.setResult(result);\r
progressMonitor.worked(20);\r
listener.onFailure(e);\r
return null;\r
}\r
- } \r
+ }\r
\r
public Collection<SysdynResult> getActiveResults(ReadGraph graph) {\r
ArrayList<SysdynResult> results = new ArrayList<SysdynResult>();\r
try {\r
Builtins b = graph.getBuiltins();\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
- Resource model = graph.getSingleObject(configurationResource, b.IsConfigurationOf);\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+ Resource model = graph.getSingleObject(configurationResource, SIMU.IsConfigurationOf);\r
Collection<Resource> experiments = graph.getObjects(model, b.ConsistsOf);\r
for(Resource experiment : experiments) {\r
Collection<Resource> experimentResults = graph.getObjects(experiment, sr.HasResult);\r
for(Resource result : experimentResults) {\r
- if(graph.hasStatement(result, b.IsActive)) {\r
+ if(graph.hasStatement(result, SIMU.IsActive)) {\r
SysdynResult sysdynResult = new SysdynResult(\r
(String) graph.getPossibleRelatedValue(result, b.HasLabel),\r
(String) graph.getPossibleRelatedValue(result, sr.HasResultFile));\r