开发者

RCP application "the command is undefined" error

开发者 https://www.devze.com 2023-03-25 01:47 出处:网络
When I try to run the application I always get the exception below. Apart form that, everything works nicely

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 or开发者_如何学Cg.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)


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)

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

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

Something like:

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


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

  <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

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

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号