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