diff options
| author | Arthur Daussy | 2019-11-20 08:00:29 +0000 |
|---|---|---|
| committer | Maxime Porhel | 2019-12-06 11:17:14 +0000 |
| commit | be8a21ba0b76db52e9a8ae1915516d5ce57a2b86 (patch) | |
| tree | 2751704b045feb284fd69643bd024b643f75e47e | |
| parent | 8c4ca6ef6a5bd66595ded27571f65d5304e2735b (diff) | |
| download | org.eclipse.sirius-be8a21ba0b76db52e9a8ae1915516d5ce57a2b86.tar.gz org.eclipse.sirius-be8a21ba0b76db52e9a8ae1915516d5ce57a2b86.tar.xz org.eclipse.sirius-be8a21ba0b76db52e9a8ae1915516d5ce57a2b86.zip | |
[552839] 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: 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.java | 22 |
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; } } |
