analysis.lami: Introduce LAMI integration plugins
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.lami.ui / src / org / eclipse / tracecompass / internal / analysis / lami / ui / Activator.java
1 /*******************************************************************************
2 * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
3 *
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
8 *******************************************************************************/
9
10 package org.eclipse.tracecompass.internal.analysis.lami.ui;
11
12 import org.eclipse.core.runtime.IStatus;
13 import org.eclipse.core.runtime.Status;
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.eclipse.jface.resource.ImageRegistry;
16 import org.eclipse.swt.graphics.Image;
17 import org.eclipse.ui.plugin.AbstractUIPlugin;
18 import org.osgi.framework.BundleContext;
19
20 /**
21 * The activator class controls the plug-in life cycle
22 */
23 public class Activator extends AbstractUIPlugin {
24
25 // ------------------------------------------------------------------------
26 // Attributes
27 // ------------------------------------------------------------------------
28
29 /**
30 * The plug-in ID
31 */
32 public static final String PLUGIN_ID = "org.eclipse.tracecompass.analysis.lami.ui"; //$NON-NLS-1$
33
34 /**
35 * The shared instance
36 */
37 private static Activator plugin;
38
39 // ------------------------------------------------------------------------
40 // Constructors
41 // ------------------------------------------------------------------------
42
43 /**
44 * The constructor
45 */
46 public Activator() {
47 }
48
49 // ------------------------------------------------------------------------
50 // Accessors
51 // ------------------------------------------------------------------------
52
53 /**
54 * Returns the shared instance
55 *
56 * @return the shared instance
57 */
58 public static Activator getDefault() {
59 return plugin;
60 }
61
62 // ------------------------------------------------------------------------
63 // AbstractUIPlugin
64 // ------------------------------------------------------------------------
65
66 @Override
67 public void start(BundleContext context) throws Exception {
68 super.start(context);
69 plugin = this;
70 }
71
72 @Override
73 public void stop(BundleContext context) throws Exception {
74 plugin = null;
75 super.stop(context);
76 }
77
78 @Override
79 protected void initializeImageRegistry(ImageRegistry reg) {
80 }
81
82 // ------------------------------------------------------------------------
83 // Operations
84 // ------------------------------------------------------------------------
85
86 /**
87 * Get the image object from a given path
88 *
89 * @param path
90 * The path to the image file
91 * @return The Image object
92 */
93 public Image getImageFromPath(String path) {
94 return getImageDescripterFromPath(path).createImage();
95 }
96
97 /**
98 * Get the ImageDescriptor from a given path
99 *
100 * @param path
101 * The path to the image file
102 * @return The ImageDescriptor object
103 */
104 public ImageDescriptor getImageDescripterFromPath(String path) {
105 return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
106 }
107
108 /**
109 * Get the Image from a registry
110 *
111 * @param path
112 * The path to the image registry
113 * @return The Image object
114 */
115 public Image getImageFromImageRegistry(String path) {
116 Image icon = getImageRegistry().get(path);
117 if (icon == null) {
118 icon = getImageDescripterFromPath(path).createImage();
119 plugin.getImageRegistry().put(path, icon);
120 }
121 return icon;
122 }
123
124 /**
125 * Logs a message with severity INFO in the runtime log of the plug-in.
126 *
127 * @param message A message to log
128 */
129 public void logInfo(String message) {
130 getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
131 }
132
133 /**
134 * Logs a message and exception with severity INFO in the runtime log of the plug-in.
135 *
136 * @param message A message to log
137 * @param exception A exception to log
138 */
139 public void logInfo(String message, Throwable exception) {
140 getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message, exception));
141 }
142
143 /**
144 * Logs a message and exception with severity WARNING in the runtime log of the plug-in.
145 *
146 * @param message A message to log
147 */
148 public void logWarning(String message) {
149 getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message));
150 }
151
152 /**
153 * Logs a message and exception with severity WARNING in the runtime log of the plug-in.
154 *
155 * @param message A message to log
156 * @param exception A exception to log
157 */
158 public void logWarning(String message, Throwable exception) {
159 getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, exception));
160 }
161
162 /**
163 * Logs a message and exception with severity ERROR in the runtime log of the plug-in.
164 *
165 * @param message A message to log
166 */
167 public void logError(String message) {
168 getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
169 }
170
171 /**
172 * Logs a message and exception with severity ERROR in the runtime log of the plug-in.
173 *
174 * @param message A message to log
175 * @param exception A exception to log
176 */
177 public void logError(String message, Throwable exception) {
178 getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception));
179 }
180
181 }
This page took 0.053023 seconds and 5 git commands to generate.