How to customize text and buttons for the About entry under the Help Menu in a Eclipse 3.8.1 RCP application

89 views Asked by At

I am trying to customize the Help->About menu entry on Eclipse 3.8.1. I tried two 3.x friendly methods since Eclipse 4.0 works differently.

---> I tried extends the AboutAction itself (org.eclipse.ui.internal.dialogs.AboutDialog) so I can add one line to the DialogArea Text and add a scrollable Dialog Gui when the License button is clicked.But all the methods are protected in the API I see it says user can use but not override (same with the Dialog class)

---> I tried extending the default AbstractHandler and in the execute method I am creating a Dialog object where I basically want to add all the things I need one by one. Only issue with that is that I can not work on the Dialog object in the execute method because it remains a null reference until the end of the execute method so I am not able to add things to it without the nullPointerException bugging me.

---> I also tried adding <property> to the plugin.xml itself. This seems to be a 4.x feature. description field under the about menu also did not work to write text in the About dialog text area

    @SuppressWarnings("restriction")
    public class AboutActionStableHandler extends AbstractHandler {

public Object execute(ExecutionEvent event) throws ExecutionException 
{
    helpDialog = new AboutDialog(HandlerUtil.getActiveShellChecked(event));
    helpDialog.open();
    //helpDialog.getDialogArea(); 
    Shell aboutShell = helpDialog.getShell(); 
    aboutShell.setLayout(new GridLayout());
    Label version = new Label(aboutShell, SWT.NONE);
    version.setText(Platform.getProduct().getDefiningBundle().getVersion().toString());
    version.setLayoutData(GridDataBuilder.create().
    grabExcessHorizontalSpace(true).
    widthHint(500).
    heightHint(5).
    horizontalAlignment(SWT.FILL).build());
    return null;
}

So I end up getting this runtime error when i click on the about Gui java.lang.NullPointerException at com.magic.gui.commands.AboutActionStableHandler.execute(AboutActionStableHandler.java:28) at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:290) at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499) at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508) at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169) at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241) at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:829) at org.eclipse.ui.menus.CommandContributionItem.access$19(CommandContributionItem.java:815) at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:805) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at com.magic.rcp.Application.start(Application.java:87) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584) at org.eclipse.equinox.launcher.Main.run(Main.java:1438) at org.eclipse.equinox.launcher.Main.main(Main.java:1414)

1

There are 1 answers

0
greg-449 On BEST ANSWER

Calling helpDialog.open() displays the dialog and does not return until it is closed when it is to late to modify it.

You could call helpDialog.create() to just create the dialog, and call open() later.

But AboutDialog is an internal class attempting to modify it like this is violating the Eclipse API Rules of Engagement which is why you have had to suppress the restriction warning. There is no way that the AboutDialog can be modified officially. If you want a different about dialog you should really write your own dialog.