-package org.simantics.diagram.profile.view;\r
-\r
-import org.simantics.Simantics;\r
-import org.simantics.browsing.ui.swt.widgets.impl.ModifyComboListenerImpl;\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.db.service.VirtualGraphSupport;\r
-import org.simantics.diagram.stubs.DiagramResource;\r
-\r
-public class ActiveProfileModifier extends ModifyComboListenerImpl<Resource, Resource> {\r
-\r
- @Override\r
- public void applySelection(WriteGraph graph, final Resource runtimeDiagram, final Resource profile) throws DatabaseException {\r
- \r
- VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class);\r
- Simantics.getSession().asyncRequest(new WriteRequest(support.getWorkspacePersistent("profiles")) {\r
-\r
- @Override\r
- public void perform(WriteGraph graph) throws DatabaseException {\r
-\r
- DiagramResource DIA = DiagramResource.getInstance(graph);\r
- Resource current = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile);\r
- if(profile.equals(current)) return;\r
- \r
- graph.deny(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile, null, current);\r
- graph.claim(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile, null, profile);\r
-\r
- // Set this profile as the default profile for this model\r
- String modelURI = graph.getRelatedValue(runtimeDiagram, DIA.RuntimeDiagram_HasModelURI);\r
- Resource model = graph.getResource(modelURI);\r
- graph.deny(model, DIA.HasActiveProfile);\r
- graph.claim(model, DIA.HasActiveProfile, profile);\r
- \r
- // Set this profile as the default profile for this diagram\r
- Resource configuration = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasConfiguration);\r
- graph.deny(configuration, DIA.HasActiveProfile);\r
- graph.claim(configuration, DIA.HasActiveProfile, profile);\r
- \r
- }\r
- \r
- });\r
- \r
- }\r
-\r
-}\r
+package org.simantics.diagram.profile.view;
+
+import org.simantics.Simantics;
+import org.simantics.browsing.ui.swt.widgets.impl.ModifyComboListenerImpl;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.service.VirtualGraphSupport;
+import org.simantics.diagram.stubs.DiagramResource;
+
+public class ActiveProfileModifier extends ModifyComboListenerImpl<Resource, Resource> {
+
+ @Override
+ public void applySelection(WriteGraph graph, final Resource runtimeDiagram, final Resource profile) throws DatabaseException {
+
+ VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class);
+ Simantics.getSession().asyncRequest(new WriteRequest(support.getWorkspacePersistent("profiles")) {
+
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+
+ DiagramResource DIA = DiagramResource.getInstance(graph);
+ Resource current = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile);
+ if(profile.equals(current)) return;
+
+ graph.deny(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile, null, current);
+ graph.claim(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile, null, profile);
+
+ // Set this profile as the default profile for this model
+ String modelURI = graph.getRelatedValue(runtimeDiagram, DIA.RuntimeDiagram_HasModelURI);
+ Resource model = graph.getResource(modelURI);
+ graph.deny(model, DIA.HasActiveProfile);
+ graph.claim(model, DIA.HasActiveProfile, profile);
+
+ // Set this profile as the default profile for this diagram
+ Resource configuration = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasConfiguration);
+ graph.deny(configuration, DIA.HasActiveProfile);
+ graph.claim(configuration, DIA.HasActiveProfile, profile);
+
+ }
+
+ });
+
+ }
+
+}