Tuesday, July 24, 2012

Reusing Platform images

The eclipse platform comes with a huge amount of ready to use images. Often when you need a nice icon for a toolbar or menu there is already one available within some other plug-in. Therefore plug-in programmers often copy over these icons to their own plug-in to reuse them. When you can be sure that the base plug-in will be available on your target installation you can use platform scheme URIs (see related post by Marcelo Paternostro) to reference such resources.

Still the hard part is to locate those images in other plug-ins. Therefore I wrote a plug-in, that allows you to search for such images.

Update:

This plugin is now part of Eclipse PDE and is maintained by the PDE team.

A screenshot is better than a 1000 words, so see for yourself:


Just select a source to browse, locate your desired image and click on it to update the Image Information.

Install it from the reopsitory: http://codeandme.googlecode.com/svn/trunk/at.pontesegger.updatesite/p2/

The view can be activated with Window -> Show View -> Other... and is located under Plug-in Development.

Be aware that some images you may find might be released under a restrictive license that forbids reuse.

Update 2012-07-29

* Fixed issue with memory errors when parsing too much images
* partially fixed support for e4 -> still you cannot browse the target platform there
* raised Bug 386197 to add this tool to PDE

7 comments:

  1. Awesome tool! I generally use iconlet.com a lot too when looking for Eclipse and other related icons.

    ReplyDelete
  2. Hi Christian,

    Trying in Eclipse 4.2 on linux the combo contains no choices. The layout is odd as well.

    Would you be interested in contributing it to Eclipse PDE? Many plug-in developers would find it useful. As it isn't working for me, I don't know what source options you have, but if we can set the target platform and the workspace as options that would be great.

    ReplyDelete
    Replies
    1. I developed it on/for eclipse 3.7. Didn't test it on juno yet. So it seems I found a way around the compatibility layer?
      I'll port it to e4 soon and raise a bug report once it's done

      Delete
  3. Hi Christian,

    this tool looks really helpful. It doesn't work with Eclipse 3.8 (Juno) though. Seems like it uses internals that have changed in 3.8.

    java.lang.NoSuchMethodError: org.eclipse.pde.internal.core.target.TargetPlatformService.getDefault()Lorg/eclipse/pde/internal/core/target/provisional/ITargetPlatformService;
    at at.pontesegger.imagebrowser.repositories.TargetPlatformRepository.toString(TargetPlatformRepository.java:54)
    at org.eclipse.jface.viewers.LabelProvider.getText(LabelProvider.java:54)
    at org.eclipse.jface.viewers.AbstractListViewer.getLabelProviderText(AbstractListViewer.java:187)
    at org.eclipse.jface.viewers.AbstractListViewer.inputChanged(AbstractListViewer.java:339)
    at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:280)
    at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1690)
    at at.pontesegger.imagebrowser.BrowserView.createPartControl(BrowserView.java:413)
    at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:386)
    at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:240)
    at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
    ...

    ReplyDelete
    Replies
    1. You are right, I'm partially using internal API. I got 3 different source providers: one for the local eclipse installation dir, one for the workspace and a third for the target platform. Couldn't find an official way to retrieve the current target definition, so I used internal API for that. Might not be the case for Juno anyway.

      Delete
  4. Excellent Idea to create a tool like this. I hope people should be able to find it from marketplace as well.

    ReplyDelete
  5. Cool tool. Looking forward to the Eclipse 3.8 / 4.2 port.

    ReplyDelete