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
.TmfUiRefreshHandler
;
24 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfExperimentElement
;
25 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceElement
;
26 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.events
.TmfEventAdapterFactory
;
27 import org
.eclipse
.swt
.graphics
.Image
;
28 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
29 import org
.eclipse
.ui
.preferences
.ScopedPreferenceStore
;
30 import org
.osgi
.framework
.BundleContext
;
33 * The activator class controls the plug-in life cycle.
35 public class Activator
extends AbstractUIPlugin
{
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
44 public static final String PLUGIN_ID
= "org.eclipse.linuxtools.tmf.ui"; //$NON-NLS-1$
48 public static final String PLUGIN_CORE_ID
= "org.eclipse.linuxtools.tmf.core"; //$NON-NLS-1$
53 private static Activator plugin
;
55 private TmfEventAdapterFactory fTmfEventAdapterFactory
;
56 private IPreferenceStore fCorePreferenceStore
;
58 // ------------------------------------------------------------------------
60 // ------------------------------------------------------------------------
68 // ------------------------------------------------------------------------
70 // ------------------------------------------------------------------------
73 * Returns the TMF UI plug-in instance.
75 * @return the TMF UI plug-in instance.
77 public static Activator
getDefault() {
81 // ------------------------------------------------------------------------
83 // ------------------------------------------------------------------------
86 public void start(BundleContext context
) throws Exception
{
89 TmfUiRefreshHandler
.getInstance(); // to classload/initialize it
91 TmfTraceElement
.init();
92 TmfExperimentElement
.init();
94 fTmfEventAdapterFactory
= new TmfEventAdapterFactory();
95 Platform
.getAdapterManager().registerAdapters(fTmfEventAdapterFactory
, ITmfEvent
.class);
99 public void stop(BundleContext context
) throws Exception
{
101 TmfUiRefreshHandler
.getInstance().dispose();
104 Platform
.getAdapterManager().unregisterAdapters(fTmfEventAdapterFactory
);
109 * Returns a preference store for org.eclipse.linux.tmf.core preferences
110 * @return the preference store
112 public IPreferenceStore
getCorePreferenceStore() {
113 if (fCorePreferenceStore
== null) {
114 fCorePreferenceStore
= new ScopedPreferenceStore(InstanceScope
.INSTANCE
, PLUGIN_CORE_ID
);
116 return fCorePreferenceStore
;
119 // ------------------------------------------------------------------------
121 // ------------------------------------------------------------------------
124 * Gets an image object using given path within plug-in.
129 * @return image object
131 public Image
getImageFromPath(String path
) {
132 return getImageDescripterFromPath(path
).createImage();
136 * Gets an image descriptor using given path within plug-in.
141 * @return image descriptor object
143 public ImageDescriptor
getImageDescripterFromPath(String path
) {
144 return AbstractUIPlugin
.imageDescriptorFromPlugin(PLUGIN_ID
, path
);
148 * Gets a image object from the image registry based on the given path. If
149 * the image is not in the registry it will be registered.
153 * @return image object
155 public Image
getImageFromImageRegistry(String path
) {
156 Image icon
= getImageRegistry().get(path
);
158 icon
= getImageDescripterFromPath(path
).createImage();
159 plugin
.getImageRegistry().put(path
, icon
);
165 protected void initializeImageRegistry(ImageRegistry reg
) {
166 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM
));
167 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM_IN
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM_IN
));
168 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM_OUT
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM_OUT
));
169 reg
.put(ITmfImageConstants
.IMG_UI_SEQ_DIAGRAM_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_SEQ_DIAGRAM_OBJ
));
170 reg
.put(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
));
171 reg
.put(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
));
172 reg
.put(ITmfImageConstants
.IMG_UI_CONFLICT
, getImageFromPath(ITmfImageConstants
.IMG_UI_CONFLICT
));
176 * Logs a message with severity INFO in the runtime log of the plug-in.
181 public void logInfo(String message
) {
182 getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
));
186 * Logs a message and exception with severity INFO in the runtime log of the
194 public void logInfo(String message
, Throwable exception
) {
195 getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
, exception
));
199 * Logs a message and exception with severity WARNING in the runtime log of
205 public void logWarning(String message
) {
206 getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
));
210 * Logs a message and exception with severity WARNING in the runtime log of
218 public void logWarning(String message
, Throwable exception
) {
219 getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
, exception
));
223 * Logs a message and exception with severity ERROR in the runtime log of
229 public void logError(String message
) {
230 getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
));
234 * Logs a message and exception with severity ERROR in the runtime log of
242 public void logError(String message
, Throwable exception
) {
243 getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
, exception
));