Bug 203354 - AbstractModelerPropertySection#isCurrentSelection() uses obsolete assumptions regarding deleted annotations
Summary: AbstractModelerPropertySection#isCurrentSelection() uses obsolete assumptions...
Status: RESOLVED FIXED
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: 2.0   Edit
Hardware: PC All
: P3 normal
Target Milestone: 2.0.1   Edit
Assignee: Anthony Hunter CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-13 15:47 EDT by Anthony Hunter CLA
Modified: 2010-07-19 21:59 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 Anthony Hunter CLA 2007-09-13 15:47:05 EDT
ode in the AbstractModelerPropertySection#isCurrentSelection() method uses obsolete assumptions regarding the container for deleted annotations.  In the code there is a conditional block commented as
//the annotation has been removed - check the old owner.

There are two problems with this code:

1.  The 'eventObject' in this case (the container of the EAnnotation) will not be null in 2.x but rather will be the change recorder (this is a side-effect of moving to use the change recorder in 2.x)

2.  This code doesn't check to see if the notification in question is actually on the container feature for the EAnnotation before checking the old value in the notification.

Both of these may cause incorrect behavior in properties sections.

A verson of the code that fixes both of these problems is pasted below:


	/**
	 * Determines if the page is displaying properties for this element
	 * 
	 * @param notification
	 *            The notification
	 * @param element
	 *            The element to be tested
	 * @return 'true' if the page is displaying properties for this element
	 */
	protected boolean isCurrentSelection(Notification notification,
			EObject element) {

        if (element == null)
            return false;

        if (eObjectList.contains(element))
            return true;

        if (eObjectList.size() > 0) {
            EObject eventObject = element;

            // check for annotations
            if (element instanceof EAnnotation) {
                eventObject = element.eContainer();
            } else {
                EObject container = element.eContainer();
                if (container != null && container instanceof EAnnotation) {
                    eventObject = container.eContainer();
                }
            }

            if (notification.getFeature() == EcorePackage.Literals.EANNOTATION__EMODEL_ELEMENT) {
                Object oldObj = notification.getOldValue();
                Object newObj = notification.getNewValue();
                if (oldObj instanceof EObject && newObj == null) {
                    // the annotation has been removed - check the old owner
                    eventObject = (EObject) oldObj;
                }
            }

            if (eventObject != element) {
                return eObjectList.contains(eventObject);
            }

        }
        return false;
    }
Comment 1 Anthony Hunter CLA 2007-09-13 15:58:58 EDT
Committed to R2_0_maintenance and HEAD
Comment 2 Eclipse Webmaster CLA 2010-07-19 21:59:52 EDT
[GMF Restructure] Bug 319140 : product GMF and component
Runtime was the original product and component for this bug