Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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

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
Eclipse UserFriend
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: Wed Jul 23 11:16:20 EDT 2025

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

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

Back to the top