1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
;
17 import org
.eclipse
.core
.runtime
.IStatus
;
18 import org
.eclipse
.core
.runtime
.Status
;
19 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
20 import org
.eclipse
.jface
.resource
.ImageRegistry
;
21 import org
.eclipse
.swt
.graphics
.Image
;
22 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.relayd
.LttngRelaydConnectionManager
;
23 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.preferences
.ControlPreferences
;
24 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
25 import org
.osgi
.framework
.BundleContext
;
28 * The activator class controls the plug-in life cycle
30 public class Activator
extends AbstractUIPlugin
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
39 public static final String PLUGIN_ID
= "org.eclipse.linuxtools.lttng2.control.ui"; //$NON-NLS-1$
44 private static Activator plugin
;
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
56 // ------------------------------------------------------------------------
58 // ------------------------------------------------------------------------
61 * Returns the shared instance
63 * @return the shared instance
65 public static Activator
getDefault() {
69 // ------------------------------------------------------------------------
71 // ------------------------------------------------------------------------
74 public void start(BundleContext context
) throws Exception
{
77 ControlPreferences
.getInstance().init(getPreferenceStore());
78 // This registers the connection manager with the signal manager
79 LttngRelaydConnectionManager
.getInstance();
83 public void stop(BundleContext context
) throws Exception
{
84 ControlPreferences
.getInstance().dispose();
85 LttngRelaydConnectionManager
.getInstance().dispose();
91 protected void initializeImageRegistry(ImageRegistry reg
) {
94 // ------------------------------------------------------------------------
96 // ------------------------------------------------------------------------
99 * Gets an image object using given path within plug-in.
101 * @param path path to image file
103 * @return image object
105 public Image
getImageFromPath(String path
) {
106 return getImageDescripterFromPath(path
).createImage();
110 * Gets an image descriptor using given path within plug-in.
112 * @param path path to image file
114 * @return image descriptor object
116 public ImageDescriptor
getImageDescripterFromPath(String path
) {
117 return AbstractUIPlugin
.imageDescriptorFromPlugin(PLUGIN_ID
, path
);
121 * Gets a image object from the image registry based on the given path.
122 * If the image is not in the registry it will be registered.
124 * @param path to the image file
125 * @return image object
127 public Image
getImageFromImageRegistry(String path
) {
128 Image icon
= getImageRegistry().get(path
);
130 icon
= getImageDescripterFromPath(path
).createImage();
131 plugin
.getImageRegistry().put(path
, icon
);
137 * Loads the image in the plug-ins image registry (if necessary) and returns the image
138 * @param url - URL relative to the Bundle
141 public Image
loadIcon(String url
) {
142 String key
= plugin
.getBundle().getSymbolicName() + "/" + url
; //$NON-NLS-1$
143 Image icon
= plugin
.getImageRegistry().get(key
);
145 URL imageURL
= plugin
.getBundle().getResource(url
);
146 ImageDescriptor descriptor
= ImageDescriptor
.createFromURL(imageURL
);
147 icon
= descriptor
.createImage();
148 plugin
.getImageRegistry().put(key
, icon
);
154 * Logs a message with severity INFO in the runtime log of the plug-in.
156 * @param message A message to log
158 public void logInfo(String message
) {
159 getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
));
163 * Logs a message and exception with severity INFO in the runtime log of the plug-in.
165 * @param message A message to log
166 * @param exception A exception to log
168 public void logInfo(String message
, Throwable exception
) {
169 getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
, exception
));
173 * Logs a message and exception with severity WARNING in the runtime log of the plug-in.
175 * @param message A message to log
177 public void logWarning(String message
) {
178 getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
));
182 * Logs a message and exception with severity WARNING in the runtime log of the plug-in.
184 * @param message A message to log
185 * @param exception A exception to log
187 public void logWarning(String message
, Throwable exception
) {
188 getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
, exception
));
192 * Logs a message and exception with severity ERROR in the runtime log of the plug-in.
194 * @param message A message to log
196 public void logError(String message
) {
197 getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
));
201 * Logs a message and exception with severity ERROR in the runtime log of the plug-in.
203 * @param message A message to log
204 * @param exception A exception to log
206 public void logError(String message
, Throwable exception
) {
207 getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
, exception
));