--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.issues.ui.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.common.utils.TagUtil;\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
+ private 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)\r
+ new TagUtil(virtualGraphId, tagURI, tag).execute(session, resources);\r
+ }\r
+\r
+}\r