1 /*******************************************************************************
2 * Copyright (c) 2009, 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
.linuxtools
.internal
.tmf
.ui
;
15 import org
.eclipse
.core
.runtime
.IStatus
;
16 import org
.eclipse
.core
.runtime
.Platform
;
17 import org
.eclipse
.core
.runtime
.Status
;
18 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
19 import org
.eclipse
.jface
.resource
.ImageRegistry
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
21 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceElement
;
22 import org
.eclipse
.linuxtools
.tmf
.ui
.properties
.TmfTimePreferences
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.events
.TmfEventAdapterFactory
;
24 import org
.eclipse
.swt
.graphics
.Image
;
25 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
26 import org
.osgi
.framework
.BundleContext
;
29 * The activator class controls the plug-in life cycle.
31 public class Activator
extends AbstractUIPlugin
{
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
40 public static final String PLUGIN_ID
= "org.eclipse.linuxtools.tmf.ui"; //$NON-NLS-1$
45 private static Activator plugin
;
47 private TmfEventAdapterFactory fTmfEventAdapterFactory
;
49 // ------------------------------------------------------------------------
51 // ------------------------------------------------------------------------
59 // ------------------------------------------------------------------------
61 // ------------------------------------------------------------------------
64 * Returns the TMF UI plug-in instance.
66 * @return the TMF UI plug-in instance.
68 public static Activator
getDefault() {
72 // ------------------------------------------------------------------------
74 // ------------------------------------------------------------------------
77 public void start(BundleContext context
) throws Exception
{
81 TmfTraceElement
.init();
82 TmfTimePreferences
.init();
84 fTmfEventAdapterFactory
= new TmfEventAdapterFactory();
85 Platform
.getAdapterManager().registerAdapters(fTmfEventAdapterFactory
, ITmfEvent
.class);
89 public void stop(BundleContext context
) throws Exception
{
93 Platform
.getAdapterManager().unregisterAdapters(fTmfEventAdapterFactory
);
97 // ------------------------------------------------------------------------
99 // ------------------------------------------------------------------------
102 * Gets an image object using given path within plug-in.
107 * @return image object
109 public Image
getImageFromPath(String path
) {
110 return getImageDescripterFromPath(path
).createImage();
114 * Gets an image descriptor using given path within plug-in.
119 * @return image descriptor object
121 public ImageDescriptor
getImageDescripterFromPath(String path
) {
122 return AbstractUIPlugin
.imageDescriptorFromPlugin(PLUGIN_ID
, path
);
126 * Gets a image object from the image registry based on the given path. If
127 * the image is not in the registry it will be registered.
131 * @return image object
133 public Image
getImageFromImageRegistry(String path
) {
134 Image icon
= getImageRegistry().get(path
);
136 icon
= getImageDescripterFromPath(path
).createImage();
137 plugin
.getImageRegistry().put(path
, icon
);
143 protected void initializeImageRegistry(ImageRegistry reg
) {
144 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM
));
145 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM_IN
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM_IN
));
146 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM_OUT
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM_OUT
));
147 reg
.put(ITmfImageConstants
.IMG_UI_SEQ_DIAGRAM_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_SEQ_DIAGRAM_OBJ
));
148 reg
.put(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
));
149 reg
.put(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
));
150 reg
.put(ITmfImageConstants
.IMG_UI_CONFLICT
, getImageFromPath(ITmfImageConstants
.IMG_UI_CONFLICT
));
154 * Logs a message with severity INFO in the runtime log of the plug-in.
159 public void logInfo(String message
) {
160 getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
));
164 * Logs a message and exception with severity INFO in the runtime log of the
172 public void logInfo(String message
, Throwable exception
) {
173 getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
, exception
));
177 * Logs a message and exception with severity WARNING in the runtime log of
183 public void logWarning(String message
) {
184 getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
));
188 * Logs a message and exception with severity WARNING in the runtime log of
196 public void logWarning(String message
, Throwable exception
) {
197 getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
, exception
));
201 * Logs a message and exception with severity ERROR in the runtime log of
207 public void logError(String message
) {
208 getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
));
212 * Logs a message and exception with severity ERROR in the runtime log of
220 public void logError(String message
, Throwable exception
) {
221 getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
, exception
));