Track dirty state of editor [message #326641] |
Thu, 27 March 2008 10:51 |
Eclipse User |
|
|
|
Originally posted by: news.dankof.net
Hello!
I'm currently facing a problem regarding the dirty state of an editor.
My editor uses data binding and a ScrolledForm. I want the editor to
be dirty as soon as the user edits the form.
Is there a best practice to handle this?
My current solution is to add a filter for SWT.Selection and SWT.KeyDown
to the applications display. This actually works but the listener is
invoked for every opened editor.
I also found another solution in this newsgroup which involves setting
the dirty state as soon as a setter of the model is being called. As I'd
like my model to be independet of the GUI, this is not an option.
Does anyone have a suggestion how this can be improved? Mabye adding a
listener to the editor, form, main composite, binding context or something?
Thanks,
Fabian
|
|
|
Re: Track dirty state of editor [message #326644 is a reply to message #326641] |
Thu, 27 March 2008 12:03 |
|
On Thu, 27 Mar 2008 10:51:41 +0000, "Fabian Dankof" <news@dankof.net>
wrote:
>I also found another solution in this newsgroup which involves setting
>the dirty state as soon as a setter of the model is being called. As I'd
>like my model to be independet of the GUI, this is not an option.
>
If your model classes are implemented as Java Beans, you could
register a property change listener. This wouldn't tie your model to
any GUI.
And since you are using data binding, your model should already use a
Bean interface (and the property change event).
Achim
Achim Lörke
|
|
|
Re-2: Track dirty state of editor [message #326660 is a reply to message #326644] |
Thu, 27 March 2008 12:03 |
Eclipse User |
|
|
|
Originally posted by: news.dankof.net
-------- Original Message --------
Subject: Re: Track dirty state of editor (27-Mrz-2008 13:03)
From: Achim Lörke <Achim.Loerke@bredex.de>
To:
>
> If your model classes are implemented as Java Beans, you could
> register a property change listener. This wouldn't tie your model to
> any GUI.
>
In fact it does.
Where can I register a property change listener? Is it the databinding context?
Fabian
|
|
|
Re-3: Track dirty state of editor [message #326676 is a reply to message #326660] |
Thu, 27 March 2008 12:03 |
Eclipse User |
|
|
|
Originally posted by: news.dankof.net
OK I tried it and it works. But there is one thing I forgot to mention:
Everytime I an editor changes, a lock token is acquired. If this is not
possible, the user should not be able to change anything. If I register
a PropertyChangeListener it seems that I cannot cancel the input operation
of the user (such as event.doit=false).
So my feeling is that I somehow have to listen for any GUI events rather than
model events. Right?
|
|
|
Re: Re-3: Track dirty state of editor [message #326679 is a reply to message #326676] |
Fri, 28 March 2008 11:39 |
|
On Thu, 27 Mar 2008 12:03:30 +0000, "Fabian Dankof" <news@dankof.net>
wrote:
>
>OK I tried it and it works. But there is one thing I forgot to mention:
>
>Everytime I an editor changes, a lock token is acquired. If this is not
>possible, the user should not be able to change anything. If I register
>a PropertyChangeListener it seems that I cannot cancel the input operation
>of the user (such as event.doit=false).
>So my feeling is that I somehow have to listen for any GUI events rather than
>model events. Right?
>
>
If you are propagating all changes using the data binding framework
you can check for the lock token in the data validation. If you don't
get the token just deny the model update.
Achim
Achim Lörke
|
|
|
Powered by
FUDForum. Page generated in 0.05271 seconds