-1

我正在开发一个 Eclipse 插件,我想使用 contect 菜单仅获取所选 javaproject 的包。我已经在我的处理程序中使用了选择,并将它传递给了 mywizard 页面。我无法将选择设置为 treeviewersetinput。如果我使用 treeViewer.setInput(selection)。

我在我的向导页面中有这样的选择。

代码片段:

public void init(IStructuredSelection selection) 
    {
        Object firstElement = selection.getFirstElement();
        if (firstElement instanceof IJavaProject) {
            IJavaProject javaProject = (IJavaProject) firstElement;
            IFolder folder = javaProject.getProject().getFolder("src");
             srcFolder = javaProject
                    .getPackageFragmentRoot(folder);

                System.out.println(srcFolder.getPath().isRoot());

                    System.out.println(firstElement);
                    treeViewer.setInput(srcFolder);

        }
    }




**i am getting error as:**





  src
            <default> (...)
            com (...)
            com.hcl (not open)
            com.hcl.example (not open)
            com.hcl.example.menu (not open)
            com.hcl.example.menu.handlers (not open)

        !ENTRY org.eclipse.ui 4 0 2013-07-28 15:50:07.870
        !MESSAGE Unhandled event loop exception
        !STACK 0
        org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException
            at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
            at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:229)
            at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:210)
            at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:131)
            at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:171)
            at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:814)
            at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:707)
            at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$7(HandledContributionItem.java:691)
            at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:630)
            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.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1029)
            at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
            at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:923)
            at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
            at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
            at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
            at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
            at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
            at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
            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)
        Caused by: java.lang.NullPointerException
            at com.hcl.green.type.handler.GenerateGreenfieldLayer.init(GenerateGreenfieldLayer.java:333)
            at com.hcl.green.type.handler.GreenWizard.addPages(GreenWizard.java:53)
            at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:605)
            at org.eclipse.jface.window.Window.create(Window.java:431)
            at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089)
            at org.eclipse.jface.window.Window.open(Window.java:790)
            at com.hcl.green.type.handler.GreenSelectionHandler.execute(GreenSelectionHandler.java:70)
            at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:290)
            at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:76)
            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.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
            ... 34 more

任何人都可以让我知道如何进行。

4

1 回答 1

-2

看起来像一张丢失的null支票

com.hcl.green.type.handler.GenerateGreenfieldLayer.init(GenerateGreenfieldLayer.java:333)
于 2013-07-29T01:29:35.920 回答