Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to validate data by the use of commands through code directly.
How to validate data by the use of commands through code directly. [message #1220487] Thu, 12 December 2013 07:24 Go to next message
SD Khan is currently offline SD Khan
Messages: 63
Registered: May 2013
Member
Hi Dirk !

I have a cell which is editable and attached display converter and data validators to it now, when i click on the cell and type some invalid value it works fine and validator mark value as RED and don't allow to commit.

So Now,

I want's to achieve the same behavior through the code like when some button is pressed, my cell becomes editable and if the passed values is not valid, then it should mark it as red and don't allow to commit.

I have tried several things, like first called EditCellCommand, which bring my cell in the inline edit mode, now i called updateCellCommand , which trys to commit wrong value, but instead of showing the error and marking the wrong value as red, it does nothing.

What are the required steps needed to achieve this behavior ?

Thanks,
SD Khan
Re: How to validate data by the use of commands through code directly. [message #1220494 is a reply to message #1220487] Thu, 12 December 2013 08:17 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1339
Registered: July 2012
Senior Member
That behaviour can not be achieved easily by using NatTable code. Marking the text red in a TextCellEditor is done by key listeners on the underlying Text Control. So if you want to trigger such behaviour you need to get in touch with the Text Control directly.

Also by calling the update command directly you are skipping the framework code for conversion and validation. The update command is fired if conversion and validation passes. You need to commit the current active editor. This is currently possible by using the ActiveCellEditorRegistry.
Re: How to validate data by the use of commands through code directly. [message #1220528 is a reply to message #1220494] Thu, 12 December 2013 11:18 Go to previous messageGo to next message
SD Khan is currently offline SD Khan
Messages: 63
Registered: May 2013
Member
Yup, right , I have done following steps

1. Called edit cell command
EditCellCommand cmd = new EditCellCommand(getTable().getNatTable(), getTable().getConfigRegistry(), cell);
getTable().getNatTable().doCommand(cmd);

2.Get active cell editor
ICellEditor editor = ActiveCellEditorRegistry.getActiveCellEditor();

3. Set the text you want to set
editor.setEditorValue("wow");

4.Now, validate
editor.validateCanonicalValue(editor.getEditorValue(), new RenderErrorHandling(new ControlDecorationProvider(FieldDecorationRegistry.DEC_ERROR)));

Now, if the text is invalid, it will remain in the edit mode and will be marked as red.

But his behavior can only be achieved for text cell editors.

[Updated on: Thu, 12 December 2013 11:19]

Report message to a moderator

Re: How to validate data by the use of commands through code directly. [message #1220639 is a reply to message #1220528] Thu, 12 December 2013 19:24 Go to previous message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1339
Registered: July 2012
Senior Member
What other editor should support it?
Previous Topic:Collapse All Rows in TreeLayer
Next Topic:Abrupt behavior when using "EditCellCommand" through code directly
Goto Forum:
  


Current Time: Sun Oct 26 00:34:48 GMT 2014

Powered by FUDForum. Page generated in 0.08835 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software