]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/internal/Activator.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.reflection / src / org / simantics / scl / reflection / internal / Activator.java
1 package org.simantics.scl.reflection.internal;\r
2 \r
3 import org.eclipse.core.runtime.ILog;\r
4 import org.eclipse.core.runtime.Platform;\r
5 import org.eclipse.core.runtime.Status;\r
6 import org.osgi.framework.Bundle;\r
7 import org.osgi.framework.BundleActivator;\r
8 import org.osgi.framework.BundleContext;\r
9 \r
10 public class Activator implements BundleActivator {\r
11 \r
12     private BundleContext context;  \r
13     \r
14     private static Activator instance;\r
15     \r
16     @Override\r
17     public void start(BundleContext context) throws Exception {\r
18         this.context = context;\r
19         instance = this;\r
20     }\r
21 \r
22     @Override\r
23     public void stop(BundleContext context) throws Exception {\r
24         instance = null;\r
25         this.context = null;\r
26     }\r
27     \r
28     public BundleContext getContext() {\r
29         return context;\r
30     }\r
31     \r
32     public static Activator getInstance() {\r
33         return instance;\r
34     }\r
35         \r
36     public static void logError(String description, Exception e) {\r
37         System.err.println(description);\r
38         if(e != null)\r
39             e.printStackTrace();\r
40         Bundle bundle = getInstance().getContext().getBundle();\r
41         ILog log = Platform.getLog(bundle);\r
42         log.log(new Status(Status.ERROR, bundle.getSymbolicName(), description, e));\r
43     }\r
44     \r
45     public static void logError(String description) {\r
46         logError(description, null);\r
47     }\r
48 \r
49 }\r