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 17:55 Go to next message
Robert Brodt is currently offline Robert BrodtFriend
Messages: 618
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 18:08 Go to previous messageGo to next message
Robert Brodt is currently offline Robert BrodtFriend
Messages: 618
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 18: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 07:53 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1637
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 18:12 Go to previous messageGo to next message
Robert Brodt is currently offline Robert BrodtFriend
Messages: 618
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 14:44 Go to previous message
Robert Brodt is currently offline Robert BrodtFriend
Messages: 618
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: Sat Nov 29 04:01:31 GMT 2014

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

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