[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: How to simulate a label of a link when link and label are of different EClasses?

Hello Alex,

I tried to not upset you by asking for more specific instructions, but I spent most of these days trying to resolve it and could not make it work :(

I tried to follow your second sugestion, because I have added a derived attribute in EClass C (I'll call it "derivedCAttribute: String") which gets its value from an attribute of EClass B (I'll call it "BAttribute: String"), by an EReference "CtoB" from EClass C to EClass B. Also, there is an EReference "BtoC" which is the EOpposite of "CtoB". My tentative was:

(i) implement the method setDerivedCAttribute(String newCAttribute) in CImpl.java, making a call to eNotify:
setDerivedCAttribute(String newCAttribute) {
eNotify(new ENotificationImpl(this, Notification.SET, ???Package.C__derivedCAttribute, "", ""));
}


(ii) modify setBAttribute(String newCAttribute) in BImpl.java in order to call my implementation of the method setDerivedCAttribute:
setBAttribute(String newCAttribute) {
..
this.getBtoC().setDerivedCAttribute("");
..
}


(iii) modify notifyChanged(Notification notification) in CItemProvider.java in order to fire a notification for derivedCAttribute:
public void notifyChanged(Notification notification) {
updateChildren(notification);


switch (notification.getFeatureID(C.class)) {
..
case ???Package.C__derivedCAttribute:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
super.notifyChanged(notification);
}


(iv) implement handleNotificationEvent(Notification event) in CEditPart.java in order to properly change the label of the EClass C instance, when the associated EClass B instance has changed its BAttribute:
protected void handleNotificationEvent(Notification event) {
-code to update the label-
super.handleNotificationEvent(event);
}


So, I thought that when I change BAttribute, the setDerivedCAttribute would be called, making a notification and the method notifyChanged would send it to CEditPart.java, which would notice it by the method handleNotificationEvent and the label would be updated. But the problem is that the notification does not arrives on handleNotificationEvent. All the notifications which comes from proper EClass C attributes are working, and the other "normal" labels are fine. But, this scheme to indirectly notify instances of EClass C of changes on instances of EClass B is not working... could you help me more?

Thank you very much for your help!
Best regards,
Alessander