Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Databinding/Undo/Redo
EMF Databinding/Undo/Redo [message #644264] Fri, 10 December 2010 10:07 Go to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Hello,

i have a problem with the EMF Databinding and Undo/Redo support.
If the the User enter text in der textfield1, textfield2 should automaticlly fill with a value.
But in the ModifyListener the model value is wrong. Its the oldValue before the text is entered.

If i update all Models (bindingContext.updateModels()), i have for every model attribute a undo/event. In my case 4 thats really ugly.
So what is worng?

	private void bindValue(){
		DataBindingContext bindingContext = new EMFDataBindingContext();
		bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(textfield1),
				EMFProperties.value(MyObjectPackage.Literals.OBJECT__ATT1).observe(myObject));
		bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(textfield2),
				EMFProperties.value(MyObjectPackage.Literals.OBJECT__ATT1).observe(myObject));
		bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(textfield3),
				EMFProperties.value(MyObjectPackage.Literals.OBJECT__ATT3).observe(myObject));
		bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(textfield4),
				EMFProperties.value(MyObjectPackage.Literals.OBJECT__ATT4).observe(myObject));
	textfield1.addModifyListener(new ModifyListener() {
		
		@Override
		public void modifyText(ModifyEvent e) {
//			bindingContext.updateModels();

                        // Att1 wrong model value
			Double double1 = myObject.getAtt1() * 0.66;
			myObject.setAtt2(double1);
			
		}
	});

	}


2. Or shoudl the model register a Adapter/Listener for attribut1 instead of a ModifyListener?

Thanks =)
Re: EMF Databinding/Undo/Redo [message #644276 is a reply to message #644264] Fri, 10 December 2010 10:40 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
If you'd remember the observable create with
EMFProperties.value(MyObjectPackage.Literals.OBJECT__ATT1) you can bind
OBJECT__ATT1 to OBJECT__ATT2 and simply but an converter between.

Them beside that it looks like OBJECT__ATT2 is a derived value but I
could be wrong.

Tom

Am 10.12.10 11:07, schrieb SirWayne:
> Hello,
>
> i have a problem with the EMF Databinding and Undo/Redo support.
> If the the User enter text in der textfield1, textfield2 should
> automaticlly fill with a value.
> But in the ModifyListener the model value is wrong. Its the oldValue
> before the text is entered.
>
> If i update all Models (bindingContext.updateModels()), i have for every
> model attribute a undo/event. In my case 4 thats really ugly.
> So what is worng?
>
>
> private void bindValue(){
> DataBindingContext bindingContext = new EMFDataBindingContext();
>
> bindingContext.bindValue(WidgetProperties.text(SWT.Modify).o bserve(textfield1),
>
>
> EMFProperties.value(MyObjectPackage.Literals.OBJECT__ATT1).o bserve(myObject));
>
>
> bindingContext.bindValue(WidgetProperties.text(SWT.Modify).o bserve(textfield2),
>
>
> EMFProperties.value(MyObjectPackage.Literals.OBJECT__ATT1).o bserve(myObject));
>
>
> bindingContext.bindValue(WidgetProperties.text(SWT.Modify).o bserve(textfield3),
>
>
> EMFProperties.value(MyObjectPackage.Literals.OBJECT__ATT3).o bserve(myObject));
>
>
> bindingContext.bindValue(WidgetProperties.text(SWT.Modify).o bserve(textfield4),
>
>
> EMFProperties.value(MyObjectPackage.Literals.OBJECT__ATT4).o bserve(myObject));
>
> textfield1.addModifyListener(new ModifyListener() {
>
> @Override
> public void modifyText(ModifyEvent e) {
> // bindingContext.updateModels();
>
> // Att1 wrong model value
> Double double1 = myObject.getAtt1() * 0.66;
> myObject.setAtt2(double1);
>
> }
> });
>
> }
>
>
> 2. Or shoudl the model register a Adapter/Listener for attribut1 instead
> of a ModifyListener?
>
> Thanks =)
Re: EMF Databinding/Undo/Redo [message #644312 is a reply to message #644276] Fri, 10 December 2010 13:49 Go to previous message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
How would you implement the converter?

attr2 have a own textfield where the user can enter text/values or it is filled by the attr1 (but the value have to calculated with differents value)
Previous Topic:accessing a genmodel programmatically
Next Topic:Ecore2Java NPE during generation
Goto Forum:
  


Current Time: Sat Apr 27 03:42:17 GMT 2024

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

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

Back to the top