Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to uncheck CheckBoxCellEditor?
How to uncheck CheckBoxCellEditor? [message #1018267] Wed, 13 March 2013 10:30 Go to next message
Joachim Fuchs is currently offline Joachim Fuchs
Messages: 34
Registered: February 2013
Member
Hi,

my out-of-the-box CheckBoxCellEditor refuses to become unchecked. How can that be achieved? I can check it but it is not possible to uncheck once it is checked.

J

[Updated on: Wed, 13 March 2013 10:31]

Report message to a moderator

Re: How to uncheck CheckBoxCellEditor? [message #1018275 is a reply to message #1018267] Wed, 13 March 2013 10:45 Go to previous messageGo to next message
Edwin Park is currently offline Edwin Park
Messages: 124
Registered: July 2009
Senior Member
Hi Joachim,

Have a look at the EditableGridExample. This should work. If yours is not, you'll need to provide some more information about your setup - ideally a test program that demonstrates the issue.

Thanks,
Edwin
Re: How to uncheck CheckBoxCellEditor? [message #1018291 is a reply to message #1018275] Wed, 13 March 2013 11:07 Go to previous messageGo to next message
Joachim Fuchs is currently offline Joachim Fuchs
Messages: 34
Registered: February 2013
Member
Thanks for the quick answer. Well, I used the EditableGridExample as my guide.

There is a CheckBoxPainter, a Validator, a DefaultBooleanConverter and the CheckBoxCellEditor configured for boolean values. What is different from the example is that I have extended the CheckBoxPainter like this:

@Override
protected Boolean convertDataType(ILayerCell cell, IConfigRegistry configRegistry) {
	boolean result = false;
	Object o = cell.getDataValue();
	if (null != o && o instanceof MyObj) {
		MyObj o = (MyObj) o;
		result = Boolean.parseBoolean(o.getValue());
	}
	return result;
//				return super.convertDataType(cell, configRegistry);
}


Otherwise I run into the following Exception, which lets me think that my configuration is not 100% accepted by the nattable (looks like the converter is not being set correctly). All other types are OK with their painters, converters, editors.

Error while painting table: java.lang.String cannot be cast to java.lang.Boolean
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
	at org.eclipse.nebula.widgets.nattable.painter.cell.CheckBoxPainter.convertDataType(CheckBoxPainter.java:71)
	at org.eclipse.nebula.widgets.nattable.painter.cell.CheckBoxPainter.isChecked(CheckBoxPainter.java:61)
	at org.eclipse.nebula.widgets.nattable.painter.cell.CheckBoxPainter.getImage(CheckBoxPainter.java:57)
	at org.eclipse.nebula.widgets.nattable.painter.cell.ImagePainter.paintCell(ImagePainter.java:85)
	at org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter.paintCell(CellLayerPainter.java:69)
	at org.eclipse.nebula.widgets.nattable.selection.SelectionLayerPainter.paintCell(SelectionLayerPainter.java:152)
	at org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter.paintLayer(CellLayerPainter.java:41)
	at org.eclipse.nebula.widgets.nattable.painter.layer.GridLineCellLayerPainter.paintLayer(GridLineCellLayerPainter.java:41)
	at org.eclipse.nebula.widgets.nattable.selection.SelectionLayerPainter.paintLayer(SelectionLayerPainter.java:43)
	at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer$CompositeLayerPainter.paintLayer(CompositeLayer.java:916)
	at org.eclipse.nebula.widgets.nattable.painter.layer.NatLayerPainter.paintLayer(NatLayerPainter.java:36)
	at org.eclipse.nebula.widgets.nattable.NatTable.paintNatTable(NatTable.java:333)
	at org.eclipse.nebula.widgets.nattable.NatTable.paintControl(NatTable.java:329)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:230)
	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.Widget.sendEvent(Widget.java:1077)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
	at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1463)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4585)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2546)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3756)
	at dev.treetable.nat.NatTreeTablePartTest.testCreateControl(NatTreeTablePartTest.java:62)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Error while painting table: java.lang.String cannot be cast to java.lang.Boolean
Re: How to uncheck CheckBoxCellEditor? [message #1018312 is a reply to message #1018291] Wed, 13 March 2013 11:50 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1263
Registered: July 2012
Senior Member
I don't think you need the DefaultBooleanConverter when using CheckboxPainter and CheckboxCellEditor. These two will complain if the underlying value is NOT a boolean, otherwise you don't need to care.
Re: How to uncheck CheckBoxCellEditor? [message #1018352 is a reply to message #1018312] Wed, 13 March 2013 12:56 Go to previous message
Joachim Fuchs is currently offline Joachim Fuchs
Messages: 34
Registered: February 2013
Member
These are the labels and converter for the cell:
[LABEL_COLUMN_VALUE, LABEL_VALUE:HALF-DUPLEX, HALF-DUPLEX, LABEL_PAINTER_BOOLEAN, LABEL_CONVERTER_BOOLEAN, LABEL_EDITOR_BOOLEAN, selectionAnchor, BODY]
org.eclipse.nebula.widgets.nattable.data.convert.DefaultBooleanDisplayConverter@3e4a9a7d

The click on the checkbox is honored but for some reason it does not change the value of it. The validator gets a TRUE for validation, which should be a FALSE.
Previous Topic:How to do full row selection?
Next Topic:Questions about GlazedList and Nattable
Goto Forum:
  


Current Time: Fri Aug 29 10:14:13 EDT 2014

Powered by FUDForum. Page generated in 0.17091 seconds