X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.event%2Fsrc%2Forg%2Fsimantics%2Fevent%2Fview%2Fhandler%2FClaimAction.java;h=e46e3544273052b335ed6bbe702ef6bbcaad043b;hb=7045f0f516c243563976207abcec13a68891ff1d;hp=3e8d62cd2100b746fcd2aaedd0ee21d897517d7b;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git
diff --git a/bundles/org.simantics.event/src/org/simantics/event/view/handler/ClaimAction.java b/bundles/org.simantics.event/src/org/simantics/event/view/handler/ClaimAction.java
index 3e8d62cd2..e46e35442 100644
--- a/bundles/org.simantics.event/src/org/simantics/event/view/handler/ClaimAction.java
+++ b/bundles/org.simantics.event/src/org/simantics/event/view/handler/ClaimAction.java
@@ -1,74 +1,74 @@
-package org.simantics.event.view.handler;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.simantics.Simantics;
-import org.simantics.db.Resource;
-import org.simantics.db.Session;
-import org.simantics.db.VirtualGraph;
-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.layer0.Layer0;
-import org.simantics.utils.datastructures.Callback;
-import org.simantics.utils.ui.ErrorLogger;
-
-/**
- * @author Tuukka Lehtonen
- */
-public class ClaimAction extends Action {
-
- protected final String virtualGraphId;
- protected final Resource subject;
- protected final String relationURI;
- protected final Resource object;
-
- /**
- * @param label
- * @param image
- * @param virtualGraphId
- * @param tagURI
- * @param tag true
to add tag, false
to remove tag
- * @param input
- */
- public ClaimAction(String label, ImageDescriptor image, String virtualGraphId, Resource subject, String relationURI, Resource object) {
- super(label, image);
-
- this.virtualGraphId = virtualGraphId;
- this.subject = subject;
- this.relationURI = relationURI;
- this.object = object;
- }
-
- @Override
- public void run() {
- Session session = Simantics.peekSession();
- if (session != null) {
- VirtualGraph vg = virtualGraphId == null ? null :
- session.getService(VirtualGraphSupport.class).getWorkspacePersistent(virtualGraphId);
- session.asyncRequest(new WriteRequest(vg) {
- @Override
- public void perform(WriteGraph graph) throws DatabaseException {
- claim(graph);
- }
- }, new Callback() {
- @Override
- public void run(DatabaseException parameter) {
- if (parameter != null)
- ErrorLogger.defaultLogError(parameter);
- }
- });
- }
- }
-
- public void claim(WriteGraph graph) throws DatabaseException {
- Layer0 L0 = Layer0.getInstance(graph);
- Resource relation = graph.getResource(relationURI);
- boolean functional = graph.isInstanceOf(relation, L0.FunctionalRelation);
- if (functional)
- graph.deny(subject, relation);
- graph.claim(subject, graph.getResource(relationURI), object);
- }
-
-}
+package org.simantics.event.view.handler;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.simantics.Simantics;
+import org.simantics.db.Resource;
+import org.simantics.db.Session;
+import org.simantics.db.VirtualGraph;
+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.layer0.Layer0;
+import org.simantics.utils.datastructures.Callback;
+import org.simantics.utils.ui.ErrorLogger;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class ClaimAction extends Action {
+
+ protected final String virtualGraphId;
+ protected final Resource subject;
+ protected final String relationURI;
+ protected final Resource object;
+
+ /**
+ * @param label
+ * @param image
+ * @param virtualGraphId
+ * @param tagURI
+ * @param tag true
to add tag, false
to remove tag
+ * @param input
+ */
+ public ClaimAction(String label, ImageDescriptor image, String virtualGraphId, Resource subject, String relationURI, Resource object) {
+ super(label, image);
+
+ this.virtualGraphId = virtualGraphId;
+ this.subject = subject;
+ this.relationURI = relationURI;
+ this.object = object;
+ }
+
+ @Override
+ public void run() {
+ Session session = Simantics.peekSession();
+ if (session != null) {
+ VirtualGraph vg = virtualGraphId == null ? null :
+ session.getService(VirtualGraphSupport.class).getWorkspacePersistent(virtualGraphId);
+ session.asyncRequest(new WriteRequest(vg) {
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+ claim(graph);
+ }
+ }, new Callback() {
+ @Override
+ public void run(DatabaseException parameter) {
+ if (parameter != null)
+ ErrorLogger.defaultLogError(parameter);
+ }
+ });
+ }
+ }
+
+ public void claim(WriteGraph graph) throws DatabaseException {
+ Layer0 L0 = Layer0.getInstance(graph);
+ Resource relation = graph.getResource(relationURI);
+ boolean functional = graph.isInstanceOf(relation, L0.FunctionalRelation);
+ if (functional)
+ graph.deny(subject, relation);
+ graph.claim(subject, graph.getResource(relationURI), object);
+ }
+
+}