Bug 155581 - TextCompartmentEditPart does facilitate proper event subscription /unsubscription
Summary: TextCompartmentEditPart does facilitate proper event subscription /unsubscrip...
Status: RESOLVED FIXED
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 major
Target Milestone: 1.0.1   Edit
Assignee: Linda Damus CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2006-08-29 14:55 EDT by Natalia Balaba CLA
Modified: 2006-09-28 15:53 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Natalia Balaba CLA 2006-08-29 14:55:03 EDT
It's a bug. I am providing a fix below. In summary - it manifests in a class shape with attributes and operations (with signatutres showing) . One has to set a return type of operation or attribute type to another class or primitive type (e.g. MyClass or MyType) and then change the name of MyClass and MyType - the labels of operaions and attributes will not update. It happens because on event notification (when a new return type is assigned) the operation\attrubute is not made to listen to the changes in that new type (and old subscription , if any, is not removed either).

The fix is to the TextCompartmentEditPart.handleNotification() method :
	protected void handleNotificationEvent(Notification event) {
		Object feature = event.getFeature();
		if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)){
			Integer c = (Integer) event.getNewValue();
			setFontColor(DiagramColorRegistry.getInstance().getColor(c));
		}
		else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature))
			refreshUnderline();
		else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature))
			refreshStrikeThrough();
        else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) ||
                NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) ||
                NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) ||
                NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
			refreshFont();
		} 
		else if (isAffectingParserOptions(event)) {
			refreshParserOptions();
			refreshLabel();
		}else if (getParser() != null) {
            // if the parser happens to be sematic it should do areSematicElementsAffected as
            // a part of isAffectingEvent , then this concuction below should become unnesessary
            // see RATLC00547391
            boolean sematicsAffected = getParser() instanceof ISemanticParser
                && ((ISemanticParser) getParser()).areSemanticElementsAffected(
                    null, event);
            boolean parserAffected = getParser().isAffectingEvent(event,
                getParserOptions().intValue());

            if (sematicsAffected) {
                removeSemanticListeners();
                if (resolveSemanticElement() != null)
                    addSemanticListeners();
            }
            if (sematicsAffected || parserAffected)
                refreshLabel();
        }
        super.handleNotificationEvent(event);
    }
Comment 1 Linda Damus CLA 2006-09-05 09:52:20 EDT
Committed the proposed fix with minor modifications (comments and formatting).
Comment 2 Richard Gronback CLA 2006-09-28 15:53:01 EDT
Can Natalia please attach a patch containing what's in the comment below so that the IP log generator can find this contribution?  We've got the contributed keyword, which is great, but without an actual patch attachment by the contributor, this is missed.

Thanks!
Comment 3 Eclipse Webmaster CLA 2010-07-19 12:30:27 EDT
[GMF Restructure] Bug 319140 : product GMF and component Runtime Diagram was the original product and component for this bug