]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.debug.browser.ui/src/org/simantics/debug/browser/ui/LaunchDebugBrowser.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.debug.browser.ui / src / org / simantics / debug / browser / ui / LaunchDebugBrowser.java
index e7041539c359cbf421d06c30e8fac3a087420d5c..d3a16abb3e2159ff11371e7259d16a0f1ed7fd0e 100644 (file)
@@ -1,86 +1,86 @@
-/*******************************************************************************\r
- * Copyright (c) 2016 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
- *     THTH ry - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.debug.browser.ui;\r
-\r
-import java.net.URL;\r
-\r
-import javax.inject.Named;\r
-\r
-import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.core.runtime.Platform;\r
-import org.eclipse.core.runtime.Status;\r
-import org.eclipse.e4.core.di.annotations.CanExecute;\r
-import org.eclipse.e4.core.di.annotations.Execute;\r
-import org.eclipse.e4.ui.services.IServiceConstants;\r
-import org.eclipse.jface.dialogs.ErrorDialog;\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.eclipse.ui.browser.IWebBrowser;\r
-import org.eclipse.ui.browser.IWorkbenchBrowserSupport;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.layer0.SelectionHints;\r
-import org.simantics.debug.browser.internal.DebugBrowserServer;\r
-import org.simantics.utils.ui.ISelectionUtils;\r
-\r
-/**\r
- * @author Jani Simomaa / Semantum Oy\r
- * @author Tuukka Lehtonen / Semantum Oy\r
- * @since 1.22\r
- */\r
-public class LaunchDebugBrowser {\r
-\r
-    private static int browserCounter = 0;\r
-\r
-    @CanExecute\r
-    public boolean canExecute() {\r
-        return Platform.inDevelopmentMode();\r
-    }\r
-\r
-    @Execute\r
-    public void execute(\r
-            @Named(IServiceConstants.ACTIVE_SHELL) Shell activeShell,\r
-            @Named(IServiceConstants.ACTIVE_SELECTION) ISelection selection)\r
-    {\r
-        try {\r
-            // Start Jetty server for graph debugging\r
-            DebugBrowserServer server = org.simantics.debug.browser.internal.Activator.getDefault().startDebugServer();\r
-            URL url = server.getURL();\r
-\r
-            // Get default input from current workbench selection\r
-            Resource input = ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MAIN, Resource.class, true);\r
-            URL inputUrl = input != null ? new URL(url.toExternalForm() + "/" + input.getResourceId()) : url;\r
-\r
-            // Open browser\r
-            IWorkbenchBrowserSupport bs = PlatformUI.getWorkbench().getBrowserSupport();\r
-            if (bs.isInternalWebBrowserAvailable()) {\r
-                IWebBrowser browser = bs.createBrowser(\r
-                        IWorkbenchBrowserSupport.AS_EDITOR\r
-                        | IWorkbenchBrowserSupport.NAVIGATION_BAR\r
-                        | IWorkbenchBrowserSupport.LOCATION_BAR\r
-                        , "graph.debug.browser." + (browserCounter++),\r
-                        "Database Debug Browser",\r
-                        url.toString());\r
-                browser.openURL(inputUrl);\r
-            } else {\r
-                bs.getExternalBrowser().openURL(inputUrl);\r
-            }\r
-        } catch (Exception e) {\r
-            Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to open external browser.", e));\r
-            ErrorDialog.openError(activeShell,\r
-                    "Failed to Open External Browser",\r
-                    "Failed to open debug browser in the default external web browser. See exception for details.",\r
-                    new Status(Status.ERROR, Activator.PLUGIN_ID, "", e));\r
-        }\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2016 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:
+ *     THTH ry - initial API and implementation
+ *******************************************************************************/
+package org.simantics.debug.browser.ui;
+
+import java.net.URL;
+
+import javax.inject.Named;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.browser.IWebBrowser;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.simantics.db.Resource;
+import org.simantics.db.layer0.SelectionHints;
+import org.simantics.debug.browser.internal.DebugBrowserServer;
+import org.simantics.utils.ui.ISelectionUtils;
+
+/**
+ * @author Jani Simomaa / Semantum Oy
+ * @author Tuukka Lehtonen / Semantum Oy
+ * @since 1.22
+ */
+public class LaunchDebugBrowser {
+
+    private static int browserCounter = 0;
+
+    @CanExecute
+    public boolean canExecute() {
+        return Platform.inDevelopmentMode();
+    }
+
+    @Execute
+    public void execute(
+            @Named(IServiceConstants.ACTIVE_SHELL) Shell activeShell,
+            @Named(IServiceConstants.ACTIVE_SELECTION) ISelection selection)
+    {
+        try {
+            // Start Jetty server for graph debugging
+            DebugBrowserServer server = org.simantics.debug.browser.internal.Activator.getDefault().startDebugServer();
+            URL url = server.getURL();
+
+            // Get default input from current workbench selection
+            Resource input = ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MAIN, Resource.class, true);
+            URL inputUrl = input != null ? new URL(url.toExternalForm() + "/" + input.getResourceId()) : url;
+
+            // Open browser
+            IWorkbenchBrowserSupport bs = PlatformUI.getWorkbench().getBrowserSupport();
+            if (bs.isInternalWebBrowserAvailable()) {
+                IWebBrowser browser = bs.createBrowser(
+                        IWorkbenchBrowserSupport.AS_EDITOR
+                        | IWorkbenchBrowserSupport.NAVIGATION_BAR
+                        | IWorkbenchBrowserSupport.LOCATION_BAR
+                        , "graph.debug.browser." + (browserCounter++),
+                        "Database Debug Browser",
+                        url.toString());
+                browser.openURL(inputUrl);
+            } else {
+                bs.getExternalBrowser().openURL(inputUrl);
+            }
+        } catch (Exception e) {
+            Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to open external browser.", e));
+            ErrorDialog.openError(activeShell,
+                    "Failed to Open External Browser",
+                    "Failed to open debug browser in the default external web browser. See exception for details.",
+                    new Status(Status.ERROR, Activator.PLUGIN_ID, "", e));
+        }
+    }
+
+}