Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2020-08-21 18:00:25 +0000
committerLaurent Redor2020-09-21 07:29:02 +0000
commit2ba0bac52739173c96fa9cca078607c0fb21ea33 (patch)
treec291e25bbb3a39086d4f92599b3168f4521c400a
parent189b0ce500f05a64b0b816903a5808c894cd53a9 (diff)
downloadorg.eclipse.sirius-2ba0bac52739173c96fa9cca078607c0fb21ea33.tar.gz
org.eclipse.sirius-2ba0bac52739173c96fa9cca078607c0fb21ea33.tar.xz
org.eclipse.sirius-2ba0bac52739173c96fa9cca078607c0fb21ea33.zip
[566344] Correctly clean DiagramEventBroker for edges
In specific condition, with Sirius used in collaborative mode, if the connection with the server is lost, the listener added for routing style of edges is not removed during the deactivation. This commit stores the data during the activation to always removes the listener during the deactivation. Bug: 566344 Change-Id: I827b9ac3c0c84107d4736a0c6d243669845ab84c Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/AbstractDiagramEdgeEditPart.java62
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramEdgeEditPartOperation.java18
2 files changed, 72 insertions, 8 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/AbstractDiagramEdgeEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/AbstractDiagramEdgeEditPart.java
index d81a405fb8..941bbde8d7 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/AbstractDiagramEdgeEditPart.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/AbstractDiagramEdgeEditPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2019 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2008, 2020 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
@@ -45,6 +45,7 @@ import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnecti
import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
import org.eclipse.gmf.runtime.draw2d.ui.internal.routers.ITreeConnection;
import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
+import org.eclipse.gmf.runtime.notation.RoutingStyle;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.sirius.common.tools.api.util.StringUtil;
import org.eclipse.sirius.diagram.DDiagram;
@@ -125,6 +126,18 @@ public abstract class AbstractDiagramEdgeEditPart extends ConnectionNodeEditPart
private NotificationListener editModeListener = new EditStatusUpdater(this);
/**
+ * The routingStyle for which a listener is potentially added in the DiagramEventBroker during the activation of
+ * this edit part. It is used to remove the listener during deactivation.
+ */
+ private RoutingStyle routingStyle;
+
+ /**
+ * The listener added in the DiagramEventBroker for the above routingStyle during the activation of this edit part.
+ * It is used to remove the listener during deactivation.
+ */
+ private NotificationPreCommitListener routingStyleNotificationPreCommitListener;
+
+ /**
* Creates a new <code>AbstractDiagramEdgeEditPart</code>.
*
* @param view
@@ -1018,4 +1031,51 @@ public abstract class AbstractDiagramEdgeEditPart extends ConnectionNodeEditPart
}
return super.getAdapter(key);
}
+
+ /**
+ * Get the routingStyle for which a listener is added in the DiagramEventBroker during the activation of this edit
+ * part.
+ *
+ * @return the routingStyle for which a listener is added in the DiagramEventBroker during the activation
+ */
+ public RoutingStyle getRoutingStyle() {
+ return routingStyle;
+ }
+
+
+ /**
+ * Set the routing style for which a listener is added in the DiagramEventBroker during the activation of this edit
+ * part.<BR>
+ * Warning: This method is not supposed to be used elsewhere of the scope of
+ * {@link AbstractDiagramEdgeEditPart#activate()} method.
+ *
+ * @param activatedRoutingStyle
+ * the routingStyle to set
+ */
+ public void setRoutingStyle(RoutingStyle activatedRoutingStyle) {
+ this.routingStyle = activatedRoutingStyle;
+ }
+
+ /**
+ * Get the listener added in the DiagramEventBroker for the above routingStyle during the activation of this edit
+ * part.
+ *
+ * @return the listener added in the DiagramEventBroker for the above routingStyle
+ */
+ public NotificationPreCommitListener getRoutingStyleNotificationPreCommitListener() {
+ return routingStyleNotificationPreCommitListener;
+ }
+
+ /**
+ * Set the listener added in the DiagramEventBroker for the above routingStyle during the activation of this edit
+ * part.<BR>
+ * Warning: This method is not supposed to be used elsewhere of the scope of
+ * {@link AbstractDiagramEdgeEditPart#activate()} method.
+ *
+ * @param activatedRoutingStyleNotificationPreCommitListener
+ * the activatedRoutingStyleNotificationPreCommitListener to set
+ */
+ public void setRoutingStyleNotificationPreCommitListener(NotificationPreCommitListener activatedRoutingStyleNotificationPreCommitListener) {
+ this.routingStyleNotificationPreCommitListener = activatedRoutingStyleNotificationPreCommitListener;
+ }
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramEdgeEditPartOperation.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramEdgeEditPartOperation.java
index c77bfdb435..fcb90414b2 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramEdgeEditPartOperation.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramEdgeEditPartOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2017 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2007, 2020 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
@@ -431,10 +431,14 @@ public final class DiagramEdgeEditPartOperation {
* @param self
* the edge edit part.
*/
- public static void activate(final IDiagramEdgeEditPart self) {
+ public static void activate(final AbstractDiagramEdgeEditPart self) {
final DiagramEventBroker broker = DiagramEdgeEditPartOperation.getDiagramEventBroker(self);
final RoutingStyle rstyle = (RoutingStyle) self.getNotationView().getStyle(NotationPackage.eINSTANCE.getRoutingStyle());
broker.addNotificationListener(rstyle, self.getEAdapterRoutingStyle());
+ // Store the broker data to ensure to be able to remove the added listener (not possible during deactivation in
+ // example of connection lost to a server)
+ self.setRoutingStyle(rstyle);
+ self.setRoutingStyleNotificationPreCommitListener(self.getEAdapterRoutingStyle());
final IPermissionAuthority auth = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(self.getEditingDomain().getResourceSet());
auth.addAuthorityListener(self.getEditPartAuthorityListener());
self.getEditPartAuthorityListener().refreshEditMode();
@@ -446,11 +450,11 @@ public final class DiagramEdgeEditPartOperation {
* @param self
* the edge edit part.
*/
- public static void deactivate(final IDiagramEdgeEditPart self) {
- final DiagramEventBroker broker = DiagramEdgeEditPartOperation.getDiagramEventBroker(self);
- if (self.getModel() != null && self.getNotationView().getStyle(NotationPackage.eINSTANCE.getRoutingStyle()) != null) {
- final RoutingStyle rstyle = (RoutingStyle) self.getNotationView().getStyle(NotationPackage.eINSTANCE.getRoutingStyle());
- broker.removeNotificationListener(rstyle, self.getEAdapterRoutingStyle());
+ public static void deactivate(final AbstractDiagramEdgeEditPart self) {
+ // Remove the broker listener (if added in activation)
+ if (self.getRoutingStyle() != null && self.getRoutingStyleNotificationPreCommitListener() != null) {
+ final DiagramEventBroker broker = DiagramEdgeEditPartOperation.getDiagramEventBroker(self);
+ broker.removeNotificationListener(self.getRoutingStyle(), self.getRoutingStyleNotificationPreCommitListener());
}
final IPermissionAuthority auth = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(self.getEditingDomain().getResourceSet());
auth.removeAuthorityListener(self.getEditPartAuthorityListener());

Back to the top