1
2
3
4
5
6
7
8
9
10
11 package de.jaret.util.ui;
12
13 import org.eclipse.jface.resource.ImageDescriptor;
14 import org.eclipse.swt.graphics.Image;
15 import org.eclipse.swt.graphics.ImageData;
16 import org.eclipse.swt.widgets.Display;
17
18 /***
19 * @author Peter Kliem
20 * @version $Id: ResourceImageDescriptor.java 297 2007-03-12 21:38:00Z olk $
21 */
22 public class ResourceImageDescriptor extends ImageDescriptor {
23 String _rscString;
24 Class<?> _loadingClass;
25
26 /***
27 *
28 */
29 public ResourceImageDescriptor(String rscString, Class<?> loadingClass) {
30 this._rscString = rscString;
31 _loadingClass = loadingClass;
32 }
33
34 public ResourceImageDescriptor(String rscString) {
35 this(rscString, null);
36 }
37
38
39
40
41
42
43 public ImageData getImageData() {
44 Class<?> clazz = _loadingClass != null ? _loadingClass : this.getClass();
45 Image img = new Image(Display.getCurrent(), clazz.getResourceAsStream(_rscString));
46 return img.getImageData();
47 }
48 }