Some quick and dirty nuggets of information I got while doing plugin development in Eclipse platform. For most of them I didn’t find documentation, so I hope Google will index this for others stumbling on similar needs.
Need to create a dialog for displaying and selecting from a list of items with filtering support, similar to Open Type/Resource?
Subclass FilteredItemsSelectionDialog (since Eclipse 3.3). Override methods to define your providers and filtering policy.
Similar implementations are Open Task dialog from Mylyn (Ctrl+F12) and Open Plug-in Artifact from PDE 3.4 (Ctrl+Shift+A). You can take a look at their source code to see how they were implemented. If using Eclipse 3.4, use the cool Plugin Spy (Alt+Shift+F1) while dialog is open to discover and get linked to the class source code.
How to make an ToolItem produced by an IAction show both text and image when working with IToolBarManager?
When working with raw SWT ToolBar/ToolItem this is easily accomplished. But when you are working with JFace IToolbarManager/IAction, you will see that even if you define both text and image for an IAction using #setText(String) and #setImage(ImageDescriptor), the resulting control will show only the image. No need to curse JFace developers!
The ToolItem creation itself is delegated to an IContributionItem. When you invoke IToolBarManager#add(IAction), the action is encapsulated inside an IContributionItem implementation instance, ActionContributionItem, whose policy is: if the IAction defines only text, the ToolItem has only text; if the IAction defines an image, use only the image, regardless of text presence.
If you want to display text and image, you need to manually create an ActionContributionItem and override the default policy calling ActionContributionItem.setMode(ActionContributionItem.MODE_FORCE_TEXT).
IAction action = new MyAction(); ActionContributionItem ci = new ActionContributionItem(action); ci.setMode(ActionContributionItem.MODE_FORCE_TEXT); IToolBarManager tbm = new ToolBarManager(); tbm.add(ci);
This way, the ToolItem will display text and image, positioned according to the ToolBar style: text under image by default; text after image, if using SWT.RIGHT style.