]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/requests/SetSubscriptionEnabled.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / requests / SetSubscriptionEnabled.java
diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/requests/SetSubscriptionEnabled.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/requests/SetSubscriptionEnabled.java
new file mode 100644 (file)
index 0000000..0568bee
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************\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.modeling.requests;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.modeling.ModelingResources;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class SetSubscriptionEnabled {\r
+\r
+    Collection<Resource> subscriptions;\r
+    boolean              newValue;\r
+\r
+    public SetSubscriptionEnabled(Collection<Resource> subscriptions, boolean newValue) {\r
+        this.subscriptions = subscriptions;\r
+        this.newValue = newValue;\r
+    }\r
+\r
+    public void perform(WriteGraph graph) throws DatabaseException {\r
+        ModelingResources mod = ModelingResources.getInstance(graph);\r
+\r
+        Boolean value = newValue;\r
+        //System.out.println("SetEnabled(" + value + "):");\r
+        for (Resource subscription : subscriptions) {\r
+            //System.out.println("    setting for " + NameUtils.getSafeLabel(graph, subscription));\r
+            graph.claimLiteral(subscription, mod.Subscription_Enabled, value);\r
+        }\r
+    }\r
+\r
+}
\ No newline at end of file