如何在Eclipse 3.8.1 RCP应用程序的“帮助”菜单下的“关于”条目中自定义文本和按钮

90天

我正在尝试自定义Eclipse 3.8.1上的Help-> About菜单项。我尝试了两种3.x友好方法,因为Eclipse 4.0的工作方式有所不同。

--->我尝试扩展AboutAction本身(org.eclipse.ui.internal.dialogs.AboutDialog),这样我就可以在DialogArea Text中添加一行,并在单击License按钮时添加一个可滚动的Dialog Gui。但是所有方法在API中受到保护,我看到它说用户可以使用但不能覆盖(与Dialog类相同)

--->我尝试扩展默认的AbstractHandler,并在execute方法中创建一个Dialog对象,我基本上想逐一添加所有我需要的东西。唯一的问题是,我无法在execute方法中使用Dialog对象,因为在execute方法结束之前,它始终为null引用,因此如果没有nullPointerException困扰我,我将无法向其添加内容。

--->我也尝试添加<property>到plugin.xml本身。这似乎是4.x功能。“关于”菜单下的“描述”字段也无法在“关于”对话框文本区域中写入文本

    @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;
}

因此,当我单击关于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)

greg-449

调用将helpDialog.open()显示该对话框,直到要修改该对话框时,该对话框才会关闭,直到返回。

您可以调用helpDialog.create()以仅创建对话框,然后再调用open()

但是 AboutDialog是一个内部类试图修改它,就像这样违反了Eclipse API参与规则,这就是为什么您必须取消限制警告的原因。无法AboutDialog正式修改。如果您想使用其他对话框,则应该编写自己的对话框。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在JavaFX 8中创建自定义3d模型?

如何在Eclipse RCP应用程序中为自动生成的文件提供自定义位置

如何在Vue.js中显示12个条目中的1到3?

如何在 Laravel 8/Inertia.js/vuejs3 应用程序中创建和使用常用的 mixin?

如何在Windows 8中为32位应用程序启用Direct3D加速?

为什么3-1 * 8 + 2 * 3等于1

在 Eclipse RCP 应用程序中禁用自定义首选项页面的取消按钮

如何绘制自定义标签边框右侧3边和1舍入

为什么parseInt(8,3)== NaN和parseInt(16,3)== 1?

如何在GNOME 3中编辑“应用程序”菜单?

如何在Swift 3中自定义按钮的大小?

关于如何在Android中流式传输M3U8视频的任何想法

R:如何制作序列(1,1,1,2,3,3,3,4,5,5,5,6,7,7,7,8)

如何在Java中的ISO-8859-1和UTF-8之间转换?

如何重复序列:r中的1,2,3,4,5,6,1,2,3,4,5,6,7,8,9,10,7,8,9,10

如何在OSX,Xcode 8,Swift 3中实现单选按钮?

如何在Swift 3(XCode 8)中从文本文件读取数据

如何在Windows 8上禁用DirectDraw和Direct3D加速?

如何在Gnome3中为单个非GTK3应用程序窗口自定义窗口装饰器?

如何在密集或展平的图层之后应用Conv1D:ValueError:形状(1、1、3)和(1、1)不兼容

如何在tkinter中并排包装3个单选按钮和1个标签?

如何检测ios8自定义键盘扩展是否在非iPhone 6优化应用程序中运行?

如何在存储过程中将EventAccessIds = 1 + 4 + 8分解为EventId = 1,EventId = 4和EventId = 8?

为什么C ++认为8 ^ 1/3 = 1?

如何在 Drupal 8 中将自定义类设置为子菜单?

创建主题时,如何在整个应用程序中自定义material-ui V1组件?

如何在电子应用程序中自定义菜单?

如何在iOS 8中创建自定义委托?

如何修复'ValueError:形状(1,3)和(1,1)未对齐:3(dim 1)!= 1(dim 0)'错误