Merge "Optimization for slow UML element creation"
diff --git a/cdo/bundles/uml/org.eclipse.uml2.uml.cdo/src/org/eclipse/uml2/uml/cdo/internal/impl/ElementImpl.java b/cdo/bundles/uml/org.eclipse.uml2.uml.cdo/src/org/eclipse/uml2/uml/cdo/internal/impl/ElementImpl.java
index 01c273e..6c780a2 100644
--- a/cdo/bundles/uml/org.eclipse.uml2.uml.cdo/src/org/eclipse/uml2/uml/cdo/internal/impl/ElementImpl.java
+++ b/cdo/bundles/uml/org.eclipse.uml2.uml.cdo/src/org/eclipse/uml2/uml/cdo/internal/impl/ElementImpl.java
@@ -900,11 +900,12 @@
public NotificationChain eBasicSetContainer(InternalEObject newContainer,
int newContainerFeatureID, NotificationChain msgs) {
+ InternalEObject oldContainer = eInternalContainer();
+
if (eDirectResource() != null && newContainer != null
&& eContainmentFeature(this, newContainer,
newContainerFeatureID) == null) {
- InternalEObject oldContainer = eInternalContainer();
int oldContainerFeatureID = eContainerFeatureID();
eBasicSetContainer(newContainer, newContainerFeatureID);
@@ -944,15 +945,19 @@
msgs);
}
- if (newContainer != null && (CHANGE_DESCRIPTION_CLASS == null
- || !(CHANGE_DESCRIPTION_CLASS.isInstance(newContainer)))) {
+ if (CHANGE_DESCRIPTION_CLASS == null
+ || !(CHANGE_DESCRIPTION_CLASS.isInstance(newContainer))) {
Resource.Internal eInternalResource = eInternalResource();
-
if (eInternalResource == null || !eInternalResource.isLoading()) {
- ElementOperations.unapplyAllNonApplicableStereotypes(this,
- false);
- ElementOperations.applyAllRequiredStereotypes(this, false);
+
+ if (oldContainer != null) {
+ ElementOperations.unapplyAllNonApplicableStereotypes(this, false);
+ }
+
+ if (newContainer != null) {
+ ElementOperations.applyAllRequiredStereotypes(this, false);
+ }
}
}