tmf: Add Lost Events marker event source and factory
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / internal / tmf / ui / Activator.java
CommitLineData
b0d3496e 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2009, 2014 Ericsson
f8177ba2 3 *
b0d3496e
ASL
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
f8177ba2 8 *
b0d3496e 9 * Contributors:
080600d9 10 * Francois Chouinard - Initial API and implementation
b0d3496e
ASL
11 *******************************************************************************/
12
2bdf0193 13package org.eclipse.tracecompass.internal.tmf.ui;
b0d3496e 14
9fa32496 15import org.eclipse.core.runtime.IStatus;
080600d9 16import org.eclipse.core.runtime.Platform;
9fa32496 17import org.eclipse.core.runtime.Status;
c1cd9635
MAL
18import org.eclipse.core.runtime.preferences.InstanceScope;
19import org.eclipse.jface.preference.IPreferenceStore;
73005152
BH
20import org.eclipse.jface.resource.ImageDescriptor;
21import org.eclipse.jface.resource.ImageRegistry;
abfad0aa 22import org.eclipse.swt.graphics.Image;
c53cebea 23import org.eclipse.tracecompass.internal.tmf.ui.markers.LostEventsMarkerEventSourceFactory;
2bdf0193 24import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
c53cebea
PT
25import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
26import org.eclipse.tracecompass.tmf.core.trace.TmfTraceAdapterManager;
2bdf0193
AM
27import org.eclipse.tracecompass.tmf.ui.TmfUiRefreshHandler;
28import org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement;
29import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement;
30import org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventAdapterFactory;
b0d3496e 31import org.eclipse.ui.plugin.AbstractUIPlugin;
c1cd9635 32import org.eclipse.ui.preferences.ScopedPreferenceStore;
b0d3496e
ASL
33import org.osgi.framework.BundleContext;
34
35/**
12c155f5 36 * The activator class controls the plug-in life cycle.
b0d3496e 37 */
8fd82db5 38public class Activator extends AbstractUIPlugin {
b0d3496e 39
12c155f5 40 // ------------------------------------------------------------------------
b0d3496e 41 // Attributes
12c155f5 42 // ------------------------------------------------------------------------
b0d3496e 43
11252342
AM
44 /**
45 * The plug-in ID
46 */
c77a695a 47 public static final String PLUGIN_ID = "org.eclipse.tracecompass.tmf.ui"; //$NON-NLS-1$
c1cd9635
MAL
48 /**
49 * The core plug-in ID
50 */
c77a695a 51 public static final String PLUGIN_CORE_ID = "org.eclipse.tracecompass.tmf.core"; //$NON-NLS-1$
b0d3496e 52
11252342
AM
53 /**
54 * The shared instance
55 */
56 private static Activator plugin;
9fa32496 57
080600d9 58 private TmfEventAdapterFactory fTmfEventAdapterFactory;
c53cebea 59 private LostEventsMarkerEventSourceFactory fLostEventMarkerEventSourceFactory;
c1cd9635 60 private IPreferenceStore fCorePreferenceStore;
080600d9 61
12c155f5 62 // ------------------------------------------------------------------------
b0d3496e 63 // Constructors
12c155f5 64 // ------------------------------------------------------------------------
b0d3496e 65
11252342
AM
66 /**
67 * Constructor
68 */
69 public Activator() {
70 }
b0d3496e 71
12c155f5 72 // ------------------------------------------------------------------------
b0d3496e 73 // Accessors
12c155f5 74 // ------------------------------------------------------------------------
b0d3496e 75
11252342
AM
76 /**
77 * Returns the TMF UI plug-in instance.
78 *
79 * @return the TMF UI plug-in instance.
80 */
81 public static Activator getDefault() {
82 return plugin;
83 }
b0d3496e 84
12c155f5
FC
85 // ------------------------------------------------------------------------
86 // AbstractUIPlugin
87 // ------------------------------------------------------------------------
b0d3496e 88
11252342
AM
89 @Override
90 public void start(BundleContext context) throws Exception {
91 super.start(context);
92 plugin = this;
9c91c317 93 TmfUiRefreshHandler.getInstance(); // to classload/initialize it
11252342
AM
94 TmfUiTracer.init();
95 TmfTraceElement.init();
8f5221c2 96 TmfExperimentElement.init();
080600d9
MAL
97
98 fTmfEventAdapterFactory = new TmfEventAdapterFactory();
99 Platform.getAdapterManager().registerAdapters(fTmfEventAdapterFactory, ITmfEvent.class);
c53cebea
PT
100 fLostEventMarkerEventSourceFactory = new LostEventsMarkerEventSourceFactory();
101 TmfTraceAdapterManager.registerFactory(fLostEventMarkerEventSourceFactory, ITmfTrace.class);
11252342
AM
102 }
103
104 @Override
105 public void stop(BundleContext context) throws Exception {
106 TmfUiTracer.stop();
9c91c317 107 TmfUiRefreshHandler.getInstance().dispose();
11252342 108 plugin = null;
080600d9
MAL
109
110 Platform.getAdapterManager().unregisterAdapters(fTmfEventAdapterFactory);
c53cebea
PT
111 TmfTraceAdapterManager.unregisterFactory(fLostEventMarkerEventSourceFactory);
112 fLostEventMarkerEventSourceFactory.dispose();
11252342
AM
113 super.stop(context);
114 }
b0d3496e 115
c1cd9635
MAL
116 /**
117 * Returns a preference store for org.eclipse.linux.tmf.core preferences
118 * @return the preference store
119 */
120 public IPreferenceStore getCorePreferenceStore() {
121 if (fCorePreferenceStore == null) {
122 fCorePreferenceStore= new ScopedPreferenceStore(InstanceScope.INSTANCE, PLUGIN_CORE_ID);
123 }
124 return fCorePreferenceStore;
125 }
126
12c155f5
FC
127 // ------------------------------------------------------------------------
128 // Operations
129 // ------------------------------------------------------------------------
130
11252342
AM
131 /**
132 * Gets an image object using given path within plug-in.
133 *
134 * @param path
135 * path to image file
136 *
137 * @return image object
138 */
139 public Image getImageFromPath(String path) {
73005152
BH
140 return getImageDescripterFromPath(path).createImage();
141 }
f8177ba2 142
9fa32496
BH
143 /**
144 * Gets an image descriptor using given path within plug-in.
f8177ba2 145 *
11252342
AM
146 * @param path
147 * path to image file
f8177ba2 148 *
9fa32496
BH
149 * @return image descriptor object
150 */
11252342 151 public ImageDescriptor getImageDescripterFromPath(String path) {
73005152
BH
152 return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
153 }
f8177ba2 154
9fa32496 155 /**
11252342
AM
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.
f8177ba2 158 *
11252342
AM
159 * @param path
160 * to the image file
9fa32496
BH
161 * @return image object
162 */
73005152
BH
163 public Image getImageFromImageRegistry(String path) {
164 Image icon = getImageRegistry().get(path);
165 if (icon == null) {
166 icon = getImageDescripterFromPath(path).createImage();
167 plugin.getImageRegistry().put(path, icon);
168 }
169 return icon;
abfad0aa
FC
170 }
171
73005152
BH
172 @Override
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));
d04ec5a7 180 reg.put(ITmfImageConstants.IMG_UI_CONFLICT, getImageFromPath(ITmfImageConstants.IMG_UI_CONFLICT));
73005152 181 }
9fa32496
BH
182
183 /**
184 * Logs a message with severity INFO in the runtime log of the plug-in.
f8177ba2 185 *
11252342
AM
186 * @param message
187 * A message to log
9fa32496
BH
188 */
189 public void logInfo(String message) {
190 getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
191 }
f8177ba2 192
9fa32496 193 /**
11252342
AM
194 * Logs a message and exception with severity INFO in the runtime log of the
195 * plug-in.
f8177ba2 196 *
11252342
AM
197 * @param message
198 * A message to log
199 * @param exception
200 * A exception to log
9fa32496
BH
201 */
202 public void logInfo(String message, Throwable exception) {
203 getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message, exception));
204 }
205
206 /**
11252342
AM
207 * Logs a message and exception with severity WARNING in the runtime log of
208 * the plug-in.
f8177ba2 209 *
11252342
AM
210 * @param message
211 * A message to log
9fa32496
BH
212 */
213 public void logWarning(String message) {
214 getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message));
215 }
f8177ba2 216
9fa32496 217 /**
11252342
AM
218 * Logs a message and exception with severity WARNING in the runtime log of
219 * the plug-in.
f8177ba2 220 *
11252342
AM
221 * @param message
222 * A message to log
223 * @param exception
224 * A exception to log
9fa32496
BH
225 */
226 public void logWarning(String message, Throwable exception) {
227 getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, exception));
228 }
229
230 /**
11252342
AM
231 * Logs a message and exception with severity ERROR in the runtime log of
232 * the plug-in.
f8177ba2 233 *
11252342
AM
234 * @param message
235 * A message to log
9fa32496
BH
236 */
237 public void logError(String message) {
238 getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
239 }
f8177ba2 240
9fa32496 241 /**
11252342
AM
242 * Logs a message and exception with severity ERROR in the runtime log of
243 * the plug-in.
f8177ba2 244 *
11252342
AM
245 * @param message
246 * A message to log
247 * @param exception
248 * A exception to log
9fa32496
BH
249 */
250 public void logError(String message, Throwable exception) {
251 getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception));
252 }
b0d3496e 253}
This page took 0.144885 seconds and 5 git commands to generate.