Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Daussy2019-11-20 08:00:29 +0000
committerMaxime Porhel2019-12-09 14:53:54 +0000
commitfb35d68e9e19ec82e34977cfb2a034ddff3b852e (patch)
tree487958f4236231141dc1f5ee3fb8628b687f4985
parente6838242ec9be79cb82e9aaeace56cb0965ea33b (diff)
downloadorg.eclipse.sirius-fb35d68e9e19ec82e34977cfb2a034ddff3b852e.tar.gz
org.eclipse.sirius-fb35d68e9e19ec82e34977cfb2a034ddff3b852e.tar.xz
org.eclipse.sirius-fb35d68e9e19ec82e34977cfb2a034ddff3b852e.zip
[558026] Catch new events to close the opened editor on deletion
It appears that the type of event that remove the target of DRepresentationDescriptor might defers depending on several factors. Depending, on the available bundles in the platform the removal of the target from the DRepresentation descriptor is either done by unsetting the feature (actual case) or by setting the feature to null. As we do not control in which order the notifications and the operations are done, we need to handle both events. This commit do not provide unit test because the problem occurs only when some plugins (cdo) are part of the running platform. Bug: 558026 Cherry-picked-from: 552839 Change-Id: Ie8f050176394e16d4b930fce6fdf25527594c013 Signed-off-by: Arthur Daussy <arthur.daussy@obeo.fr> Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/internal/dialect/editor/DialectEditorCloserFilter.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/internal/dialect/editor/DialectEditorCloserFilter.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/internal/dialect/editor/DialectEditorCloserFilter.java
index b6e95a14e4..69a9d3486a 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/internal/dialect/editor/DialectEditorCloserFilter.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/internal/dialect/editor/DialectEditorCloserFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2017 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2012, 2019 THALES GLOBAL SERVICES and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -72,8 +72,14 @@ public class DialectEditorCloserFilter extends NotificationFilter.Custom {
}
private boolean isTargetUnset(Notification notification) {
- boolean remove = notification.getEventType() == Notification.REMOVE || notification.getEventType() == Notification.UNSET;
- return remove && notification.getNotifier() == dRepDescriptor && notification.getFeature() == ViewpointPackage.Literals.DREPRESENTATION_DESCRIPTOR__TARGET;
+ boolean unsetNotification = isUnsetNotification(notification);
+ return unsetNotification && notification.getNotifier() == dRepDescriptor && notification.getFeature() == ViewpointPackage.Literals.DREPRESENTATION_DESCRIPTOR__TARGET;
+ }
+
+ private boolean isUnsetNotification(Notification notification) {
+ int eventType = notification.getEventType();
+ boolean setToNull = eventType == Notification.SET && notification.getNewValue() == null;
+ return setToNull || eventType == Notification.REMOVE || eventType == Notification.UNSET || eventType == Notification.REMOVE_MANY;
}
private boolean isRepresentationDeletion(Notification notification) {
@@ -96,8 +102,7 @@ public class DialectEditorCloserFilter extends NotificationFilter.Custom {
private boolean wasInOldValue(Notification notification, EObject eObject) {
boolean isCurrentDRepresentationRemove = false;
- int eventType = notification.getEventType();
- if (eventType == Notification.REMOVE || eventType == Notification.UNSET || eventType == Notification.REMOVE_MANY) {
+ if (isUnsetNotification(notification)) {
isCurrentDRepresentationRemove = isInOldValue(notification, eObject);
}
return isCurrentDRepresentationRemove;
@@ -117,7 +122,12 @@ public class DialectEditorCloserFilter extends NotificationFilter.Custom {
resolveDRepDescriptorProxy(notification);
DRepresentation representation = dRepDescriptor.getRepresentation();
if (representation instanceof DSemanticDecorator) {
- EObject target = ((DSemanticDecorator) dRepDescriptor.getRepresentation()).getTarget();
+ EObject target = ((DSemanticDecorator) representation).getTarget();
+ detachedTarget = isInOldValue(notification, target) && target.eContainer() == null;
+ } else {
+ // Get target might have been already unset by someone but since we receive all notification at once we
+ // want to close the editor as soon as we detect it has to be closed
+ EObject target = dRepDescriptor.getTarget();
detachedTarget = isInOldValue(notification, target) && target.eContainer() == null;
}
}

Back to the top