Fix some findbugs
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.ui / src / org / eclipse / linuxtools / internal / lttng2 / kernel / ui / Activator.java
CommitLineData
a7780cc8
FC
1/*******************************************************************************
2 * Copyright (c) 2012 Ericsson
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 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
1ee4d327 13package org.eclipse.linuxtools.internal.lttng2.kernel.ui;
a7780cc8
FC
14
15import org.eclipse.jface.resource.ImageDescriptor;
16import org.eclipse.jface.resource.ImageRegistry;
17import org.eclipse.swt.graphics.Image;
18import org.eclipse.ui.plugin.AbstractUIPlugin;
19import org.osgi.framework.BundleContext;
20
21/**
22 * The activator class controls the plug-in life cycle
23 */
24public class Activator extends AbstractUIPlugin {
25
26 // ------------------------------------------------------------------------
27 // Attributes
28 // ------------------------------------------------------------------------
29
30 /**
31 * The plug-in ID
32 */
04835162 33 public static final String PLUGIN_ID = "org.eclipse.linuxtools.lttng2.kernel.ui"; //$NON-NLS-1$
a7780cc8
FC
34
35 /**
36 * The shared instance
37 */
38 private static Activator plugin;
39
40 // ------------------------------------------------------------------------
41 // Constructors
42 // ------------------------------------------------------------------------
43
44 /**
45 * The constructor
46 */
47 public Activator() {
48 }
49
50 // ------------------------------------------------------------------------
51 // Accessors
52 // ------------------------------------------------------------------------
53
54 /**
55 * Returns the shared instance
56 *
57 * @return the shared instance
58 */
59 public static Activator getDefault() {
60 return plugin;
61 }
62
63 // ------------------------------------------------------------------------
64 // AbstractUIPlugin
65 // ------------------------------------------------------------------------
66
67 /* (non-Javadoc)
68 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
69 */
70 @Override
71 public void start(BundleContext context) throws Exception {
72 super.start(context);
73 plugin = this;
74 }
75
76 /* (non-Javadoc)
77 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
78 */
79 @Override
80 public void stop(BundleContext context) throws Exception {
81 plugin = null;
82 super.stop(context);
83 }
84
85 /* (non-Javadoc)
86 * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry)
87 */
88 @Override
89 protected void initializeImageRegistry(ImageRegistry reg) {
90 }
91
92 // ------------------------------------------------------------------------
93 // Operations
94 // ------------------------------------------------------------------------
95
96 public Image getImageFromPath(String path) {
97 return getImageDescripterFromPath(path).createImage();
98 }
99
100 public ImageDescriptor getImageDescripterFromPath(String path) {
101 return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
102 }
103
104 public Image getImageFromImageRegistry(String path) {
105 Image icon = getImageRegistry().get(path);
106 if (icon == null) {
107 icon = getImageDescripterFromPath(path).createImage();
108 plugin.getImageRegistry().put(path, icon);
109 }
110 return icon;
111 }
112
113}
This page took 0.028986 seconds and 5 git commands to generate.