1 /*******************************************************************************
2 * Copyright (c) 2009, 2014 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
.tracecompass
.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
.swt
.graphics
.Image
;
23 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.markers
.LostEventsMarkerEventSourceFactory
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceAdapterManager
;
27 import org
.eclipse
.tracecompass
.tmf
.ui
.TmfUiRefreshHandler
;
28 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfExperimentElement
;
29 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfTraceElement
;
30 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.events
.TmfEventAdapterFactory
;
31 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
32 import org
.eclipse
.ui
.preferences
.ScopedPreferenceStore
;
33 import org
.osgi
.framework
.BundleContext
;
36 * The activator class controls the plug-in life cycle.
38 public class Activator
extends AbstractUIPlugin
{
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
47 public static final String PLUGIN_ID
= "org.eclipse.tracecompass.tmf.ui"; //$NON-NLS-1$
51 public static final String PLUGIN_CORE_ID
= "org.eclipse.tracecompass.tmf.core"; //$NON-NLS-1$
56 private static Activator plugin
;
58 private TmfEventAdapterFactory fTmfEventAdapterFactory
;
59 private LostEventsMarkerEventSourceFactory fLostEventMarkerEventSourceFactory
;
60 private IPreferenceStore fCorePreferenceStore
;
62 // ------------------------------------------------------------------------
64 // ------------------------------------------------------------------------
72 // ------------------------------------------------------------------------
74 // ------------------------------------------------------------------------
77 * Returns the TMF UI plug-in instance.
79 * @return the TMF UI plug-in instance.
81 public static Activator
getDefault() {
85 // ------------------------------------------------------------------------
87 // ------------------------------------------------------------------------
90 public void start(BundleContext context
) throws Exception
{
93 TmfUiRefreshHandler
.getInstance(); // to classload/initialize it
95 TmfTraceElement
.init();
96 TmfExperimentElement
.init();
98 fTmfEventAdapterFactory
= new TmfEventAdapterFactory();
99 Platform
.getAdapterManager().registerAdapters(fTmfEventAdapterFactory
, ITmfEvent
.class);
100 fLostEventMarkerEventSourceFactory
= new LostEventsMarkerEventSourceFactory();
101 TmfTraceAdapterManager
.registerFactory(fLostEventMarkerEventSourceFactory
, ITmfTrace
.class);
105 public void stop(BundleContext context
) throws Exception
{
107 TmfUiRefreshHandler
.getInstance().dispose();
110 Platform
.getAdapterManager().unregisterAdapters(fTmfEventAdapterFactory
);
111 TmfTraceAdapterManager
.unregisterFactory(fLostEventMarkerEventSourceFactory
);
112 fLostEventMarkerEventSourceFactory
.dispose();
117 * Returns a preference store for org.eclipse.linux.tmf.core preferences
118 * @return the preference store
120 public IPreferenceStore
getCorePreferenceStore() {
121 if (fCorePreferenceStore
== null) {
122 fCorePreferenceStore
= new ScopedPreferenceStore(InstanceScope
.INSTANCE
, PLUGIN_CORE_ID
);
124 return fCorePreferenceStore
;
127 // ------------------------------------------------------------------------
129 // ------------------------------------------------------------------------
132 * Gets an image object using given path within plug-in.
137 * @return image object
139 public Image
getImageFromPath(String path
) {
140 return getImageDescripterFromPath(path
).createImage();
144 * Gets an image descriptor using given path within plug-in.
149 * @return image descriptor object
151 public ImageDescriptor
getImageDescripterFromPath(String path
) {
152 return AbstractUIPlugin
.imageDescriptorFromPlugin(PLUGIN_ID
, path
);
156 * Gets a image object from the image registry based on the given path. If
157 * the image is not in the registry it will be registered.
161 * @return image object
163 public Image
getImageFromImageRegistry(String path
) {
164 Image icon
= getImageRegistry().get(path
);
166 icon
= getImageDescripterFromPath(path
).createImage();
167 plugin
.getImageRegistry().put(path
, icon
);
173 protected void initializeImageRegistry(ImageRegistry reg
) {
174 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM
));
175 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM_IN
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM_IN
));
176 reg
.put(ITmfImageConstants
.IMG_UI_ZOOM_OUT
, getImageFromPath(ITmfImageConstants
.IMG_UI_ZOOM_OUT
));
177 reg
.put(ITmfImageConstants
.IMG_UI_SEQ_DIAGRAM_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_SEQ_DIAGRAM_OBJ
));
178 reg
.put(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
));
179 reg
.put(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
, getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
));
180 reg
.put(ITmfImageConstants
.IMG_UI_CONFLICT
, getImageFromPath(ITmfImageConstants
.IMG_UI_CONFLICT
));
184 * Logs a message with severity INFO in the runtime log of the plug-in.
189 public void logInfo(String message
) {
190 getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
));
194 * Logs a message and exception with severity INFO in the runtime log of the
202 public void logInfo(String message
, Throwable exception
) {
203 getLog().log(new Status(IStatus
.INFO
, PLUGIN_ID
, message
, exception
));
207 * Logs a message and exception with severity WARNING in the runtime log of
213 public void logWarning(String message
) {
214 getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
));
218 * Logs a message and exception with severity WARNING in the runtime log of
226 public void logWarning(String message
, Throwable exception
) {
227 getLog().log(new Status(IStatus
.WARNING
, PLUGIN_ID
, message
, exception
));
231 * Logs a message and exception with severity ERROR in the runtime log of
237 public void logError(String message
) {
238 getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
));
242 * Logs a message and exception with severity ERROR in the runtime log of
250 public void logError(String message
, Throwable exception
) {
251 getLog().log(new Status(IStatus
.ERROR
, PLUGIN_ID
, message
, exception
));