]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/handlers/CommandUtil.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / diagramEditor / handlers / CommandUtil.java
index 21182743694472898a3a4e8eb1a8d21be4ff9b55..e86eeec6917e458783d90ed516f60361aca99d97 100644 (file)
@@ -1,79 +1,79 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.ui.diagramEditor.handlers;\r
-\r
-import org.eclipse.core.commands.Command;\r
-import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.core.commands.IParameter;\r
-import org.eclipse.core.commands.IParameterValues;\r
-import org.eclipse.core.commands.NotEnabledException;\r
-import org.eclipse.core.commands.NotHandledException;\r
-import org.eclipse.core.commands.ParameterValuesException;\r
-import org.eclipse.core.commands.Parameterization;\r
-import org.eclipse.core.commands.ParameterizedCommand;\r
-import org.eclipse.core.commands.common.NotDefinedException;\r
-import org.eclipse.ui.IWorkbench;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.eclipse.ui.commands.ICommandService;\r
-import org.eclipse.ui.handlers.IHandlerService;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class CommandUtil {\r
-\r
-    /**\r
-     * @param viewIdPart a part of the ID of the view to be shown\r
-     * @throws ExecutionException any errors occur during command execution or\r
-     *         if several views contain the specified string\r
-     */\r
-    public static void showView(String viewIdPart) throws ExecutionException {\r
-        IWorkbench workbench = PlatformUI.getWorkbench();\r
-        ICommandService commandService = (ICommandService) workbench.getService(ICommandService.class);\r
-        IHandlerService handlerService = (IHandlerService) workbench.getService(IHandlerService.class);\r
-        Command showView = commandService.getCommand("org.eclipse.ui.views.showView");\r
-\r
-        try {\r
-            IParameter viewIdParm = showView.getParameter("org.eclipse.ui.views.showView.viewId");\r
-\r
-            // the viewId parameter provides a list of valid values ... if you\r
-            // knew the id of the problem view, you could skip this step.\r
-            // This method is supposed to be used in places like the keys\r
-            // preference page, to allow the user to select values\r
-            IParameterValues parmValues = viewIdParm.getValues();\r
-            String viewId = null;\r
-            for (Object o : parmValues.getParameterValues().values()) {\r
-                String id = (String) o;\r
-                if (id.indexOf(viewIdPart) != -1) {\r
-                    viewId = id;\r
-                    break;\r
-                }\r
-            }\r
-            if (viewId == null)\r
-                return;\r
-\r
-            Parameterization parm = new Parameterization(viewIdParm, viewId);\r
-            ParameterizedCommand parmCommand = new ParameterizedCommand(showView, new Parameterization[] { parm });\r
-\r
-            handlerService.executeCommand(parmCommand, null);\r
-        } catch (ParameterValuesException e) {\r
-            throw new ExecutionException("could not get parameter values for showView command", e);\r
-        } catch (NotDefinedException e) {\r
-            throw new ExecutionException("showView command definition problem", e);\r
-        } catch (NotEnabledException e) {\r
-            throw new ExecutionException("showView command not enabled", e);\r
-        } catch (NotHandledException e) {\r
-            throw new ExecutionException("no handler for showView command", e);\r
-        }\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 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:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.modeling.ui.diagramEditor.handlers;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IParameter;
+import org.eclipse.core.commands.IParameterValues;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.ParameterValuesException;
+import org.eclipse.core.commands.Parameterization;
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.IHandlerService;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class CommandUtil {
+
+    /**
+     * @param viewIdPart a part of the ID of the view to be shown
+     * @throws ExecutionException any errors occur during command execution or
+     *         if several views contain the specified string
+     */
+    public static void showView(String viewIdPart) throws ExecutionException {
+        IWorkbench workbench = PlatformUI.getWorkbench();
+        ICommandService commandService = (ICommandService) workbench.getService(ICommandService.class);
+        IHandlerService handlerService = (IHandlerService) workbench.getService(IHandlerService.class);
+        Command showView = commandService.getCommand("org.eclipse.ui.views.showView");
+
+        try {
+            IParameter viewIdParm = showView.getParameter("org.eclipse.ui.views.showView.viewId");
+
+            // the viewId parameter provides a list of valid values ... if you
+            // knew the id of the problem view, you could skip this step.
+            // This method is supposed to be used in places like the keys
+            // preference page, to allow the user to select values
+            IParameterValues parmValues = viewIdParm.getValues();
+            String viewId = null;
+            for (Object o : parmValues.getParameterValues().values()) {
+                String id = (String) o;
+                if (id.indexOf(viewIdPart) != -1) {
+                    viewId = id;
+                    break;
+                }
+            }
+            if (viewId == null)
+                return;
+
+            Parameterization parm = new Parameterization(viewIdParm, viewId);
+            ParameterizedCommand parmCommand = new ParameterizedCommand(showView, new Parameterization[] { parm });
+
+            handlerService.executeCommand(parmCommand, null);
+        } catch (ParameterValuesException e) {
+            throw new ExecutionException("could not get parameter values for showView command", e);
+        } catch (NotDefinedException e) {
+            throw new ExecutionException("showView command definition problem", e);
+        } catch (NotEnabledException e) {
+            throw new ExecutionException("showView command not enabled", e);
+        } catch (NotHandledException e) {
+            throw new ExecutionException("no handler for showView command", e);
+        }
+    }
+
+}