summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Wouters2014-01-14 11:04:54 (EST)
committerLaurent Wouters2014-01-15 03:59:29 (EST)
commit0e1f9f4559e168ef250009587d834e783bb5fdf7 (patch)
treecdef6b6b2c2986b6990a5b6df24a493c31048609
parenteab7ff81dbf2eec27075dd51a7700d2884f32766 (diff)
downloadorg.eclipse.papyrus-0e1f9f4559e168ef250009587d834e783bb5fdf7.zip
org.eclipse.papyrus-0e1f9f4559e168ef250009587d834e783bb5fdf7.tar.gz
org.eclipse.papyrus-0e1f9f4559e168ef250009587d834e783bb5fdf7.tar.bz2
425584: [Component Diagram] Usage and Realization Links are solid (should be dashed)
Fixed a conflict between the custom style of an edge and the built-in dashed edge implementation https://bugs.eclipse.org/bugs/show_bug.cgi?id=425584 Change-Id: Ie27870223a448ff2ef2a137fcf1c289d3ab65b2a Signed-off-by: Laurent Wouters <laurent.wouters@cea.fr>
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/ConnectionEditPart.java55
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/edge/PapyrusEdgeFigure.java24
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/edge/DashedEdgeFigure.java8
3 files changed, 44 insertions, 43 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/ConnectionEditPart.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/ConnectionEditPart.java
index 973d934..8c916fd 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/ConnectionEditPart.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/ConnectionEditPart.java
@@ -15,13 +15,13 @@ import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
import org.eclipse.gmf.runtime.notation.Connector;
import org.eclipse.gmf.runtime.notation.IntValueStyle;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.StringValueStyle;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusConnectionEndEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.edge.PapyrusEdgeFigure;
/**
@@ -56,14 +56,16 @@ public abstract class ConnectionEditPart extends ConnectionNodeEditPart implemen
super.refresh();
IFigure figure = this.getFigure();
Object model = this.getModel();
- if (figure instanceof PolylineConnectionEx && model instanceof Connector) {
+ if (figure instanceof PapyrusEdgeFigure && model instanceof Connector) {
Connector connector = (Connector) model;
- PolylineConnectionEx polyline = (PolylineConnectionEx) figure;
+ PapyrusEdgeFigure edge = (PapyrusEdgeFigure) figure;
String lineStyle = extract((StringValueStyle) connector.getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), LINE_STYLE));
int lineDashLength = extract((IntValueStyle) connector.getNamedStyle(NotationPackage.eINSTANCE.getIntValueStyle(), LINE_DASH_LENGTH));
int lineDashGap = extract((IntValueStyle) connector.getNamedStyle(NotationPackage.eINSTANCE.getIntValueStyle(), LINE_DASH_GAP));
if (lineStyle != null) {
- setupLineStyle(polyline, lineStyle, connector.getLineWidth(), lineDashLength, lineDashGap);
+ setupLineStyle(edge, lineStyle, connector.getLineWidth(), lineDashLength, lineDashGap);
+ } else {
+ edge.resetStyle();
}
}
}
@@ -97,9 +99,9 @@ public abstract class ConnectionEditPart extends ConnectionNodeEditPart implemen
}
/**
- * Setups the line style of the polyline according to the given CSS style
+ * Setups the line style of the edge according to the given CSS style
*
- * @param polyline
+ * @param edge
* The shape to setup
* @param style
* The CSS style
@@ -110,31 +112,32 @@ public abstract class ConnectionEditPart extends ConnectionNodeEditPart implemen
* @param lineDashGap
* Length of the gap between dashes
*/
- private void setupLineStyle(PolylineConnectionEx polyline, String style, int originalWidth, int lineDashLength, int lineDashGap) {
+ private void setupLineStyle(PapyrusEdgeFigure edge, String style, int originalWidth, int lineDashLength, int lineDashGap) {
if ("none".equals(style)) {
- polyline.setLineStyle(Graphics.LINE_SOLID);
- polyline.setLineWidth(0);
- polyline.setVisible(false);
- } else if ("hidden".equals(style)) {
- polyline.setLineStyle(Graphics.LINE_SOLID);
- polyline.setLineWidth(0);
- polyline.setVisible(false);
- } else if ("dotted".equals(style)) {
- polyline.setLineStyle(Graphics.LINE_DOT);
- polyline.setLineWidth(originalWidth);
- } else if ("dashed".equals(style)) {
- polyline.setLineStyle(Graphics.LINE_DASH);
- polyline.setLineWidth(originalWidth);
- polyline.setLineDash(new int[] { lineDashLength, lineDashGap });
- } else if ("solid".equals(style)) {
- polyline.setLineStyle(Graphics.LINE_SOLID);
- polyline.setLineWidth(originalWidth);
- } else if ("double".equals(style)) {
- polyline.setLineWidth(originalWidth * 2);
+ edge.resetStyle();
+ } else {
+ if ("hidden".equals(style)) {
+ edge.setLineStyle(Graphics.LINE_SOLID);
+ edge.setLineWidth(0);
+ edge.setVisible(false);
+ } else if ("dotted".equals(style)) {
+ edge.setLineStyle(Graphics.LINE_DOT);
+ edge.setLineWidth(originalWidth);
+ } else if ("dashed".equals(style)) {
+ edge.setLineStyle(Graphics.LINE_CUSTOM);
+ edge.setLineWidth(originalWidth);
+ edge.setLineDash(new int[] { lineDashLength, lineDashGap });
+ } else if ("solid".equals(style)) {
+ edge.setLineStyle(Graphics.LINE_SOLID);
+ edge.setLineWidth(originalWidth);
+ } else if ("double".equals(style)) {
+ edge.setLineWidth(originalWidth * 2);
+ }
}
}
+
/**
*
* @see org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart#createDefaultEditPolicies()
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/edge/PapyrusEdgeFigure.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/edge/PapyrusEdgeFigure.java
index 7482681..a34311e 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/edge/PapyrusEdgeFigure.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/edge/PapyrusEdgeFigure.java
@@ -51,11 +51,6 @@ public abstract class PapyrusEdgeFigure extends PolylineConnectionEx {
private int bendpointDiameter;
/**
- * Data of the dash style
- */
- private int[] lineDashData;
-
- /**
*
* Constructor.
*
@@ -63,14 +58,6 @@ public abstract class PapyrusEdgeFigure extends PolylineConnectionEx {
public PapyrusEdgeFigure() {
super();
setBendPointDiameter(7);
- lineDashData = null;
- }
-
- /**
- * @see org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx#setLineDash(int[])
- */
- public void setLineDash(int[] data) {
- lineDashData = data;
}
/**
@@ -81,15 +68,18 @@ public abstract class PapyrusEdgeFigure extends PolylineConnectionEx {
* @param g
*/
protected void outlineShape(Graphics g) {
- g.setLineStyle(getLineStyle());
- if (getLineStyle() == Graphics.LINE_DASH) {
- g.setLineDash(lineDashData);
- }
super.outlineShape(g);
drawConnectionPoint(g);
}
/**
+ * Resets the style of this figure to its default implementation
+ */
+ public void resetStyle() {
+
+ }
+
+ /**
*
* @param g
*
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/edge/DashedEdgeFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/edge/DashedEdgeFigure.java
index a5e45b0..bb24dc6 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/edge/DashedEdgeFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/edge/DashedEdgeFigure.java
@@ -91,6 +91,14 @@ public class DashedEdgeFigure extends UMLEdgeFigure {
}
/**
+ * Resets the style of this figure to its default implementation
+ */
+ @Override
+ public void resetStyle() {
+ setStyle();
+ }
+
+ /**
* Sets initial Style for the figure. It does not give any special Color for
* Background and Foreground. This is the style used for classic arrows:
* ------>