gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.ui / src / org / eclipse / linuxtools / internal / lttng2 / control / ui / Activator.java
CommitLineData
a7780cc8 1/*******************************************************************************
11252342
AM
2 * Copyright (c) 2012, 2013 Ericsson
3 *
a7780cc8
FC
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
11252342 8 *
a7780cc8
FC
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
8e8c0226 13package org.eclipse.linuxtools.internal.lttng2.control.ui;
a7780cc8 14
115b4a01
BH
15import java.net.URL;
16
9fa32496
BH
17import org.eclipse.core.runtime.IStatus;
18import org.eclipse.core.runtime.Status;
a7780cc8
FC
19import org.eclipse.jface.resource.ImageDescriptor;
20import org.eclipse.jface.resource.ImageRegistry;
6fd3c6e9 21import org.eclipse.linuxtools.internal.lttng2.control.ui.relayd.LttngRelaydConnectionManager;
8e8c0226 22import org.eclipse.linuxtools.internal.lttng2.control.ui.views.preferences.ControlPreferences;
a7780cc8
FC
23import org.eclipse.swt.graphics.Image;
24import org.eclipse.ui.plugin.AbstractUIPlugin;
25import org.osgi.framework.BundleContext;
26
27/**
28 * The activator class controls the plug-in life cycle
29 */
30public class Activator extends AbstractUIPlugin {
31
32 // ------------------------------------------------------------------------
33 // Attributes
34 // ------------------------------------------------------------------------
35
36 /**
37 * The plug-in ID
38 */
8e8c0226 39 public static final String PLUGIN_ID = "org.eclipse.linuxtools.lttng2.control.ui"; //$NON-NLS-1$
a7780cc8
FC
40
41 /**
42 * The shared instance
43 */
44 private static Activator plugin;
45
46 // ------------------------------------------------------------------------
47 // Constructors
48 // ------------------------------------------------------------------------
49
50 /**
51 * The constructor
52 */
53 public Activator() {
54 }
55
56 // ------------------------------------------------------------------------
57 // Accessors
58 // ------------------------------------------------------------------------
59
60 /**
61 * Returns the shared instance
62 *
63 * @return the shared instance
64 */
65 public static Activator getDefault() {
66 return plugin;
67 }
68
69 // ------------------------------------------------------------------------
70 // AbstractUIPlugin
71 // ------------------------------------------------------------------------
72
a7780cc8
FC
73 @Override
74 public void start(BundleContext context) throws Exception {
75 super.start(context);
76 plugin = this;
9315aeee 77 ControlPreferences.getInstance().init(getPreferenceStore());
6fd3c6e9
MAL
78 // This registers the connection manager with the signal manager
79 LttngRelaydConnectionManager.getInstance();
a7780cc8
FC
80 }
81
a7780cc8
FC
82 @Override
83 public void stop(BundleContext context) throws Exception {
afe13e7a 84 ControlPreferences.getInstance().dispose();
6fd3c6e9 85 LttngRelaydConnectionManager.getInstance().dispose();
a7780cc8
FC
86 plugin = null;
87 super.stop(context);
88 }
89
a7780cc8
FC
90 @Override
91 protected void initializeImageRegistry(ImageRegistry reg) {
92 }
93
94 // ------------------------------------------------------------------------
95 // Operations
96 // ------------------------------------------------------------------------
97
9fa32496
BH
98 /**
99 * Gets an image object using given path within plug-in.
11252342 100 *
9fa32496 101 * @param path path to image file
11252342 102 *
9fa32496
BH
103 * @return image object
104 */
a7780cc8
FC
105 public Image getImageFromPath(String path) {
106 return getImageDescripterFromPath(path).createImage();
107 }
108
9fa32496
BH
109 /**
110 * Gets an image descriptor using given path within plug-in.
11252342
AM
111 *
112 * @param path path to image file
113 *
9fa32496
BH
114 * @return image descriptor object
115 */
a7780cc8
FC
116 public ImageDescriptor getImageDescripterFromPath(String path) {
117 return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
118 }
119
9fa32496
BH
120 /**
121 * Gets a image object from the image registry based on the given path.
11252342
AM
122 * If the image is not in the registry it will be registered.
123 *
124 * @param path to the image file
9fa32496
BH
125 * @return image object
126 */
a7780cc8
FC
127 public Image getImageFromImageRegistry(String path) {
128 Image icon = getImageRegistry().get(path);
129 if (icon == null) {
130 icon = getImageDescripterFromPath(path).createImage();
131 plugin.getImageRegistry().put(path, icon);
132 }
133 return icon;
134 }
11252342 135
115b4a01
BH
136 /**
137 * Loads the image in the plug-ins image registry (if necessary) and returns the image
138 * @param url - URL relative to the Bundle
139 * @return the image
140 */
141 public Image loadIcon(String url) {
142 String key = plugin.getBundle().getSymbolicName() + "/" + url; //$NON-NLS-1$
143 Image icon = plugin.getImageRegistry().get(key);
144 if (icon == null) {
145 URL imageURL = plugin.getBundle().getResource(url);
146 ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL);
147 icon = descriptor.createImage();
148 plugin.getImageRegistry().put(key, icon);
149 }
150 return icon;
151 }
11252342 152
9fa32496
BH
153 /**
154 * Logs a message with severity INFO in the runtime log of the plug-in.
11252342 155 *
9fa32496
BH
156 * @param message A message to log
157 */
158 public void logInfo(String message) {
159 getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
160 }
11252342 161
9fa32496
BH
162 /**
163 * Logs a message and exception with severity INFO in the runtime log of the plug-in.
11252342 164 *
9fa32496
BH
165 * @param message A message to log
166 * @param exception A exception to log
167 */
168 public void logInfo(String message, Throwable exception) {
169 getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message, exception));
170 }
171
172 /**
173 * Logs a message and exception with severity WARNING in the runtime log of the plug-in.
11252342 174 *
9fa32496
BH
175 * @param message A message to log
176 */
177 public void logWarning(String message) {
178 getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message));
179 }
11252342 180
9fa32496
BH
181 /**
182 * Logs a message and exception with severity WARNING in the runtime log of the plug-in.
11252342 183 *
9fa32496
BH
184 * @param message A message to log
185 * @param exception A exception to log
186 */
187 public void logWarning(String message, Throwable exception) {
188 getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, exception));
189 }
190
191 /**
192 * Logs a message and exception with severity ERROR in the runtime log of the plug-in.
11252342 193 *
9fa32496
BH
194 * @param message A message to log
195 */
196 public void logError(String message) {
197 getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
198 }
11252342 199
9fa32496
BH
200 /**
201 * Logs a message and exception with severity ERROR in the runtime log of the plug-in.
11252342 202 *
9fa32496
BH
203 * @param message A message to log
204 * @param exception A exception to log
205 */
206 public void logError(String message, Throwable exception) {
207 getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception));
208 }
a7780cc8
FC
209
210}
This page took 0.066629 seconds and 5 git commands to generate.