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
.core
.runtime
.preferences
.InstanceScope
;
19 import org
.eclipse
.jface
.preference
.IPreferenceStore
;
20 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
21 import org
.eclipse
.jface
.resource
.ImageRegistry
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceElement
;
24 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.events
.TmfEventAdapterFactory
;
25 import org
.eclipse
.swt
.graphics
.Image
;
26 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
27 import org
.eclipse
.ui
.preferences
.ScopedPreferenceStore
;
28 import org
.osgi
.framework
.BundleContext
;
31 * The activator class controls the plug-in life cycle.
33 public class Activator
extends AbstractUIPlugin
{
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
42 public static final String PLUGIN_ID
= "org.eclipse.linuxtools.tmf.ui"; //$NON-NLS-1$
46 public static final String PLUGIN_CORE_ID
= "org.eclipse.linuxtools.tmf.core"; //$NON-NLS-1$
51 private static Activator plugin
;
53 private TmfEventAdapterFactory fTmfEventAdapterFactory
;
54 private IPreferenceStore fCorePreferenceStore
;
56 // ------------------------------------------------------------------------
58 // ------------------------------------------------------------------------
66 // ------------------------------------------------------------------------
68 // ------------------------------------------------------------------------
71 * Returns the TMF UI plug-in instance.
73 * @return the TMF UI plug-in instance.
75 public static Activator
getDefault() {
79 // ------------------------------------------------------------------------
81 // ------------------------------------------------------------------------
84 public void start(BundleContext context
) throws Exception
{
88 TmfTraceElement
.init();
90 fTmfEventAdapterFactory
= new TmfEventAdapterFactory();
91 Platform
.getAdapterManager().registerAdapters(fTmfEventAdapterFactory
, ITmfEvent
.class);
95 public void stop(BundleContext context
) throws Exception
{
99 Platform
.getAdapterManager().unregisterAdapters(fTmfEventAdapterFactory
);
104 * Returns a preference store for org.eclipse.linux.tmf.core preferences
105 * @return the preference store
107 public IPreferenceStore
getCorePreferenceStore() {
108 if (fCorePreferenceStore
== null) {
109 fCorePreferenceStore
= new ScopedPreferenceStore(InstanceScope
.INSTANCE
, PLUGIN_CORE_ID
);
111 return fCorePreferenceStore
;
114 // ------------------------------------------------------------------------
116 // ------------------------------------------------------------------------
119 * Gets an image object using given path within plug-in.
124 * @return image object
126 public Image
getImageFromPath(String path
) {
127 return getImageDescripterFromPath(path
).createImage();
131 * Gets an image descriptor using given path within plug-in.
136 * @return image descriptor object
138 public ImageDescriptor
getImageDescripterFromPath(String path
) {
139 return AbstractUIPlugin
.imageDescriptorFromPlugin(PLUGIN_ID
, path
);
143 * Gets a image object from the image registry based on the given path. If
144 * the image is not in the registry it will be registered.
148 * @return image object
150 public Image
getImageFromImageRegistry(String path
) {
151 Image icon
= getImageRegistry().get(path
);
153 icon
= getImageDescripterFromPath(path
).createImage();
154 plugin
.getImageRegistry().put(path
, icon
);
160 protected void initializeImageRegistry(ImageRegistry reg
) {
161 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM
));
162 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM_IN
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM_IN
));
163 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM_OUT
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM_OUT
));
164 reg
.put(ITmfImageConstants
.IMG_UI_SEQ_DIAGRAM_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_SEQ_DIAGRAM_OBJ
));
165 reg
.put(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
));
166 reg
.put(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
));
167 reg
.put(ITmfImageConstants
.IMG_UI_CONFLICT
, getImageFromPath(ITmfImageConstants
.IMG_UI_CONFLICT
));
171 * Logs a message with severity INFO in the runtime log of the plug-in.
176 public void logInfo(String message
) {
177 getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
));
181 * Logs a message and exception with severity INFO in the runtime log of the
189 public void logInfo(String message
, Throwable exception
) {
190 getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
, exception
));
194 * Logs a message and exception with severity WARNING in the runtime log of
200 public void logWarning(String message
) {
201 getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
));
205 * Logs a message and exception with severity WARNING in the runtime log of
213 public void logWarning(String message
, Throwable exception
) {
214 getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
, exception
));
218 * Logs a message and exception with severity ERROR in the runtime log of
224 public void logError(String message
) {
225 getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
));
229 * Logs a message and exception with severity ERROR in the runtime log of
237 public void logError(String message
, Throwable exception
) {
238 getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
, exception
));