pcap: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / pcap / org.eclipse.tracecompass.tmf.pcap.ui / src / org / eclipse / tracecompass / internal / tmf / pcap / ui / 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 * Vincent Perot - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.internal.tmf.pcap.ui;
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.eclipse.jdt.annotation.Nullable;
19 import org.osgi.framework.BundleContext;
20
21 /**
22 * <b><u>Activator</u></b>
23 * <p>
24 * The activator class controls the plug-in life cycle
25 */
26 public class Activator extends Plugin {
27
28 // ------------------------------------------------------------------------
29 // Attributes
30 // ------------------------------------------------------------------------
31
32 /**
33 * The plug-in ID
34 */
35 public static final String PLUGIN_ID = "org.eclipse.tracecompass.tmf.pcap.ui"; //$NON-NLS-1$
36
37 /**
38 * The shared instance
39 */
40 private static @Nullable Activator fPlugin;
41
42 // ------------------------------------------------------------------------
43 // Constructors
44 // ------------------------------------------------------------------------
45
46 /**
47 * Constructor
48 */
49 public Activator() {
50 setDefault(this);
51 }
52
53 // ------------------------------------------------------------------------
54 // Accessors
55 // ------------------------------------------------------------------------
56
57 /**
58 * Returns the TMF Core plug-in instance.
59 *
60 * @return the TMF Core plug-in instance.
61 */
62 public static @Nullable Activator getDefault() {
63 return fPlugin;
64 }
65
66 // Sets plug-in instance
67 private static void setDefault(@Nullable Activator plugin) {
68 fPlugin = plugin;
69 }
70
71 // ------------------------------------------------------------------------
72 // Plugin
73 // ------------------------------------------------------------------------
74
75 @Override
76 public void start(@Nullable BundleContext context) throws Exception {
77 super.start(context);
78 setDefault(this);
79 }
80
81 @Override
82 public void stop(@Nullable BundleContext context) throws Exception {
83 setDefault(null);
84 super.stop(context);
85 }
86
87
88 // ------------------------------------------------------------------------
89 // Log an IStatus
90 // ------------------------------------------------------------------------
91
92 /**
93 * Log an IStatus object directly
94 *
95 * @param status
96 * The status to log
97 */
98 public static void log(IStatus status) {
99 Activator activator = fPlugin;
100 if (activator == null) {
101 return;
102 }
103 activator.getLog().log(status);
104 }
105
106 // ------------------------------------------------------------------------
107 // Log INFO
108 // ------------------------------------------------------------------------
109
110 /**
111 * Logs a message with severity INFO in the runtime log of the plug-in.
112 *
113 * @param message
114 * A message to log
115 */
116 public static void logInfo(String message) {
117 Activator activator = fPlugin;
118 if (activator == null) {
119 return;
120 }
121 activator.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
122 }
123
124 /**
125 * Logs a message and exception with severity INFO in the runtime log of the
126 * plug-in.
127 *
128 * @param message
129 * A message to log
130 * @param exception
131 * The corresponding exception
132 */
133 public static void logInfo(String message, Throwable exception) {
134 Activator activator = fPlugin;
135 if (activator == null) {
136 return;
137 }
138 activator.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message, exception));
139 }
140
141 // ------------------------------------------------------------------------
142 // Log WARNING
143 // ------------------------------------------------------------------------
144
145 /**
146 * Logs a message and exception with severity WARNING in the runtime log of
147 * the plug-in.
148 *
149 * @param message
150 * A message to log
151 */
152 public static void logWarning(String message) {
153 Activator activator = fPlugin;
154 if (activator == null) {
155 return;
156 }
157 activator.getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message));
158 }
159
160 /**
161 * Logs a message and exception with severity WARNING in the runtime log of
162 * the plug-in.
163 *
164 * @param message
165 * A message to log
166 * @param exception
167 * The corresponding exception
168 */
169 public static void logWarning(String message, Throwable exception) {
170 Activator activator = fPlugin;
171 if (activator == null) {
172 return;
173 }
174 activator.getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, exception));
175 }
176
177 // ------------------------------------------------------------------------
178 // Log ERROR
179 // ------------------------------------------------------------------------
180
181 /**
182 * Logs a message and exception with severity ERROR in the runtime log of
183 * the plug-in.
184 *
185 * @param message
186 * A message to log
187 */
188 public static void logError(String message) {
189 Activator activator = fPlugin;
190 if (activator == null) {
191 return;
192 }
193 activator.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
194 }
195
196 /**
197 * Logs a message and exception with severity ERROR in the runtime log of
198 * the plug-in.
199 *
200 * @param message
201 * A message to log
202 * @param exception
203 * The corresponding exception
204 */
205 public static void logError(String message, Throwable exception) {
206 Activator activator = fPlugin;
207 if (activator == null) {
208 return;
209 }
210 activator.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception));
211 }
212 }
This page took 0.035292 seconds and 5 git commands to generate.