]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/handler/TagAction.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.issues.ui / src / org / simantics / issues / ui / handler / TagAction.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.issues.ui.handler;
13
14 import java.util.List;
15
16 import org.eclipse.jface.action.Action;
17 import org.eclipse.jface.resource.ImageDescriptor;
18 import org.simantics.Simantics;
19 import org.simantics.db.Resource;
20 import org.simantics.db.Session;
21 import org.simantics.db.common.utils.TagUtil;
22
23 /**
24  * @author Tuukka Lehtonen
25  */
26 public class TagAction extends Action {
27
28     private final String virtualGraphId;
29     private final String tagURI;
30     private final boolean tag;
31     private final List<Resource> resources;
32
33     /**
34      * @param label
35      * @param image
36      * @param virtualGraphId
37      * @param tagURI
38      * @param tag <code>true</code> to add tag, <code>false</code> to remove tag
39      * @param input
40      */
41     public TagAction(String label, ImageDescriptor image, String virtualGraphId, String tagURI, boolean tag, List<Resource> input) {
42         super(label, image);
43
44         this.virtualGraphId = virtualGraphId;
45         this.tagURI = tagURI;
46         this.tag = tag;
47         this.resources = input;
48     }
49
50     @Override
51     public void run() {
52         Session session = Simantics.peekSession();
53         if (session != null)
54             new TagUtil(virtualGraphId, tagURI, tag).execute(session, resources);
55     }
56
57 }