]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Replaced os.db.Builtins contents with the contents of os.layer0.Layer0 resource file...
authorlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 18 Aug 2010 20:00:30 +0000 (20:00 +0000)
committerlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 18 Aug 2010 20:00:30 +0000 (20:00 +0000)
Much of the stuff in the previous Builtins version was already deprecated and did not exist in the database, which is
why the database initialization produced the "built not found" errors it did.

Also changed IProjectLifecycle.onActivated/onDeactivated to take in Session and be ran outside of a database transaction to allow
the lifecycle handlers to perform arbitrary read/write requests. This should fix Arto's issues with Eco.

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17349 ac1ea38d-2e2b-0410-8846-a27921b304fc

24 files changed:
org.simantics.sysdyn.ontology/graph.tg
org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
org.simantics.sysdyn.ui/META-INF/MANIFEST.MF
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Experiment.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentLabelDecorator.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Model.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/SimulationResultDecorator.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/SimulationResultImager.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleTypeNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewExperimentNodeHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ToggleResultActivation.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/UnlinkNodeHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/DefaultRealizationVirtualGraph.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/HistoryRealizationVirtualGraph.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/HistoryVariable.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProjectLifeCycle.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/TrendView.java
org.simantics.sysdyn/META-INF/MANIFEST.MF
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiment.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java

index 36b1abecc0fa9dc75f36df7522b3f8382a0addf8..c2d53bda71f82c7fc563ad8383b45637eb87dd2b 100644 (file)
Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ
index ff8714b376fcb40d86c2d25cc13495efaa561432..08298cd783ee35fe8f5a22bfd4366cc2346fb5bc 100644 (file)
@@ -32,7 +32,7 @@ SYSDYN.SysdynProject : PROJ.Feature
         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
 
 
index 86b9d38b4438296d726ac4fd1130b2fb664da24f..061e9e9b683774fbccfcf99793477851443ad906 100644 (file)
@@ -36,6 +36,7 @@ Require-Bundle: org.simantics.h2d;bundle-version="1.0.0",
  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
index 34bc6adc955a40665fb92ead91c24d127de29d73..6466de72a81957638b18af293b34f9454930cd6a 100644 (file)
@@ -13,12 +13,14 @@ package org.simantics.sysdyn.ui.browser.contributions;
 \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
@@ -28,7 +30,7 @@ public class Experiment extends ViewpointContributor<ExperimentsFolder> {
     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
index b38c9f6828f8b0b272990d2e7a97fd13f3f6f1da..048c5c508de873b627e487fb0509d3acccbfcc63 100644 (file)
@@ -6,13 +6,14 @@ import org.simantics.browsing.ui.content.LabelDecorator;
 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
index eb2d5a0f20336495908756053a1f642183201b51..9a06d6810552fe8129f6a0360c0bf7de719e67ac 100644 (file)
@@ -2,9 +2,11 @@ package org.simantics.sysdyn.ui.browser.contributions;
 \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
@@ -20,8 +22,8 @@ public class Model  extends ViewpointContributor<ModelNode> {
         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
index 694696283d4cd2ca23d3dea086874c65dc46af82..60ea3bce8f2a93b0861895eed25c24acb0632397 100644 (file)
@@ -4,17 +4,16 @@ import org.eclipse.jface.resource.FontDescriptor;
 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
index 1bc94307423f64a68a7e3f22a66641c1318e525d..de9b255462b849c70a9feeddeac8d166d1c09dee 100644 (file)
@@ -4,6 +4,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
 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
@@ -11,7 +12,7 @@ public class SimulationResultImager extends ImagerContributor<SimulationResultNo
 \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
index 68738690b0fe5c9b87c67d298d15a9dd628e6f6e..dacf11d90f424ab9a623a961a49dd9418046642d 100644 (file)
@@ -18,6 +18,7 @@ import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;
 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
@@ -54,7 +55,7 @@ public class ModuleTypeNode extends ModuleNode implements IDeletableNode, IModif
             });\r
         } catch (DatabaseException e) {\r
             e.printStackTrace();\r
-        }       \r
+        }\r
 \r
         return modifier;\r
     }\r
@@ -72,7 +73,7 @@ public class ModuleTypeNode extends ModuleNode implements IDeletableNode, IModif
 \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
index d57867f1e4e198335ac751637c6113e28d4ff295..444f9eab06d66beba44e3de8853905b0b1d293e8 100644 (file)
@@ -53,6 +53,7 @@ import org.simantics.objmap.IMappingListener;
 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
@@ -76,7 +77,7 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
     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
@@ -117,19 +118,19 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
                     @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
@@ -139,7 +140,7 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
                     @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
@@ -147,10 +148,10 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
                             });\r
                         } catch (DatabaseException e) {\r
                             e.printStackTrace();\r
-                        }          \r
+                        }\r
                     }\r
 \r
-                });                                \r
+                });\r
             }\r
 \r
         });\r
@@ -159,14 +160,14 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
 \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
@@ -183,7 +184,7 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
                 @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
@@ -195,7 +196,7 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
                             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
@@ -213,18 +214,18 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
                     }));\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
@@ -233,7 +234,7 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
         if (activationManager != null) {\r
             activation = activationManager.activate(diagramResource);\r
         }\r
-        */\r
+         */\r
         /// LOPPUU\r
 \r
         final ActiveSelectionProvider selectionProvider = new ActiveSelectionProvider();\r
@@ -245,8 +246,8 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
         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
@@ -255,12 +256,12 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
                 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
@@ -293,7 +294,7 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
     }\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
index 146162610e575685d2c648872fcd6e2268f40572..93354fe2725aefc016d738be82d8902a756f4e8e 100644 (file)
@@ -11,6 +11,7 @@ import org.simantics.db.WriteGraph;
 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
@@ -19,25 +20,25 @@ public class NewExperimentNodeHandler extends AbstractHandler {
     @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
index 43d4744321beeba9c5a4a3906d7937b70e1f248c..ba1b388279b3c4d124ac79e9d84012c353c0a6d4 100644 (file)
@@ -2,7 +2,7 @@ package org.simantics.sysdyn.ui.handlers;
 \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
@@ -24,7 +24,7 @@ public class NewModelHandler extends AbstractHandler {
     @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
@@ -32,37 +32,37 @@ public class NewModelHandler extends AbstractHandler {
                 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
index 3a470de048d6d8c849dba0fd7adfde8782b4fb53..fdf56c52f67c44b2813bc108962a1a6ca75f4109 100644 (file)
@@ -5,11 +5,11 @@ import org.eclipse.core.commands.ExecutionEvent;
 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
@@ -22,9 +22,9 @@ public class ToggleResultActivation extends AbstractHandler {
         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
@@ -35,21 +35,21 @@ public class ToggleResultActivation extends AbstractHandler {
                 @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
index 171007aa9a7e08d4cad65601acaab7371f7214d9..b073c84a33c7a167816a52392e97b3ddc3ac1cde 100644 (file)
@@ -30,6 +30,7 @@ import org.simantics.db.WriteGraph;
 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
@@ -65,12 +66,13 @@ public class UnlinkNodeHandler extends AbstractHandler {
                 @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
@@ -109,7 +111,7 @@ public class UnlinkNodeHandler extends AbstractHandler {
         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
index 7a07c88cccc495a8f4ff50b8f7ddda8d44b31f28..4653cd15fe19c251c74deb46beb48a8b8591b78a 100644 (file)
@@ -7,6 +7,7 @@ import org.simantics.db.WriteGraph;
 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
@@ -18,7 +19,7 @@ public class DefaultRealizationVirtualGraph extends RealizationVirtualGraph {
        @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
index fa1c94ac4c1bafc3257e7d8b26852f8745018917..92ae6e2555c65de9d1b7df6db9e03df69104700a 100644 (file)
@@ -19,6 +19,7 @@ import org.simantics.db.layer0.adapter.RemoverUtil;
 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
@@ -37,10 +38,11 @@ public class HistoryRealizationVirtualGraph extends RealizationVirtualGraph {
 //                             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
@@ -71,7 +73,7 @@ public class HistoryRealizationVirtualGraph extends RealizationVirtualGraph {
                         @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
index b686274dd2b05a3479ce1ad65f0cdd42d93c34db..cd4162ad0bc27d4d4cd7aea42904a30a11729aa0 100644 (file)
@@ -11,6 +11,7 @@ import org.simantics.db.Resource;
 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
@@ -26,9 +27,9 @@ public class HistoryVariable extends ResourceVariable {
        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
index f53e58c6ad02c19cccfa78f4fbf756fbf18d3d30..64057687f7f4e3177124e846e63611d57f8377d1 100644 (file)
@@ -108,7 +108,7 @@ public class SysdynProject extends AbstractProjectFeature {
                 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
@@ -116,7 +116,7 @@ public class SysdynProject extends AbstractProjectFeature {
 \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
@@ -136,7 +136,7 @@ public class SysdynProject extends AbstractProjectFeature {
         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
index 8a0f7fab189aa8621f0e0dc661a4f580b5242b88..58a7282254d883253956d1961e2b87b1af6852f8 100644 (file)
@@ -10,7 +10,6 @@ import org.osgi.service.prefs.BackingStoreException;
 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
@@ -23,168 +22,156 @@ import org.simantics.db.layer0.adapter.ActivationManager;
 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
@@ -198,7 +185,7 @@ public class SysdynProjectLifeCycle implements IProjectLifeCycle{
                 }\r
             });\r
         } catch (DatabaseException e) {\r
-            e.printStackTrace();\r
+            throw new ProjectException(e);\r
         }\r
 \r
         if(projectName != null) {\r
index ae744d8db081985748abc4a46cc78ae5da9f94f9..ad7a0e3ae9de7e9e33c74d8c560a82bcc71eef7c 100644 (file)
@@ -13,6 +13,7 @@ import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;
 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
@@ -71,7 +72,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
             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
index b9179b93078fd835c3fdd7e9bb79e55a38fd704d..d292a61bd5e63702a5d77cc340d01485a6af32b1 100644 (file)
@@ -44,6 +44,7 @@ import org.simantics.db.layer0.variable.Variable;
 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
@@ -86,7 +87,7 @@ public class TrendView extends ViewPart {
         }\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
@@ -95,25 +96,25 @@ public class TrendView extends ViewPart {
         }\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
@@ -143,7 +144,7 @@ public class TrendView extends ViewPart {
                         return;\r
                     Resource runtime = runtimes.get(0);\r
                     setSelection(ress.toArray(Resource.NONE), runtime);\r
-                }                \r
+                }\r
             }\r
         });\r
 \r
@@ -183,7 +184,7 @@ public class TrendView extends ViewPart {
                 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
@@ -232,7 +233,7 @@ public class TrendView extends ViewPart {
     @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
@@ -261,7 +262,7 @@ public class TrendView extends ViewPart {
         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
index fdac2af7bfa35d707e90411f53d33843300b1d73..ca7f931637ceb927bf4df1680e30b8f13dcbe69d 100644 (file)
@@ -15,8 +15,9 @@ Require-Bundle: org.simantics.objmap;bundle-version="0.1.0",
  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,
index 50b68e17b443ea4e37ae75e55a21cfa6465701f4..2862850f6c4b6acc52c31fe4c069624646f461d6 100644 (file)
@@ -24,6 +24,7 @@ import org.simantics.layer0.utils.direct.GraphUtils;
 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
@@ -174,7 +175,7 @@ public class SysdynExperiment extends Experiment implements IDynamicExperiment {
             \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
@@ -225,11 +226,11 @@ public class SysdynExperiment extends Experiment implements IDynamicExperiment {
 \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
index fbb8df790a31dc27773e0e21bea5b0efffbc1327..fe7747a0592ad83bcdbdf1a0001b81f67bfa2265 100644 (file)
@@ -40,6 +40,7 @@ import org.simantics.objmap.IMappingListener;
 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
@@ -63,7 +64,7 @@ public class SysdynModel implements IMappingListener, IModel {
 \r
     IMapping mapping;\r
 \r
-    Resource configurationResource;    \r
+    Resource configurationResource;\r
     Configuration configuration;\r
 \r
     Set<Configuration> modules = new HashSet<Configuration>();\r
@@ -147,7 +148,7 @@ public class SysdynModel implements IMappingListener, IModel {
         simulationDir  = Activator.getBundleContext().getDataFile("models/" + configName);\r
         if (!simulationDir.exists()) {\r
             simulationDir.mkdir();\r
-        } \r
+        }\r
     }\r
 \r
 \r
@@ -155,7 +156,7 @@ public class SysdynModel implements IMappingListener, IModel {
      * 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
@@ -185,8 +186,8 @@ public class SysdynModel implements IMappingListener, IModel {
         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
@@ -198,7 +199,7 @@ public class SysdynModel implements IMappingListener, IModel {
 \r
             ModelicaManager.buildModel(simulationLocation, monitor);\r
 \r
-        }  \r
+        }\r
 \r
         progressMonitor.worked(20);\r
 \r
@@ -220,7 +221,7 @@ public class SysdynModel implements IMappingListener, IModel {
                             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
@@ -343,7 +344,7 @@ public class SysdynModel implements IMappingListener, IModel {
             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
@@ -351,12 +352,13 @@ public class SysdynModel implements IMappingListener, IModel {
         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