Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to access contentChild of AddContentChildOperation
How to access contentChild of AddContentChildOperation [message #1794659] Tue, 04 September 2018 15:25 Go to next message
João Pedro is currently offline João PedroFriend
Messages: 28
Registered: December 2014
Junior Member
When I undo/redo, the parts are in fact graphically deleted/re-drew but the data behind is still there. A connection can be erased when performing an "undo" action, but if you check "target.getContent().getIncomingConnections()" it's still there.

In my case, if within each new node I add the node's model to a session within my app, when I undo the operation I need to manually erase that same model from my app's session. For that purpose I need to access the contentChild of the AddContentChildOperation (and from RemoveContentChildOperation)

One thing that is confusing me is: what's the way of accessing the contentChild? I'm doing it like this in the "addOpertionHistoryListener(..)" for now but it must be wrong:


                               Optional<ITransactionalOperation> tmpOp = containsOperation(op3.getOperations(),ReverseUndoCompositeOperation.class.getName());
				if(tmpOp.isPresent()) {
					ReverseUndoCompositeOperation op4 = (ReverseUndoCompositeOperation) tmpOp.get();
					Optional<ITransactionalOperation> tmp2 = containsOperation(op4.getOperations(),AddContentChildOperation.class.getName());
					if(tmp2.isPresent()) {
						AddContentChildOperation contentChildOp = (AddContentChildOperation) tmp2.get();
						System.out.println(contentChildOp);
						Field f;
						try {
							f = contentChildOp.getClass().getDeclaredField("contentChild");
							f.setAccessible(true);
							if(f.getType() == Object.class) {
								MapNode tmp5 = (MapNode) f.get(contentChildOp);
								currentSessionClone.removeModel(tmp5.getModel());
							}
						} catch (NoSuchFieldException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						} catch (SecurityException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						} catch (IllegalArgumentException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						} catch (IllegalAccessException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
					}
				}
Re: How to access contentChild of AddContentChildOperation [message #1794771 is a reply to message #1794659] Thu, 06 September 2018 09:43 Go to previous message
João Pedro is currently offline João PedroFriend
Messages: 28
Registered: December 2014
Junior Member
I discovered the answer with a bit of help. The problem is that I was looking at this from the wrong angle.

If I want do perform extra operations on the contentChild I should do them in the corresponding "protected void doAddContentChild(Object contentChild, int index)"
and "protected void doRemoveContentChild(Object contentChild)" functions, which are overridden from the AbstractContentPart class.

Thank you @Matthias for the help.

[Updated on: Thu, 06 September 2018 09:43]

Report message to a moderator

Previous Topic:GEF/ZEST more complex examples/projects
Next Topic:Update not drawn
Goto Forum:
  


Current Time: Fri Nov 16 17:45:05 GMT 2018

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

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

Back to the top