2009-09-07 73 views
3

希望有人能指出我正確的方向。我試圖在Eclipse中創建一個CellEditor,當我點擊該字段時,我得到一個未處理的事件循環異常,下面的堆棧跟蹤。在Eclipse中創建CellEditor時發生AssertionFailedException

此列的單元格編輯代碼如下所示

/** Cell Editor Row 2 **/ 
textEditor = new TextCellEditor(table); 
((Text)textEditor.getControl()).setTextLimit(10); 
editors[1] = textEditor; 

org.eclipse.core.runtime.AssertionFailedException: assertion failed: 
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:111) 
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:97) 
at org.eclipse.jface.viewers.TextCellEditor.doSetValue(TextCellEditor.java:228) 
at org.eclipse.jface.viewers.CellEditor.setValue(CellEditor.java:855) 
at org.eclipse.jface.viewers.EditingSupport.initializeCellEditorValue(EditingSupport.java:96) 
at org.eclipse.jface.viewers.ColumnViewerEditor.activateCellEditor(ColumnViewerEditor.java:194) 
at org.eclipse.jface.viewers.ColumnViewerEditor.handleEditorActivationEvent(ColumnViewerEditor.java:443) 
at org.eclipse.jface.viewers.ColumnViewer.triggerEditorActivationEvent(ColumnViewer.java:680) 
at org.eclipse.jface.viewers.ColumnViewer.handleMouseDown(ColumnViewer.java:664) 
at org.eclipse.jface.viewers.ColumnViewer.access$0(ColumnViewer.java:660) 
at org.eclipse.jface.viewers.ColumnViewer$1.mouseDown(ColumnViewer.java:89) 
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:179) 
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) 
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003) 
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823) 
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422) 
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382) 
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346) 
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198) 
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) 
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) 
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) 
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) 
at com.tasc.swb.internal.application.SWBApplication.start(SWBApplication.java:414) 
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) 
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:382) 
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:549) 
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) 
at org.eclipse.equinox.launcher.Main.run(Main.java:1236) 
at org.eclipse.equinox.launcher.Main.main(Main.java:1212) 

回答

10

根據this thread

好像:

  • 你要麼不設置CellModifierTableViewer(使用setCellModifier()函數)
  • 或者,如果有,則ICellModifier後代的getValue()函數返回null或不是String對象。
    getValue()的返回值是一個對象,但如果您使用的是TextCellEditor,它必須返回一個String。
+0

看起來你是正確的返回字符串部分。謝謝! – 2009-09-07 19:12:14

+0

非常有用的提示!謝謝! – 2011-09-06 23:10:33

相關問題