Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » ICelleditor: show error and do not allow to loose focus until valid data is inserted
ICelleditor: show error and do not allow to loose focus until valid data is inserted [message #941513] Fri, 12 October 2012 15:48 Go to next message
Rui Domingues is currently offline Rui DominguesFriend
Messages: 194
Registered: October 2010
Senior Member
Hi.

I'm implementing a tableviewer and two buttons to add and remove records.
Using Jface emf.edit databinding, I'm also implementing editing support for each field. for that I defined textcelleditors and Icelleditorvalidator.

My problem is: I want the user not exiting the editor until he inserted valid data, and When he is trying to exit and data is invalid I want to show an error messagebox.
Is this possible ?

I almost managed to do some of these things (with listener), however there exists always some where I stumble upon:
-listener.applyeditorvalue is called twice when exiting editor.
-listener.editorValuechange is called on each change

But I think the problem is around lostfocus event.

Is there any way to implement this?

Thanks in advance.
Re: ICelleditor: show error and do not allow to loose focus until valid data is inserted [message #1001325 is a reply to message #941513] Wed, 16 January 2013 13:42 Go to previous messageGo to next message
Bernard Sarter is currently offline Bernard SarterFriend
Messages: 88
Registered: August 2011
Location: Paris, France
Member
Hi,

I'm facing the same problem:

final TextCellEditor textCellEditor = new TextCellEditor(table, SWT.NONE);
textCellEditor.addListener(new ICellEditorListener() {

@Override
public void applyEditorValue() 
{
    if (notOk) ErrorDialog.openError(null, "Error", "Problem", new Status(IStatus.WARNING, "foo", "Error."));
}

@Override
public void cancelEditor() {
}

@Override
public void editorValueChanged(boolean arg0, boolean arg1) {
}

});


applyEditorValue get's called twice, and the user needs to call the Errormessage twice (I do not have the problem if I do not display the ErrorDialog).

Any suggestion welcome (I'm using Eclipse 4.2.1).
Bernard.
Re: ICelleditor: show error and do not allow to loose focus until valid data is inserted [message #1001495 is a reply to message #1001325] Wed, 16 January 2013 20:30 Go to previous message
Bernard Sarter is currently offline Bernard SarterFriend
Messages: 88
Registered: August 2011
Location: Paris, France
Member
Ok, I could find a suitable workaround here: http://www.eclipsezone.com/eclipse/forums/m92122629.html, by adding a simple volatile flag:

textCellEditor.addListener(new ICellEditorListener() {

private volatile boolean inProgress = false;

@Override
public void applyEditorValue() {
   if (inProgress) {
      return;
   }
   inProgress = true;
   ...
if (notOk) ErrorDialog.openError(null, "Error", "Problem", new Status(IStatus.WARNING, "foo", "Error."));
   ...
   inProgress = false;
}


Previous Topic:JFace CellEditor- Table cell click actions
Next Topic:CheckboxTableViewer looses Checked State after Filter
Goto Forum:
  


Current Time: Tue Mar 19 07:25:52 GMT 2024

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

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

Back to the top