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
.TmfExperimentElement
;
24 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceElement
;
25 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.events
.TmfEventAdapterFactory
;
26 import org
.eclipse
.swt
.graphics
.Image
;
27 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
28 import org
.eclipse
.ui
.preferences
.ScopedPreferenceStore
;
29 import org
.osgi
.framework
.BundleContext
;
32 * The activator class controls the plug-in life cycle.
34 public class Activator
extends AbstractUIPlugin
{
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
43 public static final String PLUGIN_ID
= "org.eclipse.linuxtools.tmf.ui"; //$NON-NLS-1$
47 public static final String PLUGIN_CORE_ID
= "org.eclipse.linuxtools.tmf.core"; //$NON-NLS-1$
52 private static Activator plugin
;
54 private TmfEventAdapterFactory fTmfEventAdapterFactory
;
55 private IPreferenceStore fCorePreferenceStore
;
57 // ------------------------------------------------------------------------
59 // ------------------------------------------------------------------------
67 // ------------------------------------------------------------------------
69 // ------------------------------------------------------------------------
72 * Returns the TMF UI plug-in instance.
74 * @return the TMF UI plug-in instance.
76 public static Activator
getDefault() {
80 // ------------------------------------------------------------------------
82 // ------------------------------------------------------------------------
85 public void start(BundleContext context
) throws Exception
{
89 TmfTraceElement
.init();
90 TmfExperimentElement
.init();
92 fTmfEventAdapterFactory
= new TmfEventAdapterFactory();
93 Platform
.getAdapterManager().registerAdapters(fTmfEventAdapterFactory
, ITmfEvent
.class);
97 public void stop(BundleContext context
) throws Exception
{
101 Platform
.getAdapterManager().unregisterAdapters(fTmfEventAdapterFactory
);
106 * Returns a preference store for org.eclipse.linux.tmf.core preferences
107 * @return the preference store
109 public IPreferenceStore
getCorePreferenceStore() {
110 if (fCorePreferenceStore
== null) {
111 fCorePreferenceStore
= new ScopedPreferenceStore(InstanceScope
.INSTANCE
, PLUGIN_CORE_ID
);
113 return fCorePreferenceStore
;
116 // ------------------------------------------------------------------------
118 // ------------------------------------------------------------------------
121 * Gets an image object using given path within plug-in.
126 * @return image object
128 public Image
getImageFromPath(String path
) {
129 return getImageDescripterFromPath(path
).createImage();
133 * Gets an image descriptor using given path within plug-in.
138 * @return image descriptor object
140 public ImageDescriptor
getImageDescripterFromPath(String path
) {
141 return AbstractUIPlugin
.imageDescriptorFromPlugin(PLUGIN_ID
, path
);
145 * Gets a image object from the image registry based on the given path. If
146 * the image is not in the registry it will be registered.
150 * @return image object
152 public Image
getImageFromImageRegistry(String path
) {
153 Image icon
= getImageRegistry().get(path
);
155 icon
= getImageDescripterFromPath(path
).createImage();
156 plugin
.getImageRegistry().put(path
, icon
);
162 protected void initializeImageRegistry(ImageRegistry reg
) {
163 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM
));
164 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM_IN
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM_IN
));
165 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM_OUT
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM_OUT
));
166 reg
.put(ITmfImageConstants
.IMG_UI_SEQ_DIAGRAM_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_SEQ_DIAGRAM_OBJ
));
167 reg
.put(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
));
168 reg
.put(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
));
169 reg
.put(ITmfImageConstants
.IMG_UI_CONFLICT
, getImageFromPath(ITmfImageConstants
.IMG_UI_CONFLICT
));
173 * Logs a message with severity INFO in the runtime log of the plug-in.
178 public void logInfo(String message
) {
179 getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
));
183 * Logs a message and exception with severity INFO in the runtime log of the
191 public void logInfo(String message
, Throwable exception
) {
192 getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
, exception
));
196 * Logs a message and exception with severity WARNING in the runtime log of
202 public void logWarning(String message
) {
203 getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
));
207 * Logs a message and exception with severity WARNING in the runtime log of
215 public void logWarning(String message
, Throwable exception
) {
216 getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
, exception
));
220 * Logs a message and exception with severity ERROR in the runtime log of
226 public void logError(String message
) {
227 getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
));
231 * Logs a message and exception with severity ERROR in the runtime log of
239 public void logError(String message
, Throwable exception
) {
240 getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
, exception
));