]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/handlers/DisconnectFlagHandler.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / diagramEditor / handlers / DisconnectFlagHandler.java
index 6d90afa4552e3737611441ef9bc1e4abf38c77b8..04d1bf2ba4fa3a855f6419491526204e1094167a 100644 (file)
@@ -1,69 +1,69 @@
-/*******************************************************************************\r
- * Copyright (c) 2015 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
- *     Semantum Oy - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.modeling.ui.diagramEditor.handlers;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Set;\r
-\r
-import org.eclipse.core.commands.AbstractHandler;\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.core.runtime.Status;\r
-import org.eclipse.core.runtime.jobs.Job;\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.ui.handlers.HandlerUtil;\r
-import org.simantics.DatabaseJob;\r
-import org.simantics.db.Resource;\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.modeling.actions.DisconnectFlag;\r
-import org.simantics.modeling.ui.Activator;\r
-import org.simantics.ui.SimanticsUI;\r
-import org.simantics.utils.ui.ISelectionUtils;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class DisconnectFlagHandler extends AbstractHandler {\r
-\r
-    @Override\r
-    public Object execute(ExecutionEvent event) throws ExecutionException {\r
-        ISelection sel = HandlerUtil.getCurrentSelection(event);\r
-        final Set<Resource> resources = ISelectionUtils.filterSetSelection(sel, Resource.class);\r
-        if (resources.isEmpty())\r
-            return null;\r
-\r
-        Job job = new DatabaseJob("Disconnect Flags") {\r
-            @Override\r
-            protected IStatus run(IProgressMonitor monitor) {\r
-                try {\r
-                    SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
-                        @Override\r
-                        public void perform(WriteGraph graph) throws DatabaseException {\r
-                            graph.markUndoPoint();\r
-                            DisconnectFlag.disconnectFlags(graph, new ArrayList<>(resources));\r
-                        }\r
-                    });\r
-                    return Status.OK_STATUS;\r
-                } catch (DatabaseException e) {\r
-                    return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to disconnect flags.", e); \r
-                }\r
-            }\r
-        };\r
-        job.schedule();\r
-        return null;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2015 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.modeling.ui.diagramEditor.handlers;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.simantics.DatabaseJob;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.modeling.actions.DisconnectFlag;
+import org.simantics.modeling.ui.Activator;
+import org.simantics.ui.SimanticsUI;
+import org.simantics.utils.ui.ISelectionUtils;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class DisconnectFlagHandler extends AbstractHandler {
+
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        ISelection sel = HandlerUtil.getCurrentSelection(event);
+        final Set<Resource> resources = ISelectionUtils.filterSetSelection(sel, Resource.class);
+        if (resources.isEmpty())
+            return null;
+
+        Job job = new DatabaseJob("Disconnect Flags") {
+            @Override
+            protected IStatus run(IProgressMonitor monitor) {
+                try {
+                    SimanticsUI.getSession().syncRequest(new WriteRequest() {
+                        @Override
+                        public void perform(WriteGraph graph) throws DatabaseException {
+                            graph.markUndoPoint();
+                            DisconnectFlag.disconnectFlags(graph, new ArrayList<>(resources));
+                        }
+                    });
+                    return Status.OK_STATUS;
+                } catch (DatabaseException e) {
+                    return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to disconnect flags.", e); 
+                }
+            }
+        };
+        job.schedule();
+        return null;
+    }
+
+}