Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF] [EMF-Databinding] Error to observe changes in Undo Command over TableViewer
[EMF] [EMF-Databinding] Error to observe changes in Undo Command over TableViewer [message #901443] Sun, 12 August 2012 12:43 Go to next message
Paco Blanco is currently offline Paco BlancoFriend
Messages: 28
Registered: June 2012
Junior Member
I have the next code:
//JFace tableViewer
TableViewer tableViewer = ....
tableViewer.setContentProvider(new ObservableListContentProvider());
WritableValue writable = new WritableValue();
writable.setValue(model);
tableViewer.setInput(EMFProperties.list(ModelPackage.Literals.MODEL__GRAPHIC_CRITERIA).observeDetail(writable));
//We have also tested with:
//tableViewer.setInput(EMFEditObservables.observeList(EVDEditionDomain.getInstance(), //(EObject) data, ModelPackage.Literals.MODEL__GRAPHIC_CRITERIA))


And I do changes in the tableViewer using commands:
List<Command> commandList = new ArrayList<Command>();
...
commandList.add(AddCommand.create(EVDEditionDomain.getInstance(), model, ModelPackage.Literals.MODEL__GRAPHIC_CRITERIA, criteriaRefreshDialog.getSelectedCriteria()));
CompoundCommand refreshmentCriteriaCommand = new CompoundCommand(commandList);				    	EVDEditionDomain.getInstance().getCommandStack().execute(refreshmentCriteriaCommand);


Model is an instance of an EMF EObject
ModelPackage.Literals.MODEL__GRAPHIC_CRITERIA is a multi-value feature around EList<Criterion> attribute
criteriaRefreshDialog.getSelectedCriteria() provides a List<Criterion> instance
EVDEditionDomain.getInstance() provides an AdapterFactoryEditingDomain instance


When I execute the code, the first time is all correct. The tableViewer is refreshed with the new additions criterion in the model. But if I execute Undo action from CommandStack, the tableViewer does not delete the contents previously added from the view. The model instance is correctly updated with the undo action.
If I execute redo action, the tableViewer is refreshed adding again the contents so the view has twice copied elements but the model instance has suitable filled. This undo/redo process can be done ad infinitum with the contents of the tableViewer growing and growing.

But if I change the code:
commandList.add(AddCommand.create(EVDEditionDomain.getInstance(), model, ModelPackage.Literals.MODEL__GRAPHIC_CRITERIA, criteriaRefreshDialog.getSelectedCriteria()));

by a EMF copy of the list:
commandList.add(AddCommand.create(EVDEditionDomain.getInstance(), model, ModelPackage.Literals.MODEL__GRAPHIC_CRITERIA, EcoreUtil.copyAll(criteriaRefreshDialog.getSelectedCriteria())));

all undo/redo actions work perfectly

Any suggestion??
Re: [EMF] [EMF-Databinding] Error to observe changes in Undo Command over TableViewer [message #901654 is a reply to message #901443] Mon, 13 August 2012 22:09 Go to previous message
Paco Blanco is currently offline Paco BlancoFriend
Messages: 28
Registered: June 2012
Junior Member
Don't worry Razz
The problem is from the underlaying persistence technology, CDO. The problem is derivated to manage objects from a View (read-only state of object graph). Curiously, the addition of these read-only elements to a list that belongs to a transaction-attached object work perfectly but the deletion of these read-only elements from the transaction-attached list does not work (the command does not throw any exception/error so the no working is owing to an internal exception that I have not debugged)
All works if the objects to add/remove to the list come from a transaction.

[Updated on: Mon, 13 August 2012 22:22]

Report message to a moderator

Previous Topic:EMF Compare - comparision throough emf compare failed [compare]
Next Topic:[CDO] java.lang.illegalStateException
Goto Forum:
  


Current Time: Sun Nov 23 06:01:56 GMT 2014

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

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