How to check if my object state has changed ? [message #1253585] |
Sat, 22 February 2014 12:33 |
Roger Gilliar Messages: 40 Registered: March 2010 |
Member |
|
|
So far I'm using the following code to check if my objects where changed:
EContentAdapter adapter = new EContentAdapter() {
@Override
public void notifyChanged(Notification notification) {
super.notifyChanged(notification);
eventBroker.post(CommonEvents.TOPIC_MODEL_IS_DIRTY, Boolean.TRUE);
}
};
But this is not a real solution. If the users types two character and deletes this two characters (i'm using EMF databinding) I would like to get the info that my model is not dirty anymore. Is this possible ?
[Updated on: Sat, 22 February 2014 12:38] Report message to a moderator
|
|
|
|
Re: How to check if a model is changed ? [message #1253681 is a reply to message #1253585] |
Sat, 22 February 2014 15:04 |
|
Hi, Roger,
As long as your application consistently uses Commands executed on an
EditingDomain's CommandStack to modify your model instance, then the
CommandStack tracks whether it has been changed from the last saved
state. See how the generated editor for your model implements its
"dirty" property.
HTH,
Christian
On 2014-02-22 12:33:20 +0000, Roger Gilliar said:
> So far I'm using the following code to check if a model has changed:
>
> EContentAdapter adapter = new EContentAdapter() {
> @Override
> public void notifyChanged(Notification notification) {
> super.notifyChanged(notification);
> eventBroker.post(CommonEvents.TOPIC_MODEL_IS_DIRTY, Boolean.TRUE);
> }
> };
>
> But this is not a real solution. If the users types two character and
> deletes this two characters I would like to get the info that the model
> is not dirty anymore. Is this possible ?
|
|
|
|
|
|
Re: How to check if a model is changed ? [message #1256309 is a reply to message #1256251] |
Tue, 25 February 2014 09:48 |
Ed Merks Messages: 33133 Registered: July 2009 |
Senior Member |
|
|
Felix,
Yes, the change recorder effectively remembers the original state as
state changes arrive and then at the end effectively compares the final
state to the original state to compute a description of any actual
deltas. So it is not just an event recorder...
On 25/02/2014 9:42 AM, Felix Dorner wrote:
> On 25/02/2014 05:58, Ed Merks wrote:
>> A ChangeRecorder is much like a content adapter and it's purpose is to
>> detect real value changes between the start point and the end point. But
>> as others have pointed out, in an editor (or anywhere that undo support
>> is needed), a command stack is very effective.
>
> Oh, I thought a changerecorder would not be that clever. I thought it
> simply accumulates notifications. You say it computes a "total delta"?
> I know there's a whole chapter in the book about it, so maybe I'll
> look at it again sometime.
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.02682 seconds