Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 318383

Summary: Sash and Stack not updated if model is modified - Renderer
Product: [Eclipse Project] e4 Reporter: Lars Vogel <Lars.Vogel>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: emoffatt, Lars.Vogel, remy.suen, tom.schindl
Version: unspecified   
Target Milestone: 1.0 RC3   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Lars Vogel CLA 2010-06-29 17:15:49 EDT
If I add "org.eclipse.e4.tools.emf.liveeditor" to my e4 application I can directly edit the live model of the running application. 


Unfortunately changes in the order of parts are not reflected. Example: Create an e4 application with 2 part in one stack -> run it and try to change the order via the live model editor.
Comment 1 Lars Vogel CLA 2010-06-29 17:17:44 EDT
Talked with Tom via IRC, this seems to be a problem of the renderer.
Comment 2 Lars Vogel CLA 2010-06-29 17:20:19 EDT
The problem exists for both sash and stack.
Comment 3 Remy Suen CLA 2010-06-29 17:54:44 EDT
This is probably because there are no event handlers for a "move" operation?
Comment 4 Eric Moffatt CLA 2010-07-13 09:34:23 EDT
I think that this would work if the 'move' were broken down into a 'remove' followed by an 'add(index)'...we can look into an optimized 'move' later...

Tom, if the editor isn't using this implementation of 'move' could you modify it so that it does and see if this issue is 'fixed' ?
Comment 5 Thomas Schindl CLA 2010-07-13 09:39:21 EDT
... well the editor is only doing an add() on the final destination because this is an implicit remove on the source feature. 

If I get your request right you want me to call remove on the source and an add on the target?
Comment 6 Thomas Schindl CLA 2010-07-17 06:28:56 EDT
Eric, I've now tried to reorder inside a Stack using ModelService#move() but this fails when moving inside a the same Container.

-------8<-------
java.lang.IllegalArgumentException: The 'no duplicates' constraint is violated
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:342)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.move(ModelServiceImpl.java:301)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.move(ModelServiceImpl.java:284)
	at org.eclipse.e4.tools.emf.ui.common.Util.moveElementByIndex(Util.java:91)
-------8<-------

The call looks like this:
------8<------
public static boolean moveElementByIndex(EModelService modelService, MUIElement element, int index) {
		modelService.move(element, element.getParent(), index);
		return true;
	}
------8<------

I also think that our ModelServiceImpl.move can fail with an IndexOutOfBoundsException when the index passed is too high (I think you should check the index value passed in!)
Comment 7 Thomas Schindl CLA 2010-07-17 06:41:51 EDT
One more note on this I think remove/add is a very bad thing in case of reordering inside a container because it mean dispose/create.

The EventSystem should simply support Notification.MOVE which means a reordering in the SAME List => no dispose/recreate needed!
Comment 8 Thomas Schindl CLA 2010-07-17 07:01:34 EDT
Ok. The comment about dispose/recreate is not correct, I've now checked in a new a fix for Stacks
Comment 9 Thomas Schindl CLA 2010-07-17 07:28:09 EDT
I've now switched the implementation for ALL ElementContainers and the Drag&Drop