Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Le Menez2016-05-03 16:05:38 +0000
committerGerrit Code Review @ Eclipse.org2016-05-09 08:34:19 +0000
commit214690565f28a6d2018c0df0f325644d86d2beb1 (patch)
tree5ea2e23c7c51dd68c23c8a5c71bc1b347ab057cc
parent6251fb835df733dcbc85b2f908e5273da549a635 (diff)
downloadorg.eclipse.papyrus-214690565f28a6d2018c0df0f325644d86d2beb1.tar.gz
org.eclipse.papyrus-214690565f28a6d2018c0df0f325644d86d2beb1.tar.xz
org.eclipse.papyrus-214690565f28a6d2018c0df0f325644d86d2beb1.zip
Bug 488286 - [CSS][Diagram] Missing refresh in some cases when using label filters
https://bugs.eclipse.org/bugs/show_bug.cgi?id=488286 - Added a refresh to the handleNotificationEvent method in the PapyrusLabelEditPart.java Change-Id: I7bfbfb3686fd3b39ff898cabfe7c6e486b8e0261 Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java60
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/NamedStyleProperties.java3
2 files changed, 49 insertions, 14 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java
index 3e0d1bbdb2d..309ba67d5e0 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java
@@ -27,6 +27,8 @@ import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
@@ -361,6 +363,35 @@ public abstract class PapyrusLabelEditPart extends LabelEditPart implements Name
}
/**
+ * Refresh the diagram when changing the label filters (Bug 488286 - [CSS][Diagram] Missing refresh in some cases when using label filters)
+ *
+ * @since 2.0
+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart#handleNotificationEvent(org.eclipse.emf.common.notify.Notification)
+ *
+ * @param notification
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ super.handleNotificationEvent(notification);
+
+ Object notifier = notification.getNotifier();
+ Object oldValue = notification.getOldValue();
+ // DO
+ if (notifier instanceof EAnnotation) {
+ if (((EAnnotation) notifier).getSource().equalsIgnoreCase(NamedStyleProperties.CSS_FORCE_VALUE)) {
+ super.refresh();
+ }
+ }
+ // UNDO
+ else if (oldValue instanceof EAnnotation) {
+ if (((EAnnotation) oldValue).getSource().equalsIgnoreCase(NamedStyleProperties.CSS_FORCE_VALUE)) {
+ super.refresh();
+ }
+ }
+
+ }
+
+ /**
* @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#removeNotationalListeners()
*
*/
@@ -465,31 +496,32 @@ public abstract class PapyrusLabelEditPart extends LabelEditPart implements Name
return super.getAdapter(key);
}
+ @Override
public Point getReferencePoint() {
if (getParent() instanceof AbstractConnectionEditPart) {
switch (getKeyPoint()) {
- case ConnectionLocator.TARGET:
- return calculateRefPoint(LabelViewConstants.SOURCE_LOCATION);
- case ConnectionLocator.SOURCE:
- return calculateRefPoint(LabelViewConstants.TARGET_LOCATION);
- case ConnectionLocator.MIDDLE:
- return calculateRefPoint(LabelViewConstants.MIDDLE_LOCATION);
- default:
- return calculateRefPoint(LabelViewConstants.MIDDLE_LOCATION);
+ case ConnectionLocator.TARGET:
+ return calculateRefPoint(LabelViewConstants.SOURCE_LOCATION);
+ case ConnectionLocator.SOURCE:
+ return calculateRefPoint(LabelViewConstants.TARGET_LOCATION);
+ case ConnectionLocator.MIDDLE:
+ return calculateRefPoint(LabelViewConstants.MIDDLE_LOCATION);
+ default:
+ return calculateRefPoint(LabelViewConstants.MIDDLE_LOCATION);
}
- }
-
- return ((AbstractGraphicalEditPart)getParent()).getFigure().getBounds().getTopLeft();
+ }
+
+ return ((AbstractGraphicalEditPart) getParent()).getFigure().getBounds().getTopLeft();
}
private Point calculateRefPoint(int percent) {
if (getParent() instanceof AbstractConnectionEditPart) {
- PointList ptList = ((Connection)((ConnectionEditPart)getParent()).getFigure()).getPoints();
+ PointList ptList = ((Connection) ((ConnectionEditPart) getParent()).getFigure()).getPoints();
Point refPoint = PointListUtilities.calculatePointRelativeToLine(ptList, 0, percent, true);
return refPoint;
} else if (getParent() instanceof GraphicalEditPart) {
- return ((AbstractGraphicalEditPart)getParent()).getFigure().getBounds().getTopLeft();
+ return ((AbstractGraphicalEditPart) getParent()).getFigure().getBounds().getTopLeft();
}
- return null;
+ return null;
}
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/NamedStyleProperties.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/NamedStyleProperties.java
index 7eb05eea274..7457b9bc70f 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/NamedStyleProperties.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/NamedStyleProperties.java
@@ -153,4 +153,7 @@ public interface NamedStyleProperties {
/** The port position namedStyle property */
public static final String PORT_POSITION = "portPosition"; //$NON-NLS-1$
+ /* Label used to identify the forced CSS values */
+ public static final String CSS_FORCE_VALUE = "PapyrusCSSForceValue"; // $NON-NLS-1$
+
}

Back to the top