gpt4 book ai didi

java - 从 Tree 到 TreeViewer 控件

转载 作者:行者123 更新时间:2023-12-02 08:13:16 25 4
gpt4 key购买 nike

我有这个代码

TreeViewer m_treeViewer = new TreeViewer(m_myTree);

我试图用树控件初始化树查看器控件。树形控件就是这样初始化的

m_myTree= new Tree(parent, SWT.VIRTUAL);
setTreeItemListener(); // Add a double mouse click listener

// Code to populate the tree control..

m_myTree.pack();

但每次我在树控件中选择一个项目时,TreeViewer 控件都会失败并显示以下堆栈日志

!ENTRY org.eclipse.ui 4 0 2011-08-04 12:40:17.944
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.core.runtime.AssertionFailedException: **null argument**:
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:73)
at org.eclipse.jface.viewers.AbstractTreeViewer.**getTreePathFromItem**(AbstractTreeViewer.java:2870)
at org.eclipse.jface.viewers.**AbstractTreeViewer.getSelection**(AbstractTreeViewer.java:2893)
at org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredViewer.java:1190)
at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(StructuredViewer.java:1220)
at org.eclipse.jface.util.OpenStrategy.**fireSelectionEvent**(OpenStrategy.java:228)
at org.eclipse.jface.util.OpenStrategy.access$4(OpenStrategy.java:222)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:389)
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:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
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:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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:620)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
at org.eclipse.equinox.launcher.Main.main(Main.java:1384)

我实在搞不懂,请帮帮我。我尝试关联一个空白的 ILazyTreePathContentProvider 但也失败了

最佳答案

我猜,这是因为没有分配给查看器的输入。

关于java - 从 Tree 到 TreeViewer 控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6940035/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com