-/*******************************************************************************\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.internal;\r
-\r
-import java.io.File;\r
-import java.net.URL;\r
-import java.net.URLDecoder;\r
-import java.util.Hashtable;\r
-\r
-import org.eclipse.core.runtime.FileLocator;\r
-import org.osgi.framework.BundleActivator;\r
-import org.osgi.framework.BundleContext;\r
-import org.simantics.debug.browser.content.ResourceBrowserRewriter;\r
-import org.simantics.debug.browser.internal.rewriters.BreadcrumbCreator;\r
-import org.simantics.debug.browser.internal.rewriters.PageHeaderCreator;\r
-import org.simantics.debug.browser.internal.rewriters.RawStatementsCreator;\r
-import org.simantics.debug.browser.internal.rewriters.ResourceInfoCreator;\r
-import org.simantics.debug.browser.internal.rewriters.ResourceLookupCreator;\r
-import org.simantics.debug.browser.internal.rewriters.TypeHierarchyCreator;\r
-\r
-public class Activator implements BundleActivator {\r
-\r
- public static final String PLUGIN_ID = "org.simantics.debug.browser";\r
- private static BundleContext context;\r
- private static Activator plugin;\r
- private static String resourcesPath;\r
- private DebugBrowserServer server;\r
-\r
- /*\r
- * (non-Javadoc)\r
- * \r
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.\r
- * BundleContext)\r
- */\r
- @SuppressWarnings({ "unchecked", "rawtypes" })\r
- public void start(BundleContext bundleContext) throws Exception {\r
- Activator.context = bundleContext;\r
- plugin = this;\r
-\r
- Hashtable properties = new Hashtable();\r
- bundleContext.registerService(ResourceBrowserRewriter.class, PageHeaderCreator.INSTANCE, properties);\r
- bundleContext.registerService(ResourceBrowserRewriter.class, ResourceLookupCreator.INSTANCE, properties);\r
- bundleContext.registerService(ResourceBrowserRewriter.class, RawStatementsCreator.INSTANCE, properties);\r
- bundleContext.registerService(ResourceBrowserRewriter.class, BreadcrumbCreator.INSTANCE, properties);\r
- bundleContext.registerService(ResourceBrowserRewriter.class, TypeHierarchyCreator.INSTANCE, properties);\r
- bundleContext.registerService(ResourceBrowserRewriter.class, ResourceInfoCreator.INSTANCE, properties);\r
-\r
- URL url = context.getBundle().getEntry("resources");\r
- URL fileURL = FileLocator.toFileURL(url);\r
- File filePath = new File(URLDecoder.decode(fileURL.getPath(), "UTF-8"));\r
- resourcesPath = filePath.getCanonicalPath();\r
- }\r
-\r
- public DebugBrowserServer getDebugServer() {\r
- return server;\r
- }\r
-\r
- public synchronized DebugBrowserServer startDebugServer() throws Exception {\r
- if (server == null) {\r
- server = new DebugBrowserServer(resourcesPath);\r
- server.start();\r
- }\r
- return server;\r
- }\r
-\r
- public synchronized void stopDebugServer() throws Exception {\r
- if (server != null) {\r
- server.stop();\r
- }\r
- server = null;\r
- }\r
-\r
- public static BundleContext getContext() {\r
- return context;\r
- }\r
-\r
- /*\r
- * (non-Javadoc)\r
- * \r
- * @see\r
- * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)\r
- */\r
- public void stop(BundleContext bundleContext) throws Exception {\r
- stopDebugServer();\r
- Activator.context = null;\r
- }\r
-\r
- /**\r
- * Returns the shared instance\r
- *\r
- * @return the shared instance\r
- */\r
- public static Activator getDefault() {\r
- return plugin;\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.internal;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.util.Hashtable;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.simantics.debug.browser.content.ResourceBrowserRewriter;
+import org.simantics.debug.browser.internal.rewriters.BreadcrumbCreator;
+import org.simantics.debug.browser.internal.rewriters.PageHeaderCreator;
+import org.simantics.debug.browser.internal.rewriters.RawStatementsCreator;
+import org.simantics.debug.browser.internal.rewriters.ResourceInfoCreator;
+import org.simantics.debug.browser.internal.rewriters.ResourceLookupCreator;
+import org.simantics.debug.browser.internal.rewriters.TypeHierarchyCreator;
+
+public class Activator implements BundleActivator {
+
+ public static final String PLUGIN_ID = "org.simantics.debug.browser";
+ private static BundleContext context;
+ private static Activator plugin;
+ private static String resourcesPath;
+ private DebugBrowserServer server;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.
+ * BundleContext)
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ plugin = this;
+
+ Hashtable properties = new Hashtable();
+ bundleContext.registerService(ResourceBrowserRewriter.class, PageHeaderCreator.INSTANCE, properties);
+ bundleContext.registerService(ResourceBrowserRewriter.class, ResourceLookupCreator.INSTANCE, properties);
+ bundleContext.registerService(ResourceBrowserRewriter.class, RawStatementsCreator.INSTANCE, properties);
+ bundleContext.registerService(ResourceBrowserRewriter.class, BreadcrumbCreator.INSTANCE, properties);
+ bundleContext.registerService(ResourceBrowserRewriter.class, TypeHierarchyCreator.INSTANCE, properties);
+ bundleContext.registerService(ResourceBrowserRewriter.class, ResourceInfoCreator.INSTANCE, properties);
+
+ URL url = context.getBundle().getEntry("resources");
+ URL fileURL = FileLocator.toFileURL(url);
+ File filePath = new File(URLDecoder.decode(fileURL.getPath(), "UTF-8"));
+ resourcesPath = filePath.getCanonicalPath();
+ }
+
+ public DebugBrowserServer getDebugServer() {
+ return server;
+ }
+
+ public synchronized DebugBrowserServer startDebugServer() throws Exception {
+ if (server == null) {
+ server = new DebugBrowserServer(resourcesPath);
+ server.start();
+ }
+ return server;
+ }
+
+ public synchronized void stopDebugServer() throws Exception {
+ if (server != null) {
+ server.stop();
+ }
+ server = null;
+ }
+
+ public static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ stopDebugServer();
+ Activator.context = null;
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}