btf: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / internal / ctf / core / Activator.java
CommitLineData
866e5b51 1/*******************************************************************************
4311ac8b 2 * Copyright (c) 2011, 2013 Ericsson, Ecole Polytechnique de Montreal and others
866e5b51
FC
3 *
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
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
a9d52b8f 13package org.eclipse.linuxtools.internal.ctf.core;
866e5b51
FC
14
15import org.eclipse.core.runtime.IStatus;
16import org.eclipse.core.runtime.Plugin;
17import org.eclipse.core.runtime.Status;
18import org.osgi.framework.BundleContext;
19
20/**
a9d52b8f 21 * <b><u>Activator</u></b>
866e5b51 22 * <p>
a9d52b8f 23 * The activator class controls the plug-in life cycle.
866e5b51 24 */
a9d52b8f 25public class Activator extends Plugin {
866e5b51
FC
26
27 // ------------------------------------------------------------------------
28 // Attributes
29 // ------------------------------------------------------------------------
30
9ac2eb62
MK
31 /**
32 * The plug-in ID
33 */
866e5b51
FC
34 public static final String PLUGIN_ID = "org.eclipse.linuxtools.ctf"; //$NON-NLS-1$
35
9ac2eb62
MK
36 /**
37 * The shared instance
38 */
a9d52b8f 39 private static Activator fPlugin;
866e5b51
FC
40
41 // ------------------------------------------------------------------------
42 // Constructors
43 // ------------------------------------------------------------------------
44
9ac2eb62
MK
45 /**
46 * Constructor
47 */
a9d52b8f 48 public Activator() {
866e5b51
FC
49 setDefault(this);
50 }
51
52 // ------------------------------------------------------------------------
53 // Accessors
54 // ------------------------------------------------------------------------
55
9ac2eb62
MK
56 /**
57 * Get the default activator
58 * @return the default activator
59 */
a9d52b8f 60 public static Activator getDefault() {
866e5b51
FC
61 return fPlugin;
62 }
63
9ac2eb62
MK
64 /**
65 * Sets the default activator
66 *
67 * @param plugin the default activator
68 */
a9d52b8f 69 private static void setDefault(Activator plugin) {
866e5b51
FC
70 fPlugin = plugin;
71 }
72
73 // ------------------------------------------------------------------------
74 // Plugin
75 // ------------------------------------------------------------------------
76
77 @Override
78 public void start(BundleContext context) throws Exception {
79 super.start(context);
80 setDefault(this);
81 }
82
83 @Override
84 public void stop(BundleContext context) throws Exception {
85 setDefault(null);
86 super.stop(context);
87 }
88
89 // ------------------------------------------------------------------------
90 // Logging
91 // ------------------------------------------------------------------------
92
9ac2eb62
MK
93 /**
94 * Log a message
cad411b8
AM
95 *
96 * @param msg
97 * The message to log
9ac2eb62 98 */
4311ac8b 99 public static void log(String msg) {
866e5b51
FC
100 log(msg, null);
101 }
102
9ac2eb62
MK
103 /**
104 * Log a message with an exception
cad411b8
AM
105 *
106 * @param msg
107 * The message
108 * @param e
109 * The exception
9ac2eb62 110 */
4311ac8b
MAL
111 public static void log(String msg, Exception e) {
112 getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, IStatus.OK, msg, e));
866e5b51
FC
113 }
114
cad411b8
AM
115 /**
116 * Log an error, with an associated exception
117 *
118 * @param msg
119 * The error message
120 * @param e
121 * The cause
122 */
123 public static void logError(String msg, Exception e) {
124 getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, e));
125 }
126
4311ac8b
MAL
127 /**
128 * Log a message
cad411b8
AM
129 *
130 * @param severity
131 * Desired severity of the message in the log, one of
132 * {@link IStatus#INFO}, {@link IStatus#WARNING} or
133 * {@link IStatus#ERROR}
134 * @param msg
135 * The message to log
4311ac8b
MAL
136 */
137 public static void log(int severity, String msg) {
138 getDefault().getLog().log(new Status(severity, PLUGIN_ID, msg));
139 }
140
141
866e5b51 142}
This page took 0.049248 seconds and 5 git commands to generate.