lttng: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.kernel.ui / src / org / eclipse / linuxtools / internal / lttng2 / kernel / ui / Activator.java
1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.internal.lttng2.kernel.ui;
14
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.Status;
17 import org.eclipse.jface.resource.ImageDescriptor;
18 import org.eclipse.jface.resource.ImageRegistry;
19 import org.eclipse.swt.graphics.Image;
20 import org.eclipse.ui.plugin.AbstractUIPlugin;
21 import org.osgi.framework.BundleContext;
22
23 /**
24 * The activator class controls the plug-in life cycle
25 */
26 public class Activator extends AbstractUIPlugin {
27
28 // ------------------------------------------------------------------------
29 // Attributes
30 // ------------------------------------------------------------------------
31
32 /**
33 * The plug-in ID
34 */
35 public static final String PLUGIN_ID = "org.eclipse.linuxtools.lttng2.kernel.ui"; //$NON-NLS-1$
36
37 /**
38 * The shared instance
39 */
40 private static Activator plugin;
41
42 // ------------------------------------------------------------------------
43 // Constructors
44 // ------------------------------------------------------------------------
45
46 /**
47 * The constructor
48 */
49 public Activator() {
50 }
51
52 // ------------------------------------------------------------------------
53 // Accessors
54 // ------------------------------------------------------------------------
55
56 /**
57 * Returns the shared instance
58 *
59 * @return the shared instance
60 */
61 public static Activator getDefault() {
62 return plugin;
63 }
64
65 // ------------------------------------------------------------------------
66 // AbstractUIPlugin
67 // ------------------------------------------------------------------------
68
69 @Override
70 public void start(BundleContext context) throws Exception {
71 super.start(context);
72 plugin = this;
73 }
74
75 @Override
76 public void stop(BundleContext context) throws Exception {
77 plugin = null;
78 super.stop(context);
79 }
80
81 @Override
82 protected void initializeImageRegistry(ImageRegistry reg) {
83 }
84
85 // ------------------------------------------------------------------------
86 // Operations
87 // ------------------------------------------------------------------------
88
89 /**
90 * Get the image object from a given path
91 *
92 * @param path
93 * The path to the image file
94 * @return The Image object
95 */
96 public Image getImageFromPath(String path) {
97 return getImageDescripterFromPath(path).createImage();
98 }
99
100 /**
101 * Get the ImageDescriptor from a given path
102 *
103 * @param path
104 * The path to the image file
105 * @return The ImageDescriptor object
106 */
107 public ImageDescriptor getImageDescripterFromPath(String path) {
108 return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
109 }
110
111 /**
112 * Get the Image from a registry
113 *
114 * @param path
115 * The path to the image registry
116 * @return The Image object
117 */
118 public Image getImageFromImageRegistry(String path) {
119 Image icon = getImageRegistry().get(path);
120 if (icon == null) {
121 icon = getImageDescripterFromPath(path).createImage();
122 plugin.getImageRegistry().put(path, icon);
123 }
124 return icon;
125 }
126
127 /**
128 * Logs a message with severity INFO in the runtime log of the plug-in.
129 *
130 * @param message A message to log
131 */
132 public void logInfo(String message) {
133 getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
134 }
135
136 /**
137 * Logs a message and exception with severity INFO in the runtime log of the plug-in.
138 *
139 * @param message A message to log
140 * @param exception A exception to log
141 */
142 public void logInfo(String message, Throwable exception) {
143 getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message, exception));
144 }
145
146 /**
147 * Logs a message and exception with severity WARNING in the runtime log of the plug-in.
148 *
149 * @param message A message to log
150 */
151 public void logWarning(String message) {
152 getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message));
153 }
154
155 /**
156 * Logs a message and exception with severity WARNING in the runtime log of the plug-in.
157 *
158 * @param message A message to log
159 * @param exception A exception to log
160 */
161 public void logWarning(String message, Throwable exception) {
162 getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, exception));
163 }
164
165 /**
166 * Logs a message and exception with severity ERROR in the runtime log of the plug-in.
167 *
168 * @param message A message to log
169 */
170 public void logError(String message) {
171 getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
172 }
173
174 /**
175 * Logs a message and exception with severity ERROR in the runtime log of the plug-in.
176 *
177 * @param message A message to log
178 * @param exception A exception to log
179 */
180 public void logError(String message, Throwable exception) {
181 getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception));
182 }
183
184 }
This page took 0.038555 seconds and 5 git commands to generate.