RCP应用程序“命令未定义”错误

时间:2023-01-21 16:25:11

When I try to run the application I always get the exception below. Apart form that, everything works nicely

当我尝试运行应用程序时,我总是会得到下面的异常。除此之外,一切都很好

java.lang.Exception
    at org.eclipse.jface.action.ExternalActionManager$CommandCallback.isActive(ExternalActionManager.java:370)
    at org.eclipse.jface.action.ActionContributionItem.isCommandActive(ActionContributionItem.java:647)
    at org.eclipse.jface.action.ActionContributionItem.isVisible(ActionContributionItem.java:703)
    at org.eclipse.jface.action.MenuManager.isChildVisible(MenuManager.java:999)
    at org.eclipse.jface.action.MenuManager.isVisible(MenuManager.java:567)
    at org.eclipse.jface.action.MenuManager.isChildVisible(MenuManager.java:999)
    at org.eclipse.jface.action.MenuManager.update(MenuManager.java:763)
    at org.eclipse.jface.action.MenuManager.update(MenuManager.java:682)
    at org.eclipse.jface.action.MenuManager.createMenuBar(MenuManager.java:197)
    at org.eclipse.jface.action.MenuManager.createMenuBar(MenuManager.java:213)
    at org.eclipse.ui.internal.WorkbenchWindow.createDefaultContents(WorkbenchWindow.java:1069)
    at org.eclipse.ui.internal.WorkbenchWindowConfigurer.createDefaultContents(WorkbenchWindowConfigurer.java:623)
    at org.eclipse.ui.application.WorkbenchWindowAdvisor.createWindowContents(WorkbenchWindowAdvisor.java:300)
    at org.eclipse.ui.internal.WorkbenchWindow.createContents(WorkbenchWindow.java:1036)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.eclipse.ui.internal.Workbench$22.runWithException(Workbench.java:1211)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)

2 个解决方案

#1


3  

That means a command definition is missing.
You will find example of similar error in this bug report or in EclipseZone.
You should have a 'The command ("org.eclipse.ui.file.closeAllSaved") is undefined' preceding this exception.
("org.eclipse.ui.file.closeAllSaved" is only there as an example: it your case, it could be a different command)

这意味着缺少命令定义。您将在这个bug报告或EclipseZone中找到类似错误的示例。在此异常之前,您应该有一个“未定义的命令”(“org.eclipse.ui.file.closeAllSaved”)。(“org.eclipse.ui.file。closeAllSaved只是一个例子:它是你的情况,它可能是另一个命令)

In the case of the first one, the proposed patch "omit default handler as we don't have xxx support".

在第一个例子中,建议的补丁“省略默认处理程序,因为我们没有xxx支持”。

For the second one:

第二个:

A simple workaround for an RCP app would be to include a useful definition in one of your plugins (or in a separate throw-away plugin).

对于RCP应用来说,一个简单的解决方案就是在你的一个插件中加入一个有用的定义(或者在一个单独的一次性插件中)。

Something like:

喜欢的东西:

categoryId="org.eclipse.ui.category.file"
id="org.eclipse.ui.file.closeAllSaved"    # replace by your missing command
name="Close All Saved"/> 

#2


1  

As VonC said, a command definition is missing. You should add something like this:

正如VonC所说,缺少一个命令定义。你应该添加如下内容:

  <command
        name="Close All Saved"
        description="Close All Saved"
        categoryId="org.eclipse.ui.category.file"
        id="org.eclipse.ui.file.closeAllSaved">
  </command>

to plugin.xml

对plugin . xml

Also make sure that categoryId refers to a category already defined or you will get a warning like this:

还要确保categoryId指的是已经定义好的类别或者你会得到这样的警告:

!MESSAGE Commands should really have a category: plug-in='xxxxx', id='xxxx', categoryId='xxxxx'

#1


3  

That means a command definition is missing.
You will find example of similar error in this bug report or in EclipseZone.
You should have a 'The command ("org.eclipse.ui.file.closeAllSaved") is undefined' preceding this exception.
("org.eclipse.ui.file.closeAllSaved" is only there as an example: it your case, it could be a different command)

这意味着缺少命令定义。您将在这个bug报告或EclipseZone中找到类似错误的示例。在此异常之前,您应该有一个“未定义的命令”(“org.eclipse.ui.file.closeAllSaved”)。(“org.eclipse.ui.file。closeAllSaved只是一个例子:它是你的情况,它可能是另一个命令)

In the case of the first one, the proposed patch "omit default handler as we don't have xxx support".

在第一个例子中,建议的补丁“省略默认处理程序,因为我们没有xxx支持”。

For the second one:

第二个:

A simple workaround for an RCP app would be to include a useful definition in one of your plugins (or in a separate throw-away plugin).

对于RCP应用来说,一个简单的解决方案就是在你的一个插件中加入一个有用的定义(或者在一个单独的一次性插件中)。

Something like:

喜欢的东西:

categoryId="org.eclipse.ui.category.file"
id="org.eclipse.ui.file.closeAllSaved"    # replace by your missing command
name="Close All Saved"/> 

#2


1  

As VonC said, a command definition is missing. You should add something like this:

正如VonC所说,缺少一个命令定义。你应该添加如下内容:

  <command
        name="Close All Saved"
        description="Close All Saved"
        categoryId="org.eclipse.ui.category.file"
        id="org.eclipse.ui.file.closeAllSaved">
  </command>

to plugin.xml

对plugin . xml

Also make sure that categoryId refers to a category already defined or you will get a warning like this:

还要确保categoryId指的是已经定义好的类别或者你会得到这样的警告:

!MESSAGE Commands should really have a category: plug-in='xxxxx', id='xxxx', categoryId='xxxxx'