Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » ImageProvider using provided images from third-party plugins
ImageProvider using provided images from third-party plugins [message #699037] Wed, 20 July 2011 13:24 Go to next message
chris
Messages: 3
Registered: July 2011
Junior Member
Even though I guess this issue is similar to "Image provider supporting images from different plugins" (sorry, can't post the link because I have posted <5 messages) my problem is somewhat different, I hope:
Currently we have an extensible graphical editor with third-party plugins using an extension point of our plugin. The plugins provide among other things images via a resource attribute to the extension point. Thus, I get the path in the plugin's bundle when loading the attribute.
Is there a way to add the images from the third-party plugins to our Graphiti ImageProvider without having to introduce additional dependencies (i.e. Graphiti) for the third-party developers? (which is my understanding of the specified thread above --> the other plugins must have their own image provider(?))

thanks in advance
Re: ImageProvider using provided images from third-party plugins [message #699289 is a reply to message #699037] Thu, 21 July 2011 05:26 Go to previous messageGo to next message
Dobrou Mising name is currently offline Dobrou Mising name
Messages: 16
Registered: December 2010
Junior Member
I solved exactly same problem in my project.
Don't know if it's exactly how it should be done, but this code works for me.


/* Code that reads icon paths from extensions and register icons for use in graphiti */
final IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor( ID_TEMPLATE_EXTENSION_POINT );                      
for (final IConfigurationElement extension : extensions) {   
   String contributorBundleName = extension.getContributor().getName();
   String templateIconPath = extension.getAttribute( ID_TEMPLATE_ICON );
templateIconPath = "platform:/plugin/" + contributorBundleName +"/"+ templateIconPath;
   addImageFilePath( templateIconPath, templateIconPath );    
    
   String iconID =  templateIconPath;      
    /* ... */ 
}



If you want to process extensions outside of method suggested to register images - AbstractImageProvider.addAvailableImages().
You can use this solution:
/* This is standard, registered graphiti image provider */
public class SworkflowImageProvider extends AbstractImageProvider {    
	/* This method publishes needed protected method 'addImageFilePath' */
	public void addImageFilePathLazy(String imageId, String imageFilePath){
	    /** Check if its not already registered */
	    if(getImageFilePath( imageId ) == null){
	        addImageFilePath( imageId, imageFilePath );
	    }
	}	
}



Re: ImageProvider using provided images from third-party plugins [message #699386 is a reply to message #699289] Thu, 21 July 2011 09:28 Go to previous message
chris
Messages: 3
Registered: July 2011
Junior Member
Thank you, Dobrou. It was easier than I expected.
Previous Topic:Cannot create connections between nodes
Next Topic:Calculate minimal width of text in shape
Goto Forum:
  


Current Time: Thu Aug 21 12:02:49 EDT 2014

Powered by FUDForum. Page generated in 0.01608 seconds