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 11:48 Go to next message
Rui Domingues is currently offline Rui Domingues
Messages: 186
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 08:42 Go to previous messageGo to next message
Bernard SARTER is currently offline Bernard SARTER
Messages: 75
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 15:30 Go to previous message
Bernard SARTER is currently offline Bernard SARTER
Messages: 75
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:Validation of Tables with Databinding
Next Topic:Compositeruler and Sourceviewerconfiguration
Goto Forum:
  


Current Time: Sat Jul 26 05:25:31 EDT 2014

Powered by FUDForum. Page generated in 0.01676 seconds