开发者

From Tree to TreeViewer control

开发者 https://www.devze.com 2023-03-26 00:20 出处:网络
I have this code TreeViewer m_treeViewer = new TreeViewer(m_myTree); where I\'m trying to initialize a treeviewer control with a tree control. The tree control is initialized this way

I have this code

TreeViewer m_treeViewer = new TreeViewer(m_myTree);

where I'm trying to initialize a treeviewer control with a tree control. The tree control is initialized this way

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

// Code to populate the tree control..

m_myTree.pack();

but every time I select an item in the tree control the TreeViewer control is failing with the following stack log

!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.Eve开发者_开发技巧ntTable.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)

I can't figure this out, please give me a hand. I tried associating a blank ILazyTreePathContentProvider but it failed too


I guess, its because there is no input assigned to the viewer.


I get similar error when I click add button. I am using Tableviewer and tried using both syntax as below

m_tableViewer.setSelection(new StructuredSelection(workplaceDetail), true);

and

m_tableViewer.setInput(workplaceDetail);
0

精彩评论

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