]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/internal/Activator.java b/bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/internal/Activator.java
new file mode 100755 (executable)
index 0000000..9836dfe
--- /dev/null
@@ -0,0 +1,49 @@
+package org.simantics.scl.reflection.internal;\r
+\r
+import org.eclipse.core.runtime.ILog;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.core.runtime.Status;\r
+import org.osgi.framework.Bundle;\r
+import org.osgi.framework.BundleActivator;\r
+import org.osgi.framework.BundleContext;\r
+\r
+public class Activator implements BundleActivator {\r
+\r
+    private BundleContext context;  \r
+    \r
+    private static Activator instance;\r
+    \r
+    @Override\r
+    public void start(BundleContext context) throws Exception {\r
+        this.context = context;\r
+        instance = this;\r
+    }\r
+\r
+    @Override\r
+    public void stop(BundleContext context) throws Exception {\r
+        instance = null;\r
+        this.context = null;\r
+    }\r
+    \r
+    public BundleContext getContext() {\r
+        return context;\r
+    }\r
+    \r
+    public static Activator getInstance() {\r
+        return instance;\r
+    }\r
+        \r
+    public static void logError(String description, Exception e) {\r
+        System.err.println(description);\r
+        if(e != null)\r
+            e.printStackTrace();\r
+        Bundle bundle = getInstance().getContext().getBundle();\r
+        ILog log = Platform.getLog(bundle);\r
+        log.log(new Status(Status.ERROR, bundle.getSymbolicName(), description, e));\r
+    }\r
+    \r
+    public static void logError(String description) {\r
+        logError(description, null);\r
+    }\r
+\r
+}\r