Skip to main content


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 15:33 Go to next message
excellion fdfds is currently offline excellion fdfdsFriend
Messages: 14
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 15:59 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
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 09:27 Go to previous messageGo to next message
excellion fdfds is currently offline excellion fdfdsFriend
Messages: 14
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 09: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 14:09 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
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: Tue Apr 23 10:34:04 GMT 2024

Powered by FUDForum. Page generated in 0.03006 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top