Lines 10-20
Link Here
|
10 |
******************************************************************************/ |
10 |
******************************************************************************/ |
11 |
package org.eclipse.wst.common.componentcore.ui; |
11 |
package org.eclipse.wst.common.componentcore.ui; |
12 |
|
12 |
|
|
|
13 |
import java.net.MalformedURLException; |
14 |
import java.net.URL; |
15 |
|
13 |
import org.eclipse.core.runtime.CoreException; |
16 |
import org.eclipse.core.runtime.CoreException; |
|
|
17 |
import org.eclipse.core.runtime.IPath; |
14 |
import org.eclipse.core.runtime.IStatus; |
18 |
import org.eclipse.core.runtime.IStatus; |
|
|
19 |
import org.eclipse.core.runtime.Path; |
15 |
import org.eclipse.core.runtime.Platform; |
20 |
import org.eclipse.core.runtime.Platform; |
16 |
import org.eclipse.core.runtime.Status; |
21 |
import org.eclipse.core.runtime.Status; |
|
|
22 |
import org.eclipse.jface.resource.ImageDescriptor; |
23 |
import org.eclipse.jface.resource.ImageRegistry; |
24 |
import org.eclipse.swt.graphics.Image; |
17 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
25 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
|
26 |
import org.osgi.framework.Bundle; |
18 |
import org.osgi.framework.BundleContext; |
27 |
import org.osgi.framework.BundleContext; |
19 |
|
28 |
|
20 |
/** |
29 |
/** |
Lines 24-29
Link Here
|
24 |
|
33 |
|
25 |
// The plug-in ID |
34 |
// The plug-in ID |
26 |
public static final String PLUGIN_ID = "org.eclipse.wst.common.modulecore.ui"; //$NON-NLS-1$ |
35 |
public static final String PLUGIN_ID = "org.eclipse.wst.common.modulecore.ui"; //$NON-NLS-1$ |
|
|
36 |
|
37 |
public static final String[] ICON_DIRS = new String[]{"icons/full/obj16", //$NON-NLS-1$ |
38 |
"icons/full/cview16", //$NON-NLS-1$ |
39 |
"icons/full/ctool16", //$NON-NLS-1$ |
40 |
"icons/full/clcl16", //$NON-NLS-1$ |
41 |
"icons/full/ovr16", //$NON-NLS-1$ |
42 |
"icons/full/extra", //$NON-NLS-1$ |
43 |
"icons/full/wizban", //$NON-NLS-1$ |
44 |
"icons", //$NON-NLS-1$ |
45 |
""}; //$NON-NLS-1$ |
27 |
|
46 |
|
28 |
// The shared instance |
47 |
// The shared instance |
29 |
private static ModuleCoreUIPlugin plugin; |
48 |
private static ModuleCoreUIPlugin plugin; |
Lines 64-69
Link Here
|
64 |
} |
83 |
} |
65 |
|
84 |
|
66 |
/** |
85 |
/** |
|
|
86 |
* Get a .gif from the image registry. |
87 |
*/ |
88 |
public Image getImage(String key) { |
89 |
ImageRegistry imageRegistry = getImageRegistry(); |
90 |
Image image = imageRegistry.get(key); |
91 |
if (image == null || image.isDisposed()) { |
92 |
ImageDescriptor descriptor = getImageDescriptor(key); |
93 |
if (descriptor != null) { |
94 |
image = descriptor.createImage(); |
95 |
imageRegistry.put(key, image); |
96 |
} |
97 |
} |
98 |
return image; |
99 |
} |
100 |
|
101 |
/** |
102 |
* This gets a .gif from the icons folder. |
103 |
*/ |
104 |
public ImageDescriptor getImageDescriptor(String key) { |
105 |
ImageDescriptor imageDescriptor = null; |
106 |
URL gifImageURL = getImageURL(key,getBundle()); |
107 |
if (gifImageURL != null) |
108 |
imageDescriptor = ImageDescriptor.createFromURL(gifImageURL); |
109 |
return imageDescriptor; |
110 |
} |
111 |
|
112 |
/** |
113 |
* This gets a .gif from the icons folder. |
114 |
*/ |
115 |
public URL getImageURL(String key, Bundle bundle) { |
116 |
String gif = "/" + key + ".gif"; //$NON-NLS-1$ //$NON-NLS-2$ |
117 |
IPath path = null; |
118 |
for (int i = 0; i < ICON_DIRS.length; i++) { |
119 |
path = new Path(ICON_DIRS[i]).append(gif); |
120 |
if (Platform.find(bundle,path) == null) |
121 |
continue; |
122 |
try { |
123 |
return new URL( bundle.getEntry("/"), path.toString()); //$NON-NLS-1$ |
124 |
} catch (MalformedURLException exception) { |
125 |
logError(exception); |
126 |
continue; |
127 |
} |
128 |
} |
129 |
return null; |
130 |
} |
131 |
|
132 |
/** |
67 |
* Returns the shared instance |
133 |
* Returns the shared instance |
68 |
* |
134 |
* |
69 |
* @return the shared instance |
135 |
* @return the shared instance |