diff options
author | Nicolas FAUVERGUE | 2016-08-02 14:26:02 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-08-04 11:01:41 +0000 |
commit | 4dff83585552fbbed4fb1433e694a3006fd8cca1 (patch) | |
tree | 638c613ebd3035e60a6283da3e5b6296d62a9666 /plugins | |
parent | bfbf11f4764aebdb4f5b645e9bbb2ba72fb83186 (diff) | |
download | org.eclipse.papyrus-4dff83585552fbbed4fb1433e694a3006fd8cca1.tar.gz org.eclipse.papyrus-4dff83585552fbbed4fb1433e694a3006fd8cca1.tar.xz org.eclipse.papyrus-4dff83585552fbbed4fb1433e694a3006fd8cca1.zip |
Bug 499007: [Property][Table] NPE when deleting an element displayed in
a table with
AbstractStereotypedElementUMLSynchronizedOnFeatureAxisManager
https://bugs.eclipse.org/bugs/show_bug.cgi?id=499007
Save the resource listened in the case of removed element before its
dispose.
Change-Id: I84aa3f29174e38536c4680c0bff4ea2bcd5dc7b5
Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
Diffstat (limited to 'plugins')
2 files changed, 35 insertions, 21 deletions
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/AbstractStereotypedElementUMLSynchronizedOnFeatureAxisManager.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/AbstractStereotypedElementUMLSynchronizedOnFeatureAxisManager.java index 98e92c34f1c..90aa7d2de67 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/AbstractStereotypedElementUMLSynchronizedOnFeatureAxisManager.java +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/AbstractStereotypedElementUMLSynchronizedOnFeatureAxisManager.java @@ -9,7 +9,7 @@ * * Contributors: * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation - * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 439501 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 439501, 499007 * *****************************************************************************/ package org.eclipse.papyrus.uml.nattable.manager.axis; @@ -18,6 +18,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; @@ -56,6 +57,11 @@ public abstract class AbstractStereotypedElementUMLSynchronizedOnFeatureAxisMana * the map between the stereotypes applications and the base_element */ protected Map<EObject, Element> stereotypedElementsMap; + + /** + * The list of resources listened. + */ + protected Collection<Resource> listenedResources; /** @@ -109,7 +115,11 @@ public abstract class AbstractStereotypedElementUMLSynchronizedOnFeatureAxisMana * @return */ protected Collection<Resource> getResourceToListen() { - return Collections.singleton(getTableContext().eResource()); + if(null == this.listenedResources){ + this.listenedResources = new HashSet<Resource>(); + this.listenedResources.add(getTableContext().eResource()); + } + return this.listenedResources; } /** @@ -385,6 +395,8 @@ public abstract class AbstractStereotypedElementUMLSynchronizedOnFeatureAxisMana @Override public void dispose() { super.dispose(); + this.listenedResources.clear(); + this.listenedResources = null; this.listenerMap.clear(); this.stereotypedElementsMap.clear(); } diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/utils/UMLTableUtils.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/utils/UMLTableUtils.java index 4323ef05494..b18dd0ce960 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/utils/UMLTableUtils.java +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/utils/UMLTableUtils.java @@ -102,28 +102,30 @@ public class UMLTableUtils { // Bug 435417 : Search the properties by their qualified name instead of search by its stereotypes first // This allows to manage the inherit properties and the stereotypes in packages - final Iterator<Profile> appliedProfilesIterator = element.getNearestPackage().getAllAppliedProfiles().iterator(); - while(appliedProfilesIterator.hasNext() && null == result){ - final Profile appliedProfile = appliedProfilesIterator.next(); - - // Bug 488082 : Loop on all stereotypes (check in sub packages) - final Iterator<Stereotype> stereotypesIterator = StereotypeUtil.getAllStereotypes(appliedProfile).iterator(); - while(stereotypesIterator.hasNext() && null == result){ - final Stereotype ownedStereotype = stereotypesIterator.next(); - final Iterator<Property> propertiesIterator = ownedStereotype.getAllAttributes().iterator(); - while(propertiesIterator.hasNext() && null == result){ - final Property property = propertiesIterator.next(); - if(property.getQualifiedName().equals(propertyQN)){ - result = property; + if (null != element.getNearestPackage()){ + final Iterator<Profile> appliedProfilesIterator = element.getNearestPackage().getAllAppliedProfiles().iterator(); + while(appliedProfilesIterator.hasNext() && null == result){ + final Profile appliedProfile = appliedProfilesIterator.next(); + + // Bug 488082 : Loop on all stereotypes (check in sub packages) + final Iterator<Stereotype> stereotypesIterator = StereotypeUtil.getAllStereotypes(appliedProfile).iterator(); + while(stereotypesIterator.hasNext() && null == result){ + final Stereotype ownedStereotype = stereotypesIterator.next(); + final Iterator<Property> propertiesIterator = ownedStereotype.getAllAttributes().iterator(); + while(propertiesIterator.hasNext() && null == result){ + final Property property = propertiesIterator.next(); + if(property.getQualifiedName().equals(propertyQN)){ + result = property; + } } } } - } - - // 2. if not, the profile could be applied on a sub-package of the nearest package - /* the table can show element which are not children of its context, so the profile could not be available in its context */ - if(null == result){ - result = getProperty(element.getNearestPackage().getNestedPackages(), propertyQN); + + // 2. if not, the profile could be applied on a sub-package of the nearest package + /* the table can show element which are not children of its context, so the profile could not be available in its context */ + if(null == result){ + result = getProperty(element.getNearestPackage().getNestedPackages(), propertyQN); + } } } return result; |