Fix IllegalArgumentException in Colors view
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / Activator.java
CommitLineData
b0d3496e 1/*******************************************************************************
11252342 2 * Copyright (c) 2009, 2013 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
ASL
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
d34665f9 13package org.eclipse.linuxtools.internal.tmf.ui;
b0d3496e 14
9fa32496
BH
15import org.eclipse.core.runtime.IStatus;
16import org.eclipse.core.runtime.Status;
73005152
BH
17import org.eclipse.jface.resource.ImageDescriptor;
18import org.eclipse.jface.resource.ImageRegistry;
12c155f5 19import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
f8177ba2 20import org.eclipse.linuxtools.tmf.ui.properties.TmfTimePreferences;
abfad0aa 21import org.eclipse.swt.graphics.Image;
b0d3496e
ASL
22import org.eclipse.ui.plugin.AbstractUIPlugin;
23import org.osgi.framework.BundleContext;
24
25/**
12c155f5 26 * The activator class controls the plug-in life cycle.
b0d3496e 27 */
8fd82db5 28public class Activator extends AbstractUIPlugin {
b0d3496e 29
12c155f5 30 // ------------------------------------------------------------------------
b0d3496e 31 // Attributes
12c155f5 32 // ------------------------------------------------------------------------
b0d3496e 33
11252342
AM
34 /**
35 * The plug-in ID
36 */
37 public static final String PLUGIN_ID = "org.eclipse.linuxtools.tmf.ui"; //$NON-NLS-1$
b0d3496e 38
11252342
AM
39 /**
40 * The shared instance
41 */
42 private static Activator plugin;
9fa32496 43
12c155f5 44 // ------------------------------------------------------------------------
b0d3496e 45 // Constructors
12c155f5 46 // ------------------------------------------------------------------------
b0d3496e 47
11252342
AM
48 /**
49 * Constructor
50 */
51 public Activator() {
52 }
b0d3496e 53
12c155f5 54 // ------------------------------------------------------------------------
b0d3496e 55 // Accessors
12c155f5 56 // ------------------------------------------------------------------------
b0d3496e 57
11252342
AM
58 /**
59 * Returns the TMF UI plug-in instance.
60 *
61 * @return the TMF UI plug-in instance.
62 */
63 public static Activator getDefault() {
64 return plugin;
65 }
b0d3496e 66
12c155f5
FC
67 // ------------------------------------------------------------------------
68 // AbstractUIPlugin
69 // ------------------------------------------------------------------------
b0d3496e 70
11252342
AM
71 @Override
72 public void start(BundleContext context) throws Exception {
73 super.start(context);
74 plugin = this;
75 TmfUiTracer.init();
76 TmfTraceElement.init();
77 TmfTimePreferences.init();
78 }
79
80 @Override
81 public void stop(BundleContext context) throws Exception {
82 TmfUiTracer.stop();
83 plugin = null;
84 super.stop(context);
85 }
b0d3496e 86
12c155f5
FC
87 // ------------------------------------------------------------------------
88 // Operations
89 // ------------------------------------------------------------------------
90
11252342
AM
91 /**
92 * Gets an image object using given path within plug-in.
93 *
94 * @param path
95 * path to image file
96 *
97 * @return image object
98 */
99 public Image getImageFromPath(String path) {
73005152
BH
100 return getImageDescripterFromPath(path).createImage();
101 }
f8177ba2 102
9fa32496
BH
103 /**
104 * Gets an image descriptor using given path within plug-in.
f8177ba2 105 *
11252342
AM
106 * @param path
107 * path to image file
f8177ba2 108 *
9fa32496
BH
109 * @return image descriptor object
110 */
11252342 111 public ImageDescriptor getImageDescripterFromPath(String path) {
73005152
BH
112 return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
113 }
f8177ba2 114
9fa32496 115 /**
11252342
AM
116 * Gets a image object from the image registry based on the given path. If
117 * the image is not in the registry it will be registered.
f8177ba2 118 *
11252342
AM
119 * @param path
120 * to the image file
9fa32496
BH
121 * @return image object
122 */
73005152
BH
123 public Image getImageFromImageRegistry(String path) {
124 Image icon = getImageRegistry().get(path);
125 if (icon == null) {
126 icon = getImageDescripterFromPath(path).createImage();
127 plugin.getImageRegistry().put(path, icon);
128 }
129 return icon;
abfad0aa
FC
130 }
131
73005152
BH
132 @Override
133 protected void initializeImageRegistry(ImageRegistry reg) {
134 reg.put(ITmfImageConstants.IMG_UI_ZOOM, getImageFromPath(ITmfImageConstants.IMG_UI_ZOOM));
135 reg.put(ITmfImageConstants.IMG_UI_ZOOM_IN, getImageFromPath(ITmfImageConstants.IMG_UI_ZOOM_IN));
136 reg.put(ITmfImageConstants.IMG_UI_ZOOM_OUT, getImageFromPath(ITmfImageConstants.IMG_UI_ZOOM_OUT));
137 reg.put(ITmfImageConstants.IMG_UI_SEQ_DIAGRAM_OBJ, getImageFromPath(ITmfImageConstants.IMG_UI_SEQ_DIAGRAM_OBJ));
138 reg.put(ITmfImageConstants.IMG_UI_ARROW_COLLAPSE_OBJ, getImageFromPath(ITmfImageConstants.IMG_UI_ARROW_COLLAPSE_OBJ));
139 reg.put(ITmfImageConstants.IMG_UI_ARROW_UP_OBJ, getImageFromPath(ITmfImageConstants.IMG_UI_ARROW_UP_OBJ));
d04ec5a7 140 reg.put(ITmfImageConstants.IMG_UI_CONFLICT, getImageFromPath(ITmfImageConstants.IMG_UI_CONFLICT));
73005152 141 }
9fa32496
BH
142
143 /**
144 * Logs a message with severity INFO in the runtime log of the plug-in.
f8177ba2 145 *
11252342
AM
146 * @param message
147 * A message to log
9fa32496
BH
148 */
149 public void logInfo(String message) {
150 getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
151 }
f8177ba2 152
9fa32496 153 /**
11252342
AM
154 * Logs a message and exception with severity INFO in the runtime log of the
155 * plug-in.
f8177ba2 156 *
11252342
AM
157 * @param message
158 * A message to log
159 * @param exception
160 * A exception to log
9fa32496
BH
161 */
162 public void logInfo(String message, Throwable exception) {
163 getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message, exception));
164 }
165
166 /**
11252342
AM
167 * Logs a message and exception with severity WARNING in the runtime log of
168 * the plug-in.
f8177ba2 169 *
11252342
AM
170 * @param message
171 * A message to log
9fa32496
BH
172 */
173 public void logWarning(String message) {
174 getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message));
175 }
f8177ba2 176
9fa32496 177 /**
11252342
AM
178 * Logs a message and exception with severity WARNING in the runtime log of
179 * the plug-in.
f8177ba2 180 *
11252342
AM
181 * @param message
182 * A message to log
183 * @param exception
184 * A exception to log
9fa32496
BH
185 */
186 public void logWarning(String message, Throwable exception) {
187 getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, exception));
188 }
189
190 /**
11252342
AM
191 * Logs a message and exception with severity ERROR in the runtime log of
192 * the plug-in.
f8177ba2 193 *
11252342
AM
194 * @param message
195 * A message to log
9fa32496
BH
196 */
197 public void logError(String message) {
198 getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
199 }
f8177ba2 200
9fa32496 201 /**
11252342
AM
202 * Logs a message and exception with severity ERROR in the runtime log of
203 * the plug-in.
f8177ba2 204 *
11252342
AM
205 * @param message
206 * A message to log
207 * @param exception
208 * A exception to log
9fa32496
BH
209 */
210 public void logError(String message, Throwable exception) {
211 getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception));
212 }
b0d3496e 213}
This page took 0.072019 seconds and 5 git commands to generate.