1 /*******************************************************************************
2 * Copyright (c) 2009, 2012 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
.linuxtools
.internal
.tmf
.ui
;
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
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceElement
;
20 import org
.eclipse
.swt
.graphics
.Image
;
21 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
22 import org
.osgi
.framework
.BundleContext
;
25 * The activator class controls the plug-in life cycle.
27 public class TmfUiPlugin
extends AbstractUIPlugin
{
29 // ------------------------------------------------------------------------
31 // ------------------------------------------------------------------------
36 public static final String PLUGIN_ID
= "org.eclipse.linuxtools.tmf.ui"; //$NON-NLS-1$
41 private static TmfUiPlugin plugin
;
43 // ------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
50 public TmfUiPlugin() {
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
58 * Returns the TMF UI plug-in instance.
60 * @return the TMF UI plug-in instance.
62 public static TmfUiPlugin
getDefault() {
66 // ------------------------------------------------------------------------
68 // ------------------------------------------------------------------------
72 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
75 public void start(BundleContext context
) throws Exception
{
79 TmfTraceElement
.init();
84 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
87 public void stop(BundleContext context
) throws Exception
{
93 // ------------------------------------------------------------------------
95 // ------------------------------------------------------------------------
98 * Gets an image object using given path within plug-in.
100 * @param path path to image file
102 * @return image object
104 public Image
getImageFromPath(String path
){
105 return getImageDescripterFromPath(path
).createImage();
109 * Gets an image descriptor using given path within plug-in.
111 * @param path path to image file
113 * @return image descriptor object
115 public ImageDescriptor
getImageDescripterFromPath(String path
){
116 return AbstractUIPlugin
.imageDescriptorFromPlugin(PLUGIN_ID
, path
);
120 * Gets a image object from the image registry based on the given path.
121 * If the image is not in the registry it will be registered.
123 * @param path to the image file
124 * @return image object
126 public Image
getImageFromImageRegistry(String path
) {
127 Image icon
= getImageRegistry().get(path
);
129 icon
= getImageDescripterFromPath(path
).createImage();
130 plugin
.getImageRegistry().put(path
, icon
);
137 * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry)
140 protected void initializeImageRegistry(ImageRegistry reg
) {
141 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM
));
142 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM_IN
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM_IN
));
143 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM_OUT
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM_OUT
));
144 reg
.put(ITmfImageConstants
.IMG_UI_SEQ_DIAGRAM_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_SEQ_DIAGRAM_OBJ
));
145 reg
.put(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
));
146 reg
.put(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
));
150 * Logs a message with severity INFO in the runtime log of the plug-in.
152 * @param message A message to log
154 public void logInfo(String message
) {
155 getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
));
159 * Logs a message and exception with severity INFO in the runtime log of the plug-in.
161 * @param message A message to log
162 * @param exception A exception to log
164 public void logInfo(String message
, Throwable exception
) {
165 getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
, exception
));
169 * Logs a message and exception with severity WARNING in the runtime log of the plug-in.
171 * @param message A message to log
173 public void logWarning(String message
) {
174 getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
));
178 * Logs a message and exception with severity WARNING in the runtime log of the plug-in.
180 * @param message A message to log
181 * @param exception A exception to log
183 public void logWarning(String message
, Throwable exception
) {
184 getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
, exception
));
188 * Logs a message and exception with severity ERROR in the runtime log of the plug-in.
190 * @param message A message to log
192 public void logError(String message
) {
193 getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
));
197 * Logs a message and exception with severity ERROR in the runtime log of the plug-in.
199 * @param message A message to log
200 * @param exception A exception to log
202 public void logError(String message
, Throwable exception
) {
203 getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
, exception
));