Customizing the Eclipse About Dialog
Join the DZone community and get the full member experience.
Join For FreeIn the About Dialog, the image, text etc, can be customized by the extension point org.eclipse.core.runtime.products (or PDE's product editor). But with few changes into the nightly build of 3.5, the About Dialog sports a new look and is much more customizable. In this tip, lets see how to extend it.
The new Eclipse About Dialog (for the RCP mail sample) looks like this:
If you click the "Installation Details" button, you will get this Dialog:
How about adding our own tab here? You need to extend the new org.eclipse.ui.installationPages extension point.
<extension point="org.eclipse.ui.installationPages"> <page class="com.eclipse_tips.rcp.mail.MailInstallationpage" id="com.eclipse-tips.rcp.mail.Installationpage" name="RCP Mail"> </page> </extension>
The class should extend org.eclipse.ui.about.InstallationPage, which has the createControl() method. Create all the UI you want there:
If you see the Plug-ins tab or Configuration tab, there are few buttons. How to add a new button in our RCP Mail Tab? I was looking for a createButtons() method to override, but its not that way. The buttons are contributed thru Command Framework:
<extension point="org.eclipse.ui.commands"> <command defaultHandler="com.eclipse_tips.rcp.mail.ShowRegistrationHandler" id="com.eclipse-tips.rcp.mail.showRegistrationCommand" name="Registration Details"> </command> </extension> <extension point="org.eclipse.ui.menus"> <menuContribution locationURI="toolbar:org.eclipse.ui.installationDialog.buttonbar"> <command commandId="com.eclipse-tips.rcp.mail.showRegistrationCommand" style="push"> <visibleWhen> <with variable="org.eclipse.ui.installationPage.activePage.id"> <equals value="com.eclipse-tips.rcp.mail.InstallationPage"> </equals> </with> </visibleWhen> </command> </menuContribution> </extension>
If you don't understand the above extension, you need to refer to my earlier tips on Command Framework :-P
Result:
Why can't it be as simple as extending a createButtons() method? Well, flexibility for other plugins to extend. Say if we want to add a button to the existing Plug-ins tab, all we have to do is add a menuContribution:
<extension point="org.eclipse.ui.menus"> <menuContribution locationURI="toolbar:org.eclipse.ui.installationDialog.buttonbar"> <command commandId="com.eclipse-tips.rcp.mail.showRegistrationCommand" style="push"> <visibleWhen> <with variable="org.eclipse.ui.installationPage.activePage.id"> <equals value="30.PluginPage"> </equals> </with> </visibleWhen> </command> </menuContribution> </extension>
See. Extending it is now simple!
The id of the Plug-ins tab is "30.PluginPage" and the id of the Configuration tab is "31.SystemPage". Did you notice something odd there? The ids are prefixed with some numbers. These numbers decide the order of the tabs appearing in the dialog. This is not a documented behaviour, so don't expect to work the same in future versions, but for now it works. So if we prefix our ids with a lower number like "10.com.eclipse-tips.rcp.mail.InstallationPage", our tab will be shown first:Â
The Configuration lists out all the configuration details, so if you want to add your own configuration to it, you need to extend org.eclipse.ui.systemSummarySections:
<extension point="org.eclipse.ui.systemSummarySections"> <section class="com.eclipse_tips.rcp.mail.MailSummarySection" id="com.eclipse_tips.rcp.mail.mailSummarySection" sectionTitle="RCP Mail Details"> </section> </extension>
The class should implement org.eclipse.ui.about.ISystemSummarySection, which has a single method write(PrintWriter writer). You can add all the configuration details to the writer:
public class MailSummarySection implements ISystemSummarySection { @Override public void write(PrintWriter writer) { writer.println("User Name=Prakash G.R."); writer.println("Mail Server=GMail"); writer.println("Protocol=POP3"); } }
This has been there for a while, thought I'll add it for completeness :-)
Opinions expressed by DZone contributors are their own.
Comments