Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Send To Front/Back requires a write txn?
Send To Front/Back requires a write txn? [message #1061921] Tue, 04 June 2013 13:55 Go to next message
Robert Brodt is currently offline Robert Brodt
Messages: 539
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

Hi all,

Is it possible to change the z-order of shapes without having to use a transaction i.e. without going through PEService.sendToFront()/Back()? The use case for this is one shape partially obscured by another shape; it would be useful to send the obscured shape to the front simply by selecting it without having to use a transaction (and causing the editor to become "dirty").

In general, is there a way to make model changes that are simply NOT recorded?

Thanks,
Bob
Re: Send To Front/Back requires a write txn? [message #1061924 is a reply to message #1061921] Tue, 04 June 2013 14:08 Go to previous messageGo to next message
Robert Brodt is currently offline Robert Brodt
Messages: 539
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

Ah ha! I've found a solution!
In my DiagramContainer (or DiagramEditor for 0.9.2) I simply override selectionChanged(IWorkbenchPart,ISelection) and add this after the call to super:

	for (PictogramElement pe : getSelectedPictogramElements()) {
		if (pe instanceof ContainerShape && !(pe instanceof Diagram)) {
			final ContainerShape shape = (ContainerShape)pe;
			ContainerShape container = shape.getContainer();
			int size = container.getChildren().size();
			if (size>1)
				container.getChildren().move(size-1, shape);
		}
	}


the EList.move() method does not require a write transaction for some reason Smile

Bob

[Updated on: Tue, 04 June 2013 14:09]

Report message to a moderator

Re: Send To Front/Back requires a write txn? [message #1062137 is a reply to message #1061924] Thu, 06 June 2013 03:53 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1527
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Bob,

probably this already runs in a write transaction.

All changes to the EMF model done in a Graphiti diagram editor need a
transaction (the editor uses a transaction editing domain).

Michael
Re: Send To Front/Back requires a write txn? [message #1064328 is a reply to message #1062137] Tue, 18 June 2013 14:12 Go to previous messageGo to next message
Robert Brodt is currently offline Robert Brodt
Messages: 539
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

Hmm, I think what's happening is that the implementation (a BasicEList) doesn't send notifications about the move. In any case, it does what I need it to do...until somebody "fixes" the move() behavior Wink
UPDATE: Send To Front/Back requires a write txn? Yes, yes it does! [message #1065975 is a reply to message #1064328] Fri, 28 June 2013 10:44 Go to previous message
Robert Brodt is currently offline Robert Brodt
Messages: 539
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

The EList.move() trick is a very, very, very bad idea because it does not get recorded in the undo stack (well, duh!) The result is that an undo will affect the wrong ContainerShape because the order of children has been switched and the undo command will reverse changes on the wrong element.
Previous Topic:Highlight a PictogramElement
Next Topic:Deleting pictogram elements is slow
Goto Forum:
  


Current Time: Thu Apr 17 14:40:44 EDT 2014

Powered by FUDForum. Page generated in 0.02863 seconds