Commit | Line | Data |
---|---|---|
b0d3496e ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009 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 | ||
13 | package org.eclipse.linuxtools.tmf.ui; | |
14 | ||
73005152 BH |
15 | import org.eclipse.jface.resource.ImageDescriptor; |
16 | import org.eclipse.jface.resource.ImageRegistry; | |
17 | import org.eclipse.linuxtools.tmf.ui.TmfUiTracer; | |
abfad0aa | 18 | import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager; |
73005152 | 19 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.LoadersManager; |
abfad0aa | 20 | import org.eclipse.swt.graphics.Image; |
b0d3496e ASL |
21 | import org.eclipse.ui.plugin.AbstractUIPlugin; |
22 | import org.osgi.framework.BundleContext; | |
23 | ||
24 | /** | |
25 | * <b><u>TmfUiPlugin</u></b> | |
26 | * <p> | |
27 | * The activator class controls the plug-in life cycle | |
28 | */ | |
29 | public class TmfUiPlugin extends AbstractUIPlugin { | |
30 | ||
31 | // ======================================================================== | |
32 | // Attributes | |
33 | // ======================================================================== | |
34 | ||
35 | // The plug-in ID | |
3b38ea61 | 36 | public static final String PLUGIN_ID = "org.eclipse.linuxtools.tmf.ui"; //$NON-NLS-1$ |
b0d3496e ASL |
37 | |
38 | // The shared instance | |
39 | private static TmfUiPlugin plugin; | |
40 | ||
41 | // ======================================================================== | |
42 | // Constructors | |
43 | // ======================================================================== | |
44 | ||
45 | /** | |
46 | * The constructor | |
47 | */ | |
48 | public TmfUiPlugin() { | |
49 | } | |
50 | ||
51 | // ======================================================================== | |
52 | // Accessors | |
53 | // ======================================================================== | |
54 | ||
55 | /** | |
56 | * Returns the shared instance | |
57 | * | |
58 | * @return the shared instance | |
59 | */ | |
60 | public static TmfUiPlugin getDefault() { | |
61 | return plugin; | |
62 | } | |
63 | ||
64 | // ======================================================================== | |
65 | // Operators | |
66 | // ======================================================================== | |
67 | ||
68 | /* | |
69 | * (non-Javadoc) | |
70 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) | |
71 | */ | |
62d1696a | 72 | @Override |
b0d3496e ASL |
73 | public void start(BundleContext context) throws Exception { |
74 | super.start(context); | |
75 | plugin = this; | |
73005152 | 76 | TmfUiTracer.init(); |
abfad0aa | 77 | ParserProviderManager.init(); |
b0d3496e ASL |
78 | } |
79 | ||
abfad0aa | 80 | /* |
b0d3496e ASL |
81 | * (non-Javadoc) |
82 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) | |
83 | */ | |
62d1696a | 84 | @Override |
b0d3496e | 85 | public void stop(BundleContext context) throws Exception { |
73005152 | 86 | TmfUiTracer.stop(); |
b0d3496e ASL |
87 | plugin = null; |
88 | super.stop(context); | |
89 | } | |
90 | ||
73005152 BH |
91 | public Image getImageFromPath(String path){ |
92 | return getImageDescripterFromPath(path).createImage(); | |
93 | } | |
94 | ||
95 | public ImageDescriptor getImageDescripterFromPath(String path){ | |
96 | return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path); | |
97 | } | |
98 | ||
99 | public Image getImageFromImageRegistry(String path) { | |
100 | Image icon = getImageRegistry().get(path); | |
101 | if (icon == null) { | |
102 | icon = getImageDescripterFromPath(path).createImage(); | |
103 | plugin.getImageRegistry().put(path, icon); | |
104 | } | |
105 | return icon; | |
abfad0aa FC |
106 | } |
107 | ||
73005152 BH |
108 | /* |
109 | * (non-Javadoc) | |
110 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry) | |
111 | */ | |
112 | @Override | |
113 | protected void initializeImageRegistry(ImageRegistry reg) { | |
114 | reg.put(ITmfImageConstants.IMG_UI_ZOOM, getImageFromPath(ITmfImageConstants.IMG_UI_ZOOM)); | |
115 | reg.put(ITmfImageConstants.IMG_UI_ZOOM_IN, getImageFromPath(ITmfImageConstants.IMG_UI_ZOOM_IN)); | |
116 | reg.put(ITmfImageConstants.IMG_UI_ZOOM_OUT, getImageFromPath(ITmfImageConstants.IMG_UI_ZOOM_OUT)); | |
117 | reg.put(ITmfImageConstants.IMG_UI_SEQ_DIAGRAM_OBJ, getImageFromPath(ITmfImageConstants.IMG_UI_SEQ_DIAGRAM_OBJ)); | |
118 | reg.put(ITmfImageConstants.IMG_UI_ARROW_COLLAPSE_OBJ, getImageFromPath(ITmfImageConstants.IMG_UI_ARROW_COLLAPSE_OBJ)); | |
119 | reg.put(ITmfImageConstants.IMG_UI_ARROW_UP_OBJ, getImageFromPath(ITmfImageConstants.IMG_UI_ARROW_UP_OBJ)); | |
120 | } | |
121 | ||
122 | ||
b0d3496e | 123 | } |