]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/UpDownProfileMonitorsContribution.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / diagram / UpDownProfileMonitorsContribution.java
index bcf18c1895ea46a3b86fabec72cd7c36d19670be..eda7fc977a852b6255b400020a88078710e2c08a 100644 (file)
@@ -1,99 +1,99 @@
-package org.simantics.modeling.ui.diagram;\r
-\r
-import java.util.Map;\r
-\r
-import org.eclipse.core.runtime.CoreException;\r
-import org.eclipse.core.runtime.IConfigurationElement;\r
-import org.eclipse.core.runtime.IExecutableExtension;\r
-import org.eclipse.jface.action.Action;\r
-import org.eclipse.jface.action.ActionContributionItem;\r
-import org.eclipse.jface.action.IContributionItem;\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.simantics.Simantics;\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.request.IndexRoot;\r
-import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.diagram.stubs.DiagramResource;\r
-import org.simantics.modeling.ui.Activator;\r
-import org.simantics.scl.commands.Command;\r
-import org.simantics.scl.commands.Commands;\r
-import org.simantics.ui.contribution.DynamicMenuContribution;\r
-import org.simantics.ui.utils.ResourceAdaptionUtils;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class UpDownProfileMonitorsContribution extends DynamicMenuContribution implements IExecutableExtension {\r
-\r
-    String          name    = "";\r
-    ImageDescriptor image   = null;\r
-    boolean         allow = true;\r
-\r
-    @Override\r
-    public void setInitializationData(IConfigurationElement config, String propertyName, Object data)\r
-    throws CoreException {\r
-        if (data instanceof Map<?,?>) {\r
-            @SuppressWarnings("unchecked")\r
-            Map<String, String> args = (Map<String, String>) data;\r
-            name = args.get("name");\r
-            String imageId = args.get("image");\r
-            image = Activator.getDefault().getImageRegistry().getDescriptor(imageId);\r
-            allow = Boolean.parseBoolean(args.get("allow"));\r
-        }\r
-    }\r
-\r
-    @Override\r
-    protected Object[] getSelectedObjects() {\r
-        return ResourceAdaptionUtils.toResources(getSelection());\r
-    }\r
-\r
-    @Override\r
-    protected IContributionItem[] getContributionItems(ReadGraph graph, final Object[] elements) throws DatabaseException {\r
-\r
-        if(elements.length == 0) return NONE;\r
-\r
-        Boolean allOk = true;\r
-\r
-        DiagramResource DIA = DiagramResource.getInstance(graph);\r
-        for(Object object : elements) {\r
-            Resource element = (Resource)object;\r
-            Boolean value = graph.getPossibleRelatedValue(element, DIA.Element_upProfileMonitors, Bindings.BOOLEAN);\r
-            if(value == null) value = true;\r
-            if(!value.equals(allow)) {\r
-                allOk = false;\r
-            }\r
-        }\r
-\r
-        if(allOk) return NONE;\r
-\r
-        return new IContributionItem[] {\r
-\r
-                new ActionContributionItem(new Action(name, image) {\r
-                    @Override\r
-                    public void run() {\r
-\r
-                        Simantics.getSession().markUndoPoint();\r
-                        Simantics.async(new WriteRequest() {\r
-\r
-                            @Override\r
-                            public void perform(WriteGraph graph) throws DatabaseException {\r
-                                Command command = Commands.get(graph, "Simantics/Diagram/setProfileMonitorsDirectionUp");\r
-                                for(Object object : elements) {\r
-                                    Resource element = (Resource)object;\r
-                                    command.execute(graph, graph.syncRequest(new IndexRoot(element)), element, allow);\r
-                                }\r
-                            }\r
-\r
-                        });\r
-\r
-                    }\r
-                })\r
-        };\r
-\r
-    }\r
-\r
-}\r
+package org.simantics.modeling.ui.diagram;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.simantics.Simantics;
+import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.IndexRoot;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.modeling.ui.Activator;
+import org.simantics.scl.commands.Command;
+import org.simantics.scl.commands.Commands;
+import org.simantics.ui.contribution.DynamicMenuContribution;
+import org.simantics.ui.utils.ResourceAdaptionUtils;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class UpDownProfileMonitorsContribution extends DynamicMenuContribution implements IExecutableExtension {
+
+    String          name    = "";
+    ImageDescriptor image   = null;
+    boolean         allow = true;
+
+    @Override
+    public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
+    throws CoreException {
+        if (data instanceof Map<?,?>) {
+            @SuppressWarnings("unchecked")
+            Map<String, String> args = (Map<String, String>) data;
+            name = args.get("name");
+            String imageId = args.get("image");
+            image = Activator.getDefault().getImageRegistry().getDescriptor(imageId);
+            allow = Boolean.parseBoolean(args.get("allow"));
+        }
+    }
+
+    @Override
+    protected Object[] getSelectedObjects() {
+        return ResourceAdaptionUtils.toResources(getSelection());
+    }
+
+    @Override
+    protected IContributionItem[] getContributionItems(ReadGraph graph, final Object[] elements) throws DatabaseException {
+
+        if(elements.length == 0) return NONE;
+
+        Boolean allOk = true;
+
+        DiagramResource DIA = DiagramResource.getInstance(graph);
+        for(Object object : elements) {
+            Resource element = (Resource)object;
+            Boolean value = graph.getPossibleRelatedValue(element, DIA.Element_upProfileMonitors, Bindings.BOOLEAN);
+            if(value == null) value = true;
+            if(!value.equals(allow)) {
+                allOk = false;
+            }
+        }
+
+        if(allOk) return NONE;
+
+        return new IContributionItem[] {
+
+                new ActionContributionItem(new Action(name, image) {
+                    @Override
+                    public void run() {
+
+                        Simantics.getSession().markUndoPoint();
+                        Simantics.async(new WriteRequest() {
+
+                            @Override
+                            public void perform(WriteGraph graph) throws DatabaseException {
+                                Command command = Commands.get(graph, "Simantics/Diagram/setProfileMonitorsDirectionUp");
+                                for(Object object : elements) {
+                                    Resource element = (Resource)object;
+                                    command.execute(graph, graph.syncRequest(new IndexRoot(element)), element, allow);
+                                }
+                            }
+
+                        });
+
+                    }
+                })
+        };
+
+    }
+
+}