Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Customizing the Eclipse About Dialog

DZone's Guide to

Customizing the Eclipse About Dialog

· Java Zone
Free Resource

Try Okta to add social login, MFA, and OpenID Connect support to your Java app in minutes. Create a free developer account today and never build auth again.

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

From http://blog.eclipse-tips.com/

Build and launch faster with Okta’s user management API. Register today for the free forever developer edition!

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}