I created directories inside my plugin project.
Than I used FileLocator to retrieve file in my part's contributor:
FileLocator.find(
FrameworkUtil.getBundle(this.getClass()),
new Path("icon/someimage.png"),
null)
Don't forget to check folder with your files in build.properties "Binary build".
Here is full example of my code, displaying image in SWT canvas (maybe helps somehow):
Canvas canvas = new Canvas(composite, SWT.NO_REDRAW_RESIZE);
canvas.setBounds(0, 0, IMG_WIDTH, IMG_HEIGHT);
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.drawImage(
ImageDescriptor
.createFromURL(
FileLocator.find(
FrameworkUtil.getBundle(this.getClass()),
new Path("icon/someimage.png"),
null)
).createImage(), 0, 0);
}
});
[Updated on: Tue, 23 October 2012 04:33]
Report message to a moderator