]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.event/src/org/simantics/event/view/handler/TagAction.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.event / src / org / simantics / event / view / handler / TagAction.java
index 3491e29f05ee9870c94ef45550d467a53282846f..8d64c34907f685a9b2ef0ce20091fbb1f3980372 100644 (file)
@@ -1,78 +1,78 @@
-package org.simantics.event.view.handler;\r
-\r
-import java.util.List;\r
-\r
-import org.eclipse.jface.action.Action;\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.simantics.Simantics;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Session;\r
-import org.simantics.db.VirtualGraph;\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.event.ontology.EventResource;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class TagAction extends Action {\r
-\r
-    private final String virtualGraphId;\r
-    private final String tagURI;\r
-    private final boolean tag;\r
-    protected final List<Resource> resources;\r
-\r
-    /**\r
-     * @param label\r
-     * @param image\r
-     * @param virtualGraphId\r
-     * @param tagURI\r
-     * @param tag <code>true</code> to add tag, <code>false</code> to remove tag\r
-     * @param input\r
-     */\r
-    public TagAction(String label, ImageDescriptor image, String virtualGraphId, String tagURI, boolean tag, List<Resource> input) {\r
-        super(label, image);\r
-\r
-        this.virtualGraphId = virtualGraphId;\r
-        this.tagURI = tagURI;\r
-        this.tag = tag;\r
-        this.resources = input;\r
-    }\r
-\r
-    @Override\r
-    public void run() {\r
-        Session session = Simantics.peekSession();\r
-        if (session == null) return;\r
-\r
-        final VirtualGraph vg = virtualGraphId == null ? null :\r
-            session.getService(VirtualGraphSupport.class).getWorkspacePersistent(virtualGraphId);\r
-        session.asyncRequest(new WriteRequest(vg) {\r
-            @Override\r
-            public void perform(WriteGraph graph) throws DatabaseException {\r
-                // Write tags\r
-                Resource tr = graph.getResource(tagURI);\r
-                for (Resource r : resources) {\r
-                    if (tag)\r
-                        graph.claim(r, tr, tr, r);\r
-                    else\r
-                        graph.deny(r, tr, r);\r
-                }\r
-\r
-                // Set milestone labels for all events of the event log\r
-                if (tagURI.equals(EventResource.URIs.Milestone)) {\r
-                    CorrectMilestoneLabelsAction.correctMilestoneLabels(graph, vg, resources);\r
-                }\r
-\r
-                // Perform any extra writes desired\r
-                postTagWrite(graph);\r
-            }\r
-        });\r
-\r
-    }\r
-\r
-    public void postTagWrite(WriteGraph graph) throws DatabaseException {\r
-    }\r
-\r
-}\r
+package org.simantics.event.view.handler;
+
+import java.util.List;
+
+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.event.ontology.EventResource;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class TagAction extends Action {
+
+    private final String virtualGraphId;
+    private final String tagURI;
+    private final boolean tag;
+    protected final List<Resource> resources;
+
+    /**
+     * @param label
+     * @param image
+     * @param virtualGraphId
+     * @param tagURI
+     * @param tag <code>true</code> to add tag, <code>false</code> to remove tag
+     * @param input
+     */
+    public TagAction(String label, ImageDescriptor image, String virtualGraphId, String tagURI, boolean tag, List<Resource> input) {
+        super(label, image);
+
+        this.virtualGraphId = virtualGraphId;
+        this.tagURI = tagURI;
+        this.tag = tag;
+        this.resources = input;
+    }
+
+    @Override
+    public void run() {
+        Session session = Simantics.peekSession();
+        if (session == null) return;
+
+        final VirtualGraph vg = virtualGraphId == null ? null :
+            session.getService(VirtualGraphSupport.class).getWorkspacePersistent(virtualGraphId);
+        session.asyncRequest(new WriteRequest(vg) {
+            @Override
+            public void perform(WriteGraph graph) throws DatabaseException {
+                // Write tags
+                Resource tr = graph.getResource(tagURI);
+                for (Resource r : resources) {
+                    if (tag)
+                        graph.claim(r, tr, tr, r);
+                    else
+                        graph.deny(r, tr, r);
+                }
+
+                // Set milestone labels for all events of the event log
+                if (tagURI.equals(EventResource.URIs.Milestone)) {
+                    CorrectMilestoneLabelsAction.correctMilestoneLabels(graph, vg, resources);
+                }
+
+                // Perform any extra writes desired
+                postTagWrite(graph);
+            }
+        });
+
+    }
+
+    public void postTagWrite(WriteGraph graph) throws DatabaseException {
+    }
+
+}