Load with absolute path in ImageProvider [message #1221393] |
Tue, 17 December 2013 10:33  |
Eclipse User |
|
|
|
Hi,
i can't load an picture with ImageProvider with an absolute path. This picture isn't in my bundle or workspace, and i would use as icon in palette after.
For example these paths don't work :
"/C:/folder/img.png" or "C:/folder/img.png"
I need to use this picture in AbstractCreateFeature.getCreateImageId().
So, i want to load in ImageProvider with an absolute path, or find a way to use a Image in palette without the ImageProvider.
Thanks in advance.
|
|
|
|
Re: Load with absolute path in ImageProvider [message #1226639 is a reply to message #1221882] |
Thu, 02 January 2014 04:27   |
Eclipse User |
|
|
|
I found a solution to my problem.
In org.eclipse.graphiti.ui.internal.editor.GFPaletteRoot, graphiti get image descriptor of palette elements with :
private ImageDescriptor getImageDescriptor(IPaletteCompartmentEntry compartmentEntry) {
ImageDescriptor imageDescriptor = null;
if (compartmentEntry instanceof IEclipseImageDescriptor) {
imageDescriptor = ((IEclipseImageDescriptor) compartmentEntry).getImageDescriptor();
} else {
imageDescriptor = GraphitiUi.getImageService().getImageDescriptorForId(diagramTypeProvider.getProviderId(),
compartmentEntry.getIconId());
}
return imageDescriptor;
}
So, i implements my palette element entry with IEclipseImageDescriptor :
public class MyObjectCreationEntry extends ObjectCreationToolEntry
implements IEclipseImageDescriptor {
public MyObjectCreationEntry(String label, String description,
String iconId, String largeIconId, ICreateFeature createFeature) {
super(label, description, iconId, largeIconId, createFeature);
}
@Override
public ImageDescriptor getImageDescriptor() {
return SWTResourceManager.getImagedescriptor(
Activator.class.getClassLoader(), getIconId(), false);
}
}
After, just use MyObjectCreationEntry in MyToolBehaviorProvider.getPalette().
iconId is an absolute path (C:/folder/icon.jpg) and it works!
[Updated on: Thu, 02 January 2014 04:27] by Moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.24351 seconds