Eclipse PluginDevelopment - класс-обработчик не запускается с помощью plugin.xml

Я работаю над проектом, который должен открыть представление. Он должен быть открыт с помощью contextmenu-entry. Но это не работает. Каждый раз, когда я открываю контекстное меню внутри нового рабочего пространства Eclipse, я получаю исключение, и он не открывает обработчик someorg.handlers.ShowViewHandler

!MESSAGE Exception while dispatching event org.osgi.service.event.Event

Я прокомментировал plugin.xml со словами "что я ожидаю"

Может кто-нибудь сказать мне, в чем проблема / почему не запускается класс обработчика?

<plugin>
     <extension point="org.eclipse.ui.commands">
      <command
            id="someorg.editor.ShowView"
            name="ShowView">
            <commandParameter
                  id="FeatureType"
                  name="feature type"
                  optional="false"
            />
      </command>
    </extension>

    <extension point="org.eclipse.ui.menus"><!--adds a contextmenu entry with the name "ShowtheView..."-->
        <menuContribution locationURI="popup:#TextEditorContext?after=group.find" > 
            <command
                 commandId="someorg.editor.ShowView"
                 label="ShowTheView...">
                <visibleWhen checkEnabled="false">
                    <reference definitionId="someorg.Editor.opened">
                    </reference>
                </visibleWhen>
                <parameter name="Type" value="ViewThis"/>
            </command>
        </menuContribution>
    </extension>

    <extension point="org.eclipse.ui.handlers"><!--opens the handlerclass "someorg.handlers.ShowViewHandler" where the View is computed.-->
        <handler
            class="someorg.handlers.ShowViewHandler"
            commandId="someorg.editor.ShowView">
            <activeWhen>
                <reference
                    definitionId="someorg.Editor.opened">
                </reference>
            </activeWhen>
        </handler>
    </extension>


    <!--some other (independent) declarations-->

Полный журнал ошибок после открытия контекстного меню:

!ENTRY org.eclipse.equinox.event 4 0 2016-02-25 12:00:25.511
!MESSAGE Exception while dispatching event org.osgi.service.event.Event [topic=org/eclipse/e4/ui/model/ui/ElementContainer/children/ADD] {ChangedElement=org.eclipse.e4.ui.model.application.ui.menu.impl.PopupMenuImpl@cd19d0a (elementId: #TextEditorContext, tags: [menuContribution:popup, popup:#TextEditorContext, popup:someorg.EditorContext, popup:#AbstractTextEditorContext], contributorURI: null) (widget: Menu {&Undo Ctrl+Z, Re&vert File, &Save Ctrl+S, |, Quick Outline    Ctrl+O, Open Source File, Quick Outline Ctrl+O, Open Declaration    F3, Open Call Hierarchy Ctrl+Alt+H, Quick Hierarchy Ctrl+T, Open Type in Hierarchy  F4, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Open Call Hierarchy Ctrl+Alt+H, Quick Hierarchy Ctrl+T, Open Type in Hierarchy  F4, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Open with SceneBuilder, Open W&ith, Sho&w In    Alt+Shift+W, |, Cu&t    Ctrl+X, &Copy   Ctrl+C, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, &Paste    Ctrl+V, |, Rename Element   Alt+Shift+R, Validate, Validate, Validate, Extract Local Variable   Alt+Shift+L, Organize Imports   Ctrl+Shift+O, Rename Element    Alt+Shift+R, Validate, Rename Element   Alt+Shift+R, Validate, Extract Local Variable   Alt+Shift+L, Organize Imports   Ctrl+Shift+O, Rename Element    Alt+Shift+R, Validate, Validate, Rename Element Alt+Shift+R, Validate, Validate, Rename Element Alt+Shift+R, Validate, Validate, Rename Element Alt+Shift+R, Validate, Rename Element   Alt+Shift+R, Validate, Validate, Validate, Validate, Validate, Validate, Validate, Validate, Validate, &Quick Fix   Ctrl+1, |, ShowTheView, Find References Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, |, Wa&tch, Build & Export FX Application, Upgrade to EclipseLink Mapping File, Upgrade JPA Document Version, Synchronize Class List, Retrieve Context, Explore, I&mport from Repository..., Register As Service...    Ctrl+Shift+F10, |, Pre&ferences...}, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (label: null, iconURI: null, tooltip: null, mnemonics: null) (enabled: true) (context: popup:#TextEditorContext, variables: null), Widget=Menu {&Undo Ctrl+Z, Re&vert File, &Save Ctrl+S, |, Quick Outline    Ctrl+O, Open Source File, Quick Outline Ctrl+O, Open Declaration    F3, Open Call Hierarchy Ctrl+Alt+H, Quick Hierarchy Ctrl+T, Open Type in Hierarchy  F4, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Open Call Hierarchy Ctrl+Alt+H, Quick Hierarchy Ctrl+T, Open Type in Hierarchy  F4, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Quick Outline   Ctrl+O, Open with SceneBuilder, Open W&ith, Sho&w In    Alt+Shift+W, |, Cu&t    Ctrl+X, &Copy   Ctrl+C, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, Copy Qualified Name, &Paste    Ctrl+V, |, Rename Element   Alt+Shift+R, Validate, Validate, Validate, Extract Local Variable   Alt+Shift+L, Organize Imports   Ctrl+Shift+O, Rename Element    Alt+Shift+R, Validate, Rename Element   Alt+Shift+R, Validate, Extract Local Variable   Alt+Shift+L, Organize Imports   Ctrl+Shift+O, Rename Element    Alt+Shift+R, Validate, Validate, Rename Element Alt+Shift+R, Validate, Validate, Rename Element Alt+Shift+R, Validate, Validate, Rename Element Alt+Shift+R, Validate, Rename Element   Alt+Shift+R, Validate, Validate, Validate, Validate, Validate, Validate, Validate, Validate, Validate, &Quick Fix   Ctrl+1, |, ShowTheView..., Find References  Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, Find References   Ctrl+Shift+G, |, Wa&tch, Build & Export FX Application, Upgrade to EclipseLink Mapping File, Upgrade JPA Document Version, Synchronize Class List, Retrieve Context, Explore, I&mport from Repository..., Register As Service...    Ctrl+Shift+F10, |, Pre&ferences...}, AttName=children, NewValue=org.eclipse.e4.ui.model.application.ui.menu.impl.HandledMenuItemImpl@6a2e7d2d (elementId: someorg.Editor.ShowView, tags: [], contributorURI: null) (widget: MenuItem {ShowTheView}, renderer: org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer@40e420fe, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (label: ShowTheView..., iconURI: null, tooltip: null, enabled: true, selected: false, type: Push) (mnemonics: null) (wbCommand: null), EventType=ADD, Position=92} to handler org.eclipse.e4.ui.internal.di.UIEventObjectSupplier$UIEventHandler@60cb098b
!STACK 0
org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:68)
    at org.eclipse.e4.ui.internal.di.UIEventObjectSupplier$UIEventHandler$1.run(UIEventObjectSupplier.java:56)
    at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:186)
    at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:145)
    at org.eclipse.swt.widgets.Display.syncExec(Display.java:4761)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:211)
    at org.eclipse.e4.ui.internal.di.UIEventObjectSupplier$UIEventHandler.handleEvent(UIEventObjectSupplier.java:53)
    at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
    at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
    at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
    at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
    at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
    at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
    at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:85)
    at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:59)
    at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
    at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:249)
    at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:356)
    at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:341)
    at org.eclipse.e4.ui.workbench.renderers.swt.ContributionRecord.mergeIntoModel(ContributionRecord.java:250)
    at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer.processAddition(MenuManagerRenderer.java:554)
    at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer.generateContributions(MenuManagerRenderer.java:529)
    at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer.processContributions(MenuManagerRenderer.java:494)
    at org.eclipse.ui.internal.PopupMenuExtender.addMenuContributions(PopupMenuExtender.java:409)
    at org.eclipse.ui.internal.PopupMenuExtender.menuAboutToShow(PopupMenuExtender.java:381)
    at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:333)
    at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:466)
    at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:461)
    at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:493)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:255)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1137)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1118)
    at org.eclipse.swt.widgets.Control.WM_INITMENUPOPUP(Control.java:5023)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4691)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
    at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1633)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2117)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5050)
    at org.eclipse.swt.internal.win32.OS.TrackPopupMenu(Native Method)
    at org.eclipse.swt.widgets.Menu._setVisible(Menu.java:262)
    at org.eclipse.swt.widgets.Display.runPopups(Display.java:4221)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3763)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
Caused by: java.lang.NullPointerException
    at org.eclipse.ui.internal.commands.SlaveCommandService.registerElementForCommand(SlaveCommandService.java:311)
    at org.eclipse.ui.internal.commands.SlaveCommandService.registerElementForUpdate(SlaveCommandService.java:395)
    at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.fill(HandledContributionItem.java:324)
    at org.eclipse.jface.action.MenuManager.doItemFill(MenuManager.java:724)
    at org.eclipse.jface.action.MenuManager.update(MenuManager.java:806)
    at org.eclipse.jface.action.MenuManager.update(MenuManager.java:665)
    at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer.scheduleManagerUpdate(MenuManagerRenderer.java:1164)
    at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer.processContents(MenuManagerRenderer.java:636)
    at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer.subscribeTopicChildAdded(MenuManagerRenderer.java:313)
    at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
    ... 68 more

1 ответ

Я думаю, это потому, что вы указываете неправильный идентификатор для обязательного параметра команды.

В org.eclipse.ui.commands вы объявляете параметр как

 <commandParameter
        id="FeatureType"
        name="feature type"
        optional="false"

так что идентификатор FeatureType

но в org.eclipse.ui.menus ты используешь:

<parameter name="Type" value="ViewThis"/>

name совпадает

Другие вопросы по тегам