tmf: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.alltests / src / org / eclipse / tracecompass / alltests / Activator.java
1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 Ericsson
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 * Marc-Andre Laperle - Initial implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.alltests;
14
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.Plugin;
17 import org.eclipse.core.runtime.Status;
18 import org.osgi.framework.BundleContext;
19
20 /**
21 * The activator class controls the plug-in life cycle. No more than one such
22 * plug-in can exist at any time.
23 * <p>
24 * It also provides the plug-in's general logging facility and manages the
25 * internal tracer.
26 */
27 public class Activator extends Plugin {
28
29 /**
30 * The plug-in ID
31 */
32 public static final String PLUGIN_ID = "org.eclipse.tracecompass.alltests"; //$NON-NLS-1$
33
34 /**
35 * The shared instance
36 */
37 private static Activator fPlugin;
38
39 /**
40 * Constructor
41 */
42 public Activator() {
43 setDefault(this);
44 }
45
46 // ------------------------------------------------------------------------
47 // Accessors
48 // ------------------------------------------------------------------------
49
50 /**
51 * Returns the AllTests plug-in instance.
52 *
53 * @return the AllTests plug-in instance.
54 */
55 public static Activator getDefault() {
56 return fPlugin;
57 }
58
59 // Sets plug-in instance
60 private static void setDefault(Activator plugin) {
61 fPlugin = plugin;
62 }
63
64 // ------------------------------------------------------------------------
65 // Plugin
66 // ------------------------------------------------------------------------
67
68 @Override
69 public void start(BundleContext context) throws Exception {
70 super.start(context);
71 setDefault(this);
72 }
73
74 @Override
75 public void stop(BundleContext context) throws Exception {
76 setDefault(null);
77 super.stop(context);
78 }
79
80
81 /**
82 * Log an IStatus object directly
83 *
84 * @param status
85 * The status to log
86 */
87 public static void log(IStatus status) {
88 fPlugin.getLog().log(status);
89 }
90
91 // ------------------------------------------------------------------------
92 // Log INFO
93 // ------------------------------------------------------------------------
94
95 /**
96 * Logs a message with severity INFO in the runtime log of the plug-in.
97 *
98 * @param message
99 * A message to log
100 */
101 public static void logInfo(String message) {
102 fPlugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
103 }
104
105 /**
106 * Logs a message and exception with severity INFO in the runtime log of the
107 * plug-in.
108 *
109 * @param message
110 * A message to log
111 * @param exception
112 * The corresponding exception
113 */
114 public static void logInfo(String message, Throwable exception) {
115 fPlugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message, exception));
116 }
117
118 // ------------------------------------------------------------------------
119 // Log WARNING
120 // ------------------------------------------------------------------------
121
122 /**
123 * Logs a message and exception with severity WARNING in the runtime log of
124 * the plug-in.
125 *
126 * @param message
127 * A message to log
128 */
129 public static void logWarning(String message) {
130 fPlugin.getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message));
131 }
132
133 /**
134 * Logs a message and exception with severity WARNING in the runtime log of
135 * the plug-in.
136 *
137 * @param message
138 * A message to log
139 * @param exception
140 * The corresponding exception
141 */
142 public static void logWarning(String message, Throwable exception) {
143 fPlugin.getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, exception));
144 }
145
146 // ------------------------------------------------------------------------
147 // Log ERROR
148 // ------------------------------------------------------------------------
149
150 /**
151 * Logs a message and exception with severity ERROR in the runtime log of
152 * the plug-in.
153 *
154 * @param message
155 * A message to log
156 */
157 public static void logError(String message) {
158 fPlugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
159 }
160
161 /**
162 * Logs a message and exception with severity ERROR in the runtime log of
163 * the plug-in.
164 *
165 * @param message
166 * A message to log
167 * @param exception
168 * The corresponding exception
169 */
170 public static void logError(String message, Throwable exception) {
171 fPlugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception));
172 }
173 }
This page took 0.059389 seconds and 5 git commands to generate.