1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Matthew Khouzam - Initial implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.btf
.ui
;
15 import org
.eclipse
.core
.runtime
.IStatus
;
16 import org
.eclipse
.core
.runtime
.Platform
;
17 import org
.eclipse
.core
.runtime
.Plugin
;
18 import org
.eclipse
.core
.runtime
.Status
;
19 import org
.eclipse
.linuxtools
.btf
.core
.event
.BtfEvent
;
20 import org
.osgi
.framework
.BundleContext
;
23 * The activator class controls the plug-in life cycle. No more than one such
24 * plug-in can exist at any time.
26 * It also provides the plug-in's general logging facility and manages the
29 public class Activator
extends Plugin
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
38 public static final String PLUGIN_ID
= "org.eclipse.linuxtools.btf.ui"; //$NON-NLS-1$
43 private static Activator fPlugin
;
45 private BtfEventAdapterFactory fBtfEventAdapterFactory
;
48 // ------------------------------------------------------------------------
50 // ------------------------------------------------------------------------
59 // ------------------------------------------------------------------------
61 // ------------------------------------------------------------------------
64 * Returns the BTF plug-in instance.
66 * @return the BTF plug-in instance.
68 public static Activator
getDefault() {
72 // Sets plug-in instance
73 private static void setDefault(Activator plugin
) {
77 // ------------------------------------------------------------------------
79 // ------------------------------------------------------------------------
82 public void start(BundleContext context
) throws Exception
{
85 fBtfEventAdapterFactory
= new BtfEventAdapterFactory();
86 Platform
.getAdapterManager().registerAdapters(fBtfEventAdapterFactory
, BtfEvent
.class);
90 public void stop(BundleContext context
) throws Exception
{
96 // ------------------------------------------------------------------------
98 // ------------------------------------------------------------------------
101 * Log an IStatus object directly
106 public static void log(IStatus status
) {
107 fPlugin
.getLog().log(status
);
110 // ------------------------------------------------------------------------
112 // ------------------------------------------------------------------------
115 * Logs a message with severity INFO in the runtime log of the plug-in.
120 public static void logInfo(String message
) {
121 fPlugin
.getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
));
125 * Logs a message and exception with severity INFO in the runtime log of the
131 * The corresponding exception
133 public static void logInfo(String message
, Throwable exception
) {
134 fPlugin
.getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
, exception
));
137 // ------------------------------------------------------------------------
139 // ------------------------------------------------------------------------
142 * Logs a message and exception with severity WARNING in the runtime log of
148 public static void logWarning(String message
) {
149 fPlugin
.getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
));
153 * Logs a message and exception with severity WARNING in the runtime log of
159 * The corresponding exception
161 public static void logWarning(String message
, Throwable exception
) {
162 fPlugin
.getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
, exception
));
165 // ------------------------------------------------------------------------
167 // ------------------------------------------------------------------------
170 * Logs a message and exception with severity ERROR in the runtime log of
176 public static void logError(String message
) {
177 fPlugin
.getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
));
181 * Logs a message and exception with severity ERROR in the runtime log of
187 * The corresponding exception
189 public static void logError(String message
, Throwable exception
) {
190 fPlugin
.getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
, exception
));