Sep 09 2008
Eclipse RCP tips and tricks
Recently I had to do couple of tricks Eclipse RCP applications. Basically all of the pieces of code presented below need to be placed in method initialize(IWorkbenchConfigurer configurer). You need to override this method in WorkbenchAdvisor subclass.
- Displaying icons in Navigator View
final String ICONS_PATH = "icons/full/"; final String PATH_OBJECT = ICONS_PATH + "obj16/"; Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH); declareWorkbenchImage(configurer, ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT, PATH_OBJECT + "prj_obj.gif", true); declareWorkbenchImage(configurer, ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT + "cprj_obj.gif", true);
- Enabling Decoration Context
DecorationContext dc = (DecorationContext) DecorationContext.DEFAULT_CONTEXT; dc.putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE);
- Enabling Jobs Progress Bar
IWorkbench wb = PlatformUI.getWorkbench(); wb.getProgressService();
Probably you don’t need any of those when running your plug-ins in Eclipse IDE. The tricky part is running it in a stripped to minimum RCP based applications.

In Helios SR-1 I also had to do this, the API has changed so I used this variant load the open and closed project icons into the shared image library.
String ICON_PATH = “icons/full/obj16/”;
// Find the project icon in the IDE bundle and below
Enumeration e = Platform.getBundle(“org.eclipse.ui.ide”).findEntries(ICON_PATH, “prj_obj.gif”, true);
while (e.hasMoreElements()) {
Object element = e.nextElement();
if (element instanceof URL) {
URL projectIconURL = (URL)element;
configurer.declareImage(IDE.SharedImages.IMG_OBJ_PROJECT,
ImageDescriptor.createFromURL(projectIconURL), true);
}
}
e = Platform.getBundle(“org.eclipse.ui.ide”).findEntries(ICON_PATH, “cprj_obj.gif”, true);
while (e.hasMoreElements()) {
Object element = e.nextElement();
if (element instanceof URL) {
URL closedProjectIconURL = (URL)element;
configurer.declareImage(IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED,
ImageDescriptor.createFromURL(closedProjectIconURL), true);
}
}