Eclipse Search

Loading

Feb 18, 2009

Customizing the About Dialog

In 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:
image


If you click the "Installation Details" button, you will get this Dialog:
image

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:
image
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:
image

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!
image

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:
image 

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");
    }
}
image
This has been there for a while, thought I'll add it for completeness :-)


Update [24-Feb-2009]: In the recent nightly, the Command Contribution story has been completely removed and createButtons() method have been added. Now the framework is not flexible enough, so you can't contribute to existing pages, but the code gets much simpler now. Trade offs :-)

3 comments:

  1. good tutorial. Can you confirm that adding buttons to install pages still works in the just released offical 3.5? I could not get it to work using either the command framework, nor overriding the createPageButtons method :(
    ReplyDelete
  2. Just wanted to let you and others know, I figured out my problem. The javadoc on createPageButtons() wasn't clear that you need to add the buttons you create to the page container, or you needed to simply use createButton() which does that for you. Once I did that it worked as expected :)
    ReplyDelete
  3. Is it possible to hide the default installation pages that show up (Plugins and Configuration) ?
    ReplyDelete