eclipse/nebula

Check box column does not check/uncheck correctly

Cydoniat opened this issue · 3 comments

Hello everyone!

We've encountered a pretty boring problem and for some days now we haven't been able to solve it. To give a bit of background, we have a Nebula NatTable with 5 columns, where the last one should be a a column containing simple check boxes. We have followed this tutorial: https://www.vogella.com/tutorials/NatTableEditing/article.html. However, the problem we have is with actual clicking on the cell. If you just click on it, it doesn't change the state. However, if the cell is selected and you then push the space bar, the tick does (dis)appear and the underlying command is triggered. Here's the configuration we have so far:
`public class CheckBoxConfigurationNebula extends AbstractRegistryConfiguration {

@Override
public void configureRegistry(final IConfigRegistry configRegistry) {

	configRegistry.registerConfigAttribute(
			EditConfigAttributes.CELL_EDITABLE_RULE,
			IEditableRule.ALWAYS_EDITABLE
			);

	registerCheckBoxEditor(configRegistry);
}

private static void registerCheckBoxEditor(final IConfigRegistry configRegistry) {

	configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new CheckBoxCellEditor(),
			DisplayMode.EDIT, NatTableWidgetFactory.VISIBILITY_CELL);

	// Visualized as a check box button
	configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER,
			new CheckBoxPainter(),
			DisplayMode.NORMAL, NatTableWidgetFactory.VISIBILITY_CELL);

	// Needs a Boolean conversion to work correctly
	configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER,
			new DefaultBooleanDisplayConverter(), DisplayMode.NORMAL, NatTableWidgetFactory.VISIBILITY_CELL);
}

}`

Do you have an idea what could be the problem?

I'm not sure if I understand correctly. Do you expect that the checkbox state changes when you click in the cell even if you don't hit the checkbox? Or is it something different?

Btw, although NatTable is a subproject of Nebula it has its own repository and forum. I wasn't able to migrate it to GitHub so far.

I see my mistake, I said cell but meant the check box inside of it. The tick doesn't (dis)appear even in any case - neither when clicking exactly on the check box nor on the cell. The only thing that works is selecting the cell and ten hitting the space bar.

Should I move the question to the other forum?

Well, if the checkbox state change works on key press but not on click, I suppose you are missing the necessary ui bindings. The tutorial you are referring to is not covering this fact, as it simply uses a GridLayer that has the necessary configurations already included by default. If you are not using a GridLayer with the default configuration enabled, the necessary mouse bindings are missing.

The following page should cover it at least basically: https://www.eclipse.org/nattable/documentation.php?page=editing

Of course I don't know if you are using a GridLayer like the tutorial or if you are using another composition. Or if you changed the configuration in any way, as you did not share your layer composition. So I can only guess, but typically the described behavior results from missing or incorrectly registered ui binding configurations.

Should I move the question to the other forum?

If it is necessary to have a longer discussion yes.