--- /dev/null
+package org.simantics.diagram.profile.view;\r
+\r
+import java.net.URL;\r
+\r
+import org.eclipse.ui.plugin.AbstractUIPlugin;\r
+import org.osgi.framework.BundleContext;\r
+import org.osgi.util.tracker.ServiceTracker;\r
+\r
+public class Activator extends AbstractUIPlugin {\r
+\r
+ // The plug-in ID\r
+ public static final String PLUGIN_ID = "org.simantics.diagram.profile";\r
+\r
+ // The shared instance\r
+ private static Activator plugin;\r
+\r
+ private BundleContext bundleContext;\r
+\r
+ private ServiceTracker<?, ?> logTracker;\r
+\r
+ /**\r
+ * The constructor\r
+ */\r
+ public Activator() {\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)\r
+ */\r
+ @Override\r
+ public void start(BundleContext context) throws Exception {\r
+ super.start(context);\r
+ this.bundleContext = context;\r
+ plugin = this;\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)\r
+ */\r
+ @Override\r
+ public void stop(BundleContext context) throws Exception {\r
+ if (logTracker != null) {\r
+ logTracker.close();\r
+ logTracker = null;\r
+ }\r
+\r
+ this.bundleContext = null;\r
+ plugin = null;\r
+ super.stop(context);\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
+ public BundleContext getContext() {\r
+ return bundleContext;\r
+ }\r
+\r
+ public static URL getDefaultResource(String name) {\r
+ Activator plugin = getDefault();\r
+ if(plugin == null) throw new IllegalStateException("The plugin is not active.");\r
+ return plugin.getBundle().getResource(name);\r
+ }\r
+\r
+}\r