Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » adding icons to the palette
adding icons to the palette [message #1699423] Wed, 24 June 2015 09:15 Go to next message
Li li is currently offline Li liFriend
Messages: 3
Registered: May 2015
Junior Member

I want to add a ObjectCreationEntry to a paletteCompartmentEntry, we use a "getCreateimageId()" as parameter. I guess it represents the small icon in the palette to show a small picture of what we are going to add. However, i can't find where we define this imageid (in the createFeature ?), i already searched, but i only find a setimageId for a contextButton, not for a CreateFeature.

So, my question is, how can i add this small picture in my palette ?Could you give me a simple sample?

Thank you for your time
Re: adding icons to the palette [message #1699520 is a reply to message #1699423] Wed, 24 June 2015 18:29 Go to previous message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 85
Registered: April 2012
I am telling in my getPaletteCompartmentEntries what image to use also via CreateFeature.
	ObjectCreationToolEntry octe = new ObjectCreationToolEntry(cf.getCreateName(), cf.getCreateDescription(),
                                             cf.getCreateImageId(), cf.getCreateLargeImageId(), cf);

However they are defined somewhere else. What I am doing:

1. plugin.xml:
   <extension point="org.eclipse.graphiti.ui.diagramTypeProviders">
            description="This is the editor for the System in Cloud Task"
            name="System in Cloud Modeler">
         <diagramType   id="com.systemincloud.modeler.gui.SystemInCloudDiagramType" />
         <imageProvider id="com.systemincloud.modeler.gui.SystemInCloudImageProvider" />
   <extension point="org.eclipse.graphiti.ui.imageProviders">

2. ImageProvider:
public class ImageProvider extends AbstractImageProvider {

	protected void addAvailableImages() {
		// add image path from general features
		Map<String, String> imgs = Images.getImageKeyPath();
		for (Entry<String, String> img : imgs.entrySet()) {
			addImageFilePath(img.getKey(), img.getValue());
		// add image path from tasks
		imgs = TaskProvider.INSTANCE.getImageKeyPath();
		for (Entry<String, String> img : imgs.entrySet()) {
			addImageFilePath(img.getKey(), img.getValue());
		// add image path from installed extensions
		imgs = ModelerGuiExtensionManager.INSTANCE.getImageKeyPath();
		for (Entry<String, String> img : imgs.entrySet()) {
			addImageFilePath(img.getKey(), img.getValue());


3. Contributing images
public class Images {

	public enum K {
		public String path;
		K(String path) { this.path =  path; }
	static Map<String, String> images = new HashMap<String, String>() {	private static final long serialVersionUID = 1L; {
		for (final K v : K.values())
			put(, FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(v.path), null).toString());
	public static Map<String, String> getImageKeyPath() { return images; }

4. Contribute to Pallete:
public class CreateFeature extends CreateTaskFeature {

	public CreateFeature(IFeatureProvider fp, String bundleName, Version version) { super(fp, Inspect.class, bundleName, version); }

	@Override public String getPaletteKey()       { return SicPlugin.GUI_ID.s(); }
	@Override public String getTestPaletteKey()   { return SicPlugin.GUI_ID.s(); }
	@Override public String getTaskCategory()     { return; }
	@Override public String getTestTaskCategory() { return; }
	@Override public Object[] create(ICreateContext context) {
		Inspect inspect = InspectFactory.eINSTANCE.createInspect();
		return super.create(context, inspect); 
	@Override protected Class<? extends PortsDescr> getPortsDescription()          { return Port.class; }
	@Override public    String                      getCreateImageId()             { return; }

So in my case I can contribute to ImageProvider even from several plugins via for example RegisteredServices.
Previous Topic:how to import/export model instances
Next Topic:Animations in Graphiti
Goto Forum:

Current Time: Mon Jan 22 14:40:27 GMT 2018

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

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