Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Notify associated element
Notify associated element [message #987448] Mon, 26 November 2012 16:17 Go to next message
Matthias N is currently offline Matthias NFriend
Messages: 65
Registered: June 2012
Member
Hi,

I have the following scenario:

+-----------+                 +----------+
| Parent    |1               *| Children |
|           |-----------------|          |
+-----------+                 +----------+
A Parent is associated with several children (Note: NO containment reference)


What I want to do is the following:

When one of the parent's attributes changes, the children shall be notified.

I implemented handleNotificationEvent in parentEditPart:

@Override
 protected void handleNotificationEvent(Notification notification) {
  super.handleNotificationEvent(notification);
  //something has changed, notify my associated Children
  Parent parent = (Parent) this.resolveSemanticElement();
  for (Children c : parent.getChildren()) {
   c.eNotify(notification);
  }		
 }


And I am awaiting the Notification in ChildrenEditPart:
@Override
 protected void handleNotificationEvent(Notification notification) {
  super.handleNotificationEvent(notification);
  system.out.println("something has changed, update myself!!");	
 }



However it does not work, I get:
java.lang.StackOverflowError
	at org.eclipse.emf.transaction.impl.TransactionImpl.commit(TransactionImpl.java:474)
	at org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory$DiagramEditingDomain.postcommit(DiagramEditingDomainFactory.java:220)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.deactivate(TransactionalEditingDomainImpl.java:543)
	at org.eclipse.emf.transaction.impl.TransactionImpl.close(TransactionImpl.java:712)
	at org.eclipse.emf.transaction.impl.TransactionImpl.commit(TransactionImpl.java:474)
	at org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory$DiagramEditingDomain.postcommit(DiagramEditingDomainFactory.java:220)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.deactivate(TransactionalEditingDomainImpl.java:543)
	at org.eclipse.emf.transaction.impl.TransactionImpl.close(TransactionImpl.java:712)
	at org.eclipse.emf.transaction.impl.TransactionImpl.commit(TransactionImpl.java:474)
	at org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory$DiagramEditingDomain.postcommit(DiagramEditingDomainFactory.java:220)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.deactivate(TransactionalEditingDomainImpl.java:543)
	at org.eclipse.emf.transaction.impl.TransactionImpl.close(TransactionImpl.java:712)
	at org.eclipse.emf.transaction.impl.TransactionImpl.commit(TransactionImpl.java:474)
...

Re: Notify associated element [message #987455 is a reply to message #987448] Mon, 26 November 2012 16:53 Go to previous message
Andreas Muelder is currently offline Andreas MuelderFriend
Messages: 71
Registered: July 2011
Member
Hi Matthias,

I had a similar usecase and I did it the other way arround.

I added the listener to Parent in my ChildEditPart like this:

@Override
protected void addSemanticListeners() {
	addListenerFilter(PARENT_VIEW, this, ((Child) resolveSemanticElement()).getParent);
	super.addSemanticListeners();
}

@Override
protected void removeSemanticListeners() {
	removeListenerFilter(PARENT_VIEW);
	super.removeSemanticListeners();
	}


Regards,

Andreas


Previous Topic:get business object from editpart
Next Topic:Generator overwriting extension point definitions
Goto Forum:
  


Current Time: Mon Nov 24 03:58:51 GMT 2014

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

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