Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Load with absolute path in ImageProvider
Load with absolute path in ImageProvider [message #1221393] Tue, 17 December 2013 10:33 Go to next message
excellion fdfds is currently offline excellion fdfds
Messages: 9
Registered: July 2012
Junior Member
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 #1221882 is a reply to message #1221393] Wed, 18 December 2013 10:59 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1574
Registered: July 2009
Location: Walldorf, Germany
Senior Member
The path must be part of the Eclipse workspace, external resources are not
resolvable.

Michael
Re: Load with absolute path in ImageProvider [message #1226639 is a reply to message #1221882] Thu, 02 January 2014 04:27 Go to previous messageGo to next message
excellion fdfds is currently offline excellion fdfds
Messages: 9
Registered: July 2012
Junior Member
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]

Report message to a moderator

Re: Load with absolute path in ImageProvider [message #1228571 is a reply to message #1226639] Tue, 07 January 2014 09:09 Go to previous message
Michael Wenz is currently offline Michael Wenz
Messages: 1574
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi,

cool!

Just make sure that you also dispose the image correctly after closing the
editor or whenever you don't need it any more.

Michael
Previous Topic:UML Class Diagram Editor based on Graphiti
Next Topic:Non-deterministic behaviour in CustomFeature
Goto Forum:
  


Current Time: Mon Jul 28 08:22:59 EDT 2014

Powered by FUDForum. Page generated in 0.01774 seconds