Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2015-07-07 09:55:10 +0000
committerGerrit Code Review @ Eclipse.org2016-02-19 15:01:57 +0000
commita1c2c13a0a2e6334ca3330323ea3e99369486b86 (patch)
tree576e403c407a3530e8396c89360524815341a3c4
parent01202e23241dd2801b5e30a5646d7352d1717fdf (diff)
downloadorg.eclipse.papyrus-a1c2c13a0a2e6334ca3330323ea3e99369486b86.tar.gz
org.eclipse.papyrus-a1c2c13a0a2e6334ca3330323ea3e99369486b86.tar.xz
org.eclipse.papyrus-a1c2c13a0a2e6334ca3330323ea3e99369486b86.zip
Bug 471444: [Diagram] Background Color of name from generic shape shall
be customisable https://bugs.eclipse.org/bugs/show_bug.cgi?id=471444 + some little fix and default value on base.css + adds regression test + adds nameBackgroundColor to css autocompletion Change-Id: I3f22dbb067f58db31fa20ed18b725a6568bcbba9 Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/resources/base.css37
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/contentassist/CustomCSSProposalProvider.java3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/BorderDisplayEditPolicy.java4
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/IRoundedRectangleFigure.java16
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/RoundedRectangleNodePlateFigure.java22
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/PapyrusRoundedEditPartHelper.java23
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/NamedStyleProperties.java7
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/figures/InterruptibleActivityRegionFigure.java20
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java17
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/RoundedCompartmentFigure.java386
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/ShapeCustomisationTest.java65
12 files changed, 464 insertions, 138 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/resources/base.css b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/resources/base.css
index d0e8bc4f33e..0fc836d0e49 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/resources/base.css
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/resources/base.css
@@ -29,5 +29,42 @@ Compartment[kind=symbol]{
fontColor:black;
transparency:0; /* Default transparency in GMF Notation is -1. -1 is recognized as "Unchanged" by the GMF NodeFigure. e.g. changing from 50 to -1 ("reset") does nothing */
showTitle:false;
+ textAlignment:"center";
+ shadowWidth:5;
+ borderStyle:"solid";
+ customDash:5 5;
+ useOriginalColors:true;
+ nameBackgroundColor:"-1";
+ }
+
+Label,
+Model,
+Package,
+Profile{
+ textAlignment:"left";
+}
+
+Label{
+ position:"left";
+}
+
+Label[kind="FloatingLabel"]{
+ maskLabel:"name";
+}
+
+Port{
+ portPosition:"onLine";
+}
+
+Model,
+Package,
+Profile{
+ isPackage:true;
+}
+
+Compartment{
+ linePosition:"center";
+ lineLengthRatio:"1.0";
+ lineLength:-1;
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/contentassist/CustomCSSProposalProvider.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/contentassist/CustomCSSProposalProvider.java
index 4c6d6a484b8..eebbf3e6327 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/contentassist/CustomCSSProposalProvider.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/contentassist/CustomCSSProposalProvider.java
@@ -254,7 +254,7 @@ public class CustomCSSProposalProvider extends AbstractCSSProposalProvider {
NamedStyleProperties.LABEL_OFFSET_X,
NamedStyleProperties.LABEL_OFFSET_Y,
NamedStyleProperties.LEFT_MARGIN_PROPERTY,
- NamedStyleProperties.LENGTH,
+ NamedStyleProperties.LINE_LENGTH,
NamedStyleProperties.LINE_CUSTOM_VALUE,
NamedStyleProperties.LINE_LENGTH_RATIO,
NamedStyleProperties.LINE_POSITION,
@@ -269,6 +269,7 @@ public class CustomCSSProposalProvider extends AbstractCSSProposalProvider {
NamedStyleProperties.TOP_MARGIN_PROPERTY,
NamedStyleProperties.USE_ORIGINAL_COLORS,
NamedStyleProperties.WRAP_NAME,
+ NamedStyleProperties.NAME_BACKGROUND_COLOR
};
return Arrays.asList(properties);
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/BorderDisplayEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/BorderDisplayEditPolicy.java
index 79be6d3311b..306b014a6c4 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/BorderDisplayEditPolicy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/BorderDisplayEditPolicy.java
@@ -211,8 +211,8 @@ public class BorderDisplayEditPolicy extends GraphicalEditPolicyEx implements IC
// Set OneLineResizableBorder as border
getPrimaryShape().setBorder(defaultBorder);
// If a length or a length ratio is defined in notation or CSS
- ((OneTopLineResizableBorder) defaultBorder).setLength(NotationUtils.getIntValue(view, LENGTH, DEFAULT_LENGTH_VALUE));
- ((OneTopLineResizableBorder) defaultBorder).setLengthRatio(new Float(NotationUtils.getStringValue(view, LINE_LENGTH_RATIO, LINE_LENGTH_RATIO_DEFAULT_VALUE)));
+ ((OneTopLineResizableBorder) defaultBorder).setLength(NotationUtils.getIntValue(view, LINE_LENGTH, DEFAULT_LENGTH_VALUE));
+ ((OneTopLineResizableBorder) defaultBorder).setLengthRatio(new Float(NotationUtils.getStringValue(view, LINE_LENGTH_RATIO, LINE_LENGTH_RATIO_DEFAULT_VALUE).replace(',', '.')));// $NON-NLS-1$ //$NON-NLS-2$
((OneTopLineResizableBorder) defaultBorder).setLinePosition(getlinePosition());
// If it's the first one, set border to null.
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/IRoundedRectangleFigure.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/IRoundedRectangleFigure.java
index c1bfdc8da0c..e2ce1fef13b 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/IRoundedRectangleFigure.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/IRoundedRectangleFigure.java
@@ -156,4 +156,20 @@ public interface IRoundedRectangleFigure extends IFigure {
*/
public void setShadowColor(String shadowColor);
+
+ /**
+ * Gets the Name Background color.
+ *
+ * @return the Label BackgroundColor
+ */
+ public String getNameBackgroundColor();
+
+ /**
+ * Sets the Label Background color.
+ *
+ * @param shadowColor
+ * the LabelBackgroundColor to set
+ */
+ public void setNameBackgroundColor(String nameBackgroundColor);
+
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/RoundedRectangleNodePlateFigure.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/RoundedRectangleNodePlateFigure.java
index d8638947696..5d81041df22 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/RoundedRectangleNodePlateFigure.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/RoundedRectangleNodePlateFigure.java
@@ -309,4 +309,26 @@ public class RoundedRectangleNodePlateFigure extends DefaultSizeNodeFigure imple
public void setShadowColor(String shadowColor) {
}
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#getNameBackgroundColor()
+ *
+ * @return
+ */
+ @Override
+ public String getNameBackgroundColor() {
+ return null;
+ }
+
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#setNameBackgroundColor(java.lang.String)
+ *
+ * @param labelBackgroundColor
+ */
+ @Override
+ public void setNameBackgroundColor(final String labelBackgroundColor) {
+ // Do nothing
+ }
+
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/PapyrusRoundedEditPartHelper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/PapyrusRoundedEditPartHelper.java
index d2a463b7c6e..a1d63a4ae57 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/PapyrusRoundedEditPartHelper.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/PapyrusRoundedEditPartHelper.java
@@ -246,11 +246,32 @@ public abstract class PapyrusRoundedEditPartHelper implements NamedStyleProperti
// get the CSS value of hasHeader
String shadowColor = NotationUtils.getStringValue((View) ((GraphicalEditPart) editpart).getModel(), SHADOW_COLOR, defaultShadowColor);
-
// Set color of the shadow
roundedRectangleFigure.setShadowColor(shadowColor);
}
}
+ }
+
+ /**
+ * Refresh the Name Label background shadow color.
+ *
+ * @param editpart
+ * the editpart
+ * @param defaultLabelColor
+ * the default shadow color
+ */
+ public static void refreshNameLabelColor(final IPapyrusEditPart editpart, final String defaultLabelColor) {
+ if (editpart.getPrimaryShape() instanceof IRoundedRectangleFigure) {
+ if (((GraphicalEditPart) editpart).getModel() instanceof View) {
+ // The figure
+ IRoundedRectangleFigure roundedRectangleFigure = (IRoundedRectangleFigure) editpart.getPrimaryShape();
+
+ String labelColor = NotationUtils.getStringValue((View) ((GraphicalEditPart) editpart).getModel(), NAME_BACKGROUND_COLOR, defaultLabelColor);
+
+ // Set color of the Name Label background
+ roundedRectangleFigure.setNameBackgroundColor(labelColor);
+ }
+ }
}
}
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 013a0fa9db3..97b4428e1ca 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
@@ -81,6 +81,11 @@ public interface NamedStyleProperties {
public static final String SHADOW_COLOR = "shadowColor"; //$NON-NLS-1$
/**
+ * The NamedStyle property to set the nameLabel background color.
+ */
+ public static final String NAME_BACKGROUND_COLOR = "nameBackgroundColor"; //$NON-NLS-1$
+
+ /**
* The NamedStyle property to define if the figure must be draw as a package.
*/
public static final String IS_PACKAGE = "isPackage"; //$NON-NLS-1$
@@ -139,7 +144,7 @@ public interface NamedStyleProperties {
public static final String LINE_LENGTH_RATIO = "lineLengthRatio"; //$NON-NLS-1$
/** The notation NameStyle property to define the line length of compartment's topLine. */
- public static final String LENGTH = "lineLength"; //$NON-NLS-1$
+ public static final String LINE_LENGTH = "lineLength"; //$NON-NLS-1$
/** The notation NameStyle property to display. */
public static final String DISPLAY_BORDER = "displayBorder"; //$NON-NLS-1$
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/figures/InterruptibleActivityRegionFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/figures/InterruptibleActivityRegionFigure.java
index 440eaab55b8..90ca5f9e716 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/figures/InterruptibleActivityRegionFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/figures/InterruptibleActivityRegionFigure.java
@@ -571,5 +571,25 @@ public class InterruptibleActivityRegionFigure extends PapyrusNodeFigure impleme
return null;
}
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#getNameBackgroundColor()
+ *
+ * @return
+ */
+ @Override
+ public String getNameBackgroundColor() {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#setNameBackgroundColor(java.lang.String)
+ *
+ * @param labelBackgroundColor
+ */
+ @Override
+ public void setNameBackgroundColor(final String labelBackgroundColor) {
+ // Do nothing
+ }
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java
index e1208900d05..cd55813e62f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java
@@ -118,6 +118,9 @@ public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
/** The radiusWidth Observable */
private IObservableValue floatingLabelOffsetObservableWidth;
+ /** The nameBackgroundColor Observable */
+ private IObservableValue nameBackgroundColorObservable;
+
/**
* Instantiates a new rounded compartment edit part.
*
@@ -156,11 +159,21 @@ public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
PapyrusRoundedEditPartHelper.refreshShadowWidth(this, getDefaultShadowWidth());
PapyrusRoundedEditPartHelper.refreshPackage(this, getDefaultIsPackage());
PapyrusRoundedEditPartHelper.refreshShadowColor(this, getDefaultShadowColor());
+ PapyrusRoundedEditPartHelper.refreshNameLabelColor(this, getNameLabelbackgroundColor());
super.refreshVisuals();
}
/**
+ * Gets the name label color.
+ *
+ * @return the name label background color
+ */
+ protected String getNameLabelbackgroundColor() {
+ return null;
+ }
+
+ /**
* Adds listener to handle named Style modifications.
*/
@Override
@@ -197,6 +210,9 @@ public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
shadowColorObservable = new CustomStringStyleObservableValue(view, domain, SHADOW_COLOR);
shadowColorObservable.addChangeListener(namedStyleListener);
+ nameBackgroundColorObservable = new CustomStringStyleObservableValue(view, domain, NAME_BACKGROUND_COLOR);
+ nameBackgroundColorObservable.addChangeListener(namedStyleListener);
+
alignmentObservable = new CustomStringStyleObservableValue(view, domain, TEXT_ALIGNMENT);
alignmentObservable.addChangeListener(namedStyleListener);
@@ -227,6 +243,7 @@ public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
isPackageObservable.dispose();
shadowWidthObservable.dispose();
shadowColorObservable.dispose();
+ nameBackgroundColorObservable.dispose();
alignmentObservable.dispose();
floatingLabelOffsetObservableHeight.dispose();
floatingLabelOffsetObservableWidth.dispose();
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
index ac11aa2f83e..699b89949d7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
@@ -40,8 +40,10 @@ import org.eclipse.swt.graphics.Image;
*/
public class NodeNamedElementFigure extends PapyrusNodeFigure implements IPapyrusNodeNamedElementFigure, IPapyrusNodeUMLElementFigure {
+ /** The no border boolean. */
protected boolean noBorder = false;
+ /** The Constant CHEVRON. */
private static final String CHEVRON = String.valueOf("\u00AB") + String.valueOf("\u00BB");
/** The tagged label. */
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/RoundedCompartmentFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/RoundedCompartmentFigure.java
index 6ce7a94d0ac..1ad5c800d9e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/RoundedCompartmentFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/RoundedCompartmentFigure.java
@@ -17,6 +17,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.draw2d.Border;
+import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
@@ -79,7 +80,7 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
private int shadowWidth = 4;
/** The shadow color. */
- String shadowColor = null;
+ private String shadowColor = null;
/** set to true to define the figure as a package. */
private boolean isPackage = false;
@@ -87,6 +88,9 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
/** set to true to define if the figure has a shadow. */
private boolean shadow;
+ /** The label color. */
+ private String labelColor = null;
+
/**
* Gets the shadow color.
*
@@ -115,7 +119,7 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
@Override
public void setBorderStyle(final int borderStyle) {
this.borderStyle = borderStyle;
- if (shadowborder != null) {
+ if (null != shadowborder) {
shadowborder.setStyle(borderStyle);
}
}
@@ -156,7 +160,7 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
super(taggedLabelValue);
setOpaque(false);
setLayoutManager(new AutomaticCompartmentLayoutManager());
- if (compartmentFigure != null) {
+ if (null != compartmentFigure) {
createContentPane(compartmentFigure);
}
setBorder(getRoundedBorder());
@@ -245,9 +249,14 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
@Override
public void paintFigure(final Graphics graphics) {
+ // Expand the clip
+ Rectangle clipRectangle = new Rectangle();
+ graphics.getClip(clipRectangle);
+ graphics.setClip(clipRectangle.expand(2, 2));
+
graphics.pushState();
- final Rectangle rectangle = getBounds().getCopy();
- final Rectangle clipRectangle = getBounds().getCopy();
+ Rectangle rectangle = getBounds().getCopy();
+
refreshCornerSizeWhenOval();
applyTransparency(graphics);
@@ -265,8 +274,7 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
this.translateToRelative(polygonPoints);
// setClip
- graphics.getClip(clipRectangle);
- graphics.setClip(clipRectangle.expand(1, 1));
+ graphics.clipRect(clipRectangle.expand(1, 1));
// Draw shadow
if (isShadow()) {
@@ -282,7 +290,7 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
graphics.setClip(clipRectangle);
// set the background color
- setShadowBackgroundColor(graphics);
+ graphics.setBackgroundColor(getColorOfShadow());
// Draw the shadow
graphics.fillPolygon(polygonPoints);
@@ -291,21 +299,17 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
polygonPoints.translate(-shadowWidth, -shadowWidth);
clipRectangle.width -= shadowWidth;
clipRectangle.height -= shadowWidth;
- graphics.setClip(clipRectangle);
+ graphics.clipRect(clipRectangle);
// Reset the transparency for shadow
setShadowTransparency(graphics, false);
}
// Fill figure
- if (isUsingGradient()) {
- fillPolygonWithGradient(graphics, polygonPoints);
-
- } else {
- graphics.fillPolygon(polygonPoints);
- }
+ fillPolygon(graphics, polygonPoints);
graphics.setLineWidth(getLineWidth());
+ // set the lineStyle: not compatible with custom style
graphics.setLineStyle(borderStyle);
// border draw trough graphics
@@ -330,7 +334,7 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
} else {
// Retrieve the border when was be set to null for package
- if (cachedBorder != null) {
+ if (null != cachedBorder) {
setBorder(cachedBorder);
cachedBorder = null;
}
@@ -349,7 +353,7 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
graphics.setClip(clipRectangle);
// set the background color
- setShadowBackgroundColor(graphics);
+ graphics.setBackgroundColor(getColorOfShadow());
// draw the shadow
graphics.fillRoundRectangle(rectangle, cornerDimension.width, cornerDimension.height);
@@ -359,26 +363,37 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
// reposition clip
clipRectangle.width -= shadowWidth;
clipRectangle.height -= shadowWidth;
- graphics.setClip(clipRectangle);
+ graphics.clipRect(clipRectangle);
// Reset the transparency for shadow
setShadowTransparency(graphics, false);
}
- // Fill figure
- if (isUsingGradient()) {
- fillRoundedRectangleWithGradient(graphics, rectangle, cornerDimension.width, cornerDimension.height);
- } else {
- graphics.pushState();
- graphics.setBackgroundColor(getBackgroundColor());
- graphics.setForegroundColor(getForegroundColor());
- graphics.fillRoundRectangle(rectangle, cornerDimension.width, cornerDimension.height);
- graphics.popState();
- }
+ fillRoundedRectangle(graphics, rectangle, cornerDimension.width, cornerDimension.height);
// Draw header if needed
if (hasHeader) {
- graphics.drawPolyline(getHeader());
+ PointList header = getHeader();
+ graphics.drawPolyline(header);
+ // calculate the path
+ Path path = new Path(null);
+ path.moveTo(getBounds().x + cornerDimension.width / 2, getBounds().y);
+ for (int i = 0; i < header.size(); i++) {
+ path.lineTo(header.getPoint(i).x, header.getPoint(i).y);
+ }
+ path.lineTo(getBounds().x, header.getPoint(header.size() - 1).y + cornerDimension.height / 2);
+ path.addArc(getBounds().x, getBounds().y, cornerDimension.width, cornerDimension.height, 180, -90);
+
+ graphics.pushState();
+
+ // Set the clip
+ graphics.clipPath(path);
+
+ // Paint the Name
+ paintName(graphics);
+
+ graphics.popState();
+ path.dispose();
}
// Draw border
@@ -394,14 +409,14 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
}
/**
- * Fill polygon with gradient.
+ * Fill polygon.
*
* @param graphics
* the graphics
* @param polygonPoints
* the polygon points
*/
- protected void fillPolygonWithGradient(final Graphics graphics, final PointList polygonPoints) {
+ protected void fillPolygon(final Graphics graphics, final PointList polygonPoints) {
graphics.pushState();
final Path path = new Path(null);
@@ -410,18 +425,33 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
path.lineTo(polygonPoints.getPoint(i).x, polygonPoints.getPoint(i).y);
}
path.close();
- graphics.setForegroundColor(ColorRegistry.getInstance().getColor(getGradientColor2()));
- graphics.setBackgroundColor(ColorRegistry.getInstance().getColor(getGradientColor1()));
+
+ // Set the clip
graphics.clipPath(path);
- graphics.fillGradient(getBounds(), getGradientStyle() == 0);
- path.dispose();
+ // Defining the color and fill the figure
+ if (!isUsingGradient()) {
+ graphics.setBackgroundColor(getBackgroundColor());
+ graphics.setForegroundColor(getBackgroundColor());
+ graphics.fillPath(path);
+ } else {
+ graphics.setForegroundColor(ColorRegistry.getInstance().getColor(getGradientColor2()));
+ graphics.setBackgroundColor(ColorRegistry.getInstance().getColor(getGradientColor1()));
+ graphics.fillGradient(getBounds(), getGradientStyle() == 0);
+ }
+
+ // Paint the name
+ if (!hasHeader || isPackage) {
+ paintName(graphics);
+ }
+
+ path.dispose();
graphics.popState();
}
/**
- * Fill rounded rectangle with gradient.
+ * Fill rounded rectangle.
*
* @param graphics
* the graphics
@@ -432,15 +462,15 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
* @param arcHeight
* the arc height
*/
- protected void fillRoundedRectangleWithGradient(final Graphics graphics, final Rectangle rectangle, final int arcWidths, final int arcHeights) {
+ protected void fillRoundedRectangle(final Graphics graphics, final Rectangle rectangle, final int arcWidths, final int arcHeights) {
graphics.pushState();
final Rectangle rect = rectangle.getCopy();
final Dimension arc = new Dimension(arcWidths, arcHeights);
+ // Calculate the path to paint
+ Path path = new Path(null);
rect.setWidth(rect.width - 1);
rect.setHeight(rect.height - 1);
- final Path path = new Path(null);
-
if (isOval) {
arc.width = rect.width;
arc.height = rect.height;
@@ -463,31 +493,89 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
path.lineTo(rect.x, rect.y + arc.height / 2);
path.addArc(rect.x, rect.y, arc.width, arc.height, 180, -90);
- graphics.setForegroundColor(ColorRegistry.getInstance().getColor(getGradientColor2()));
- graphics.setBackgroundColor(ColorRegistry.getInstance().getColor(getGradientColor1()));
+ // set the Color
+ if (!isUsingGradient()) {
+ graphics.setBackgroundColor(getBackgroundColor());
+ graphics.setForegroundColor(getBackgroundColor());
+ } else {
+ graphics.setForegroundColor(ColorRegistry.getInstance().getColor(getGradientColor2()));
+ graphics.setBackgroundColor(ColorRegistry.getInstance().getColor(getGradientColor1()));
+ }
+ // Set the Clip
graphics.clipPath(path);
- graphics.fillGradient(getBounds(), getGradientStyle() == 0);
+ // Fill the figure
+ graphics.fillGradient(getBounds(), 0 == getGradientStyle());
- path.dispose();
+ if (!hasHeader) {
+ paintName(graphics);
+ }
graphics.popState();
- }
+ path.dispose();
+ }
/**
- * Sets the shadow background color.
+ * Paint name.
*
* @param graphics
- * the new shadow background color
+ * the graphics
*/
- private void setShadowBackgroundColor(final Graphics graphics) {
+ protected void paintName(final Graphics graphics) {
+ if (null != getColorOfLabelBackground()) {
+
+ Rectangle nameBounds = new Rectangle(getLocation(), getLabelsDimension());
+ // Move bounds to have a better gradient effect.
+ nameBounds.y = nameBounds.y - nameBounds.height;
+ nameBounds.height *= 2;
+ nameBounds.width = getBounds().width;
+
+ // Paint it
+ if (isUsingGradient()) {
+ graphics.setForegroundColor(ColorConstants.white);
+ } else {
+ graphics.setForegroundColor(getColorOfLabelBackground());
+ }
+ graphics.setBackgroundColor(getColorOfLabelBackground());
+ graphics.fillGradient(nameBounds, getGradientStyle() == 0);
+ }
+ }
+
+
+ /**
+ * Gets the color of shadow as org.eclipse.swt.graphics.Color.
+ *
+ * @return the color of shadow
+ */
+ protected Color getColorOfShadow() {
+ Color color = stringToColor(shadowColor);
+ return color != null ? color : getForegroundColor();
+ }
+
+ /**
+ * Gets the color of label background.
+ *
+ * @return the color of label background
+ */
+ protected Color getColorOfLabelBackground() {
+ return stringToColor(labelColor);
+ }
+
+ /**
+ * String to color.
+ *
+ * @param stringColor
+ * the color as String
+ * @return the color
+ */
+ private Color stringToColor(String stringColor) {
Color color = null;
- if (shadowColor != null && !"-1".equals(shadowColor)) {
+ if (stringColor != null && !"-1".equals(stringColor)) {
// get the the RGBColor from string
- final RGBColor rgbColor = CSS2ColorHelper.getRGBColor(shadowColor);
+ final RGBColor rgbColor = CSS2ColorHelper.getRGBColor(stringColor);
if (rgbColor != null) {
// extract RGB
final int red = Integer.parseInt(rgbColor.getRed().toString());
@@ -500,18 +588,14 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
if (color == null) {
try {
- color = ColorRegistry.getInstance().getColor(Integer.valueOf(shadowColor));
+ color = ColorRegistry.getInstance().getColor(Integer.valueOf(stringColor));
} catch (final NumberFormatException e) {
Activator.log.error("Shadow Color not well set", e);
}
}
}
- if (color != null) {
- graphics.setBackgroundColor(color);
- } else {
- graphics.setBackgroundColor(getForegroundColor());
- }
+ return color;
}
/**
@@ -560,6 +644,54 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
}
/**
+ * Gets the header point list.
+ *
+ * @return the point list to draw an header. its width is set to the width of the name and it's position to the left.
+ */
+ protected PointList getHeader() {
+ PointList points = new PointList();
+
+ Rectangle labelBounds = new Rectangle(getLocation(), getLabelsDimension());
+
+ // case the size of the label is 0 or -1 (no label)
+ if (labelBounds.width <= 0) {
+ labelBounds.width = getBounds().width / 4;
+ }
+
+ Point verticalStart = new Point();
+ Point verticalEnd = new Point();
+ Point diagonalStart = new Point();
+ Point diagonalEnd = new Point();
+ Point horizontalStart = new Point();
+ Point horizontalEnd = new Point();
+
+ verticalStart.x = labelBounds.x + labelBounds.width + 10;
+ verticalStart.y = getBounds().y;
+ points.addPoint(verticalStart);
+
+ verticalEnd.x = verticalStart.x;
+ verticalEnd.y = verticalStart.y + labelBounds.height / 2 + 3;
+ points.addPoint(verticalEnd);
+
+ diagonalStart.x = verticalEnd.x;
+ diagonalStart.y = verticalEnd.y;
+ points.addPoint(diagonalStart);
+
+ diagonalEnd.x = diagonalStart.x - labelBounds.height / 2 + 3;
+ diagonalEnd.y = labelBounds.y + labelBounds.height - 1;
+ points.addPoint(diagonalEnd);
+
+ horizontalStart.x = diagonalEnd.x;
+ horizontalStart.y = diagonalEnd.y;
+ points.addPoint(horizontalStart);
+
+ horizontalEnd.x = labelBounds.x;
+ horizontalEnd.y = horizontalStart.y;
+ points.addPoint(horizontalEnd);
+ return points;
+ }
+
+ /**
* @return the Rounded border used as border for this figure.
*
*/
@@ -603,6 +735,26 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
}
/**
+ * Gets the package header.
+ *
+ * @return the package header
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#getPackageHeader()
+ */
+ @Override
+ public Rectangle getPackageHeader() {
+ Rectangle headerBound = new Rectangle();
+ if (isPackage) {
+ headerBound.setBounds(getLocation(), getLabelsDimension());
+ if (-1 == headerBound.width) {
+ headerBound.width = 60;
+ }
+ // If the width of the figure is < to the label width
+ headerBound.width = Math.min(headerBound.width, getBounds().width);
+ }
+ return headerBound;
+ }
+
+ /**
* Sets the corner dimension.
*
* @param cornerDimension
@@ -618,9 +770,11 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
}
/**
- * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#setOval(boolean)
+ * Sets the oval.
*
* @param booleanValue
+ * the new oval
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#setOval(boolean)
*/
@Override
public void setOval(final boolean booleanValue) {
@@ -631,9 +785,10 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
}
/**
- * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#isOval()
+ * Checks if is oval.
*
- * @return
+ * @return true, if is oval
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#isOval()
*/
@Override
public boolean isOval() {
@@ -641,9 +796,11 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
}
/**
- * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#setFloatingNameConstrained(boolean)
+ * Sets the floating name constrained.
*
* @param booleanValue
+ * the new floating name constrained
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#setFloatingNameConstrained(boolean)
*/
@Override
public void setFloatingNameConstrained(final boolean booleanValue) {
@@ -651,9 +808,10 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
}
/**
- * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#isFloatingNameConstrained()
+ * Checks if is floating name constrained.
*
- * @return
+ * @return true, if is floating name constrained
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#isFloatingNameConstrained()
*/
@Override
public boolean isFloatingNameConstrained() {
@@ -661,9 +819,11 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
}
/**
- * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#setFloatingNameOffset(org.eclipse.draw2d.geometry.Dimension)
+ * Sets the floating name offset.
*
* @param offset
+ * the new floating name offset
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#setFloatingNameOffset(org.eclipse.draw2d.geometry.Dimension)
*/
@Override
public void setFloatingNameOffset(final Dimension offset) {
@@ -672,82 +832,16 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
}
/**
- * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#getFloatingNameOffset()
+ * Gets the floating name offset.
*
- * @return
+ * @return the floating name offset
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#getFloatingNameOffset()
*/
@Override
public Dimension getFloatingNameOffset() {
return floatingNameOffset;
}
-
- /**
- * @return the point list to draw an header. its width is set to the width of the name and it's position to the left.
- */
- protected PointList getHeader() {
- final PointList points = new PointList();
-
- final Rectangle labelBounds = new Rectangle(getLocation(), getLabelsDimension());
-
- // case the size of the label is 0 or -1 (no label)
- if (labelBounds.width <= 0) {
- labelBounds.width = getBounds().width / 4;
- }
-
- final Point verticalStart = new Point();
- final Point verticalEnd = new Point();
- final Point diagonalStart = new Point();
- final Point diagonalEnd = new Point();
- final Point horizontalStart = new Point();
- final Point horizontalEnd = new Point();
-
- verticalStart.x = labelBounds.x + labelBounds.width + 4;
- verticalStart.y = getBounds().y; // labelBounds.y;
- points.addPoint(verticalStart);
-
- verticalEnd.x = verticalStart.x;
- verticalEnd.y = verticalStart.y + labelBounds.height / 2 + 3;
- points.addPoint(verticalEnd);
-
- diagonalStart.x = verticalEnd.x;
- diagonalStart.y = verticalEnd.y;
- points.addPoint(diagonalStart);
-
- diagonalEnd.x = diagonalStart.x - labelBounds.height / 2 + 3;
- diagonalEnd.y = labelBounds.y + labelBounds.height - 1;
- points.addPoint(diagonalEnd);
-
- horizontalStart.x = diagonalEnd.x;
- horizontalStart.y = diagonalEnd.y;
- points.addPoint(horizontalStart);
-
- horizontalEnd.x = labelBounds.x;
- horizontalEnd.y = horizontalStart.y;
- points.addPoint(horizontalEnd);
- return points;
- }
-
- /**
- * Gets the package header. Return empty rectangle if not a package.
- *
- * @return the package header
- * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#getPackageHeader()
- */
- @Override
- public Rectangle getPackageHeader() {
- final Rectangle headerBound = new Rectangle();
- if (isPackage) {
- headerBound.setBounds(getLocation(), getLabelsDimension());
- if (-1 == headerBound.width) {
- headerBound.width = 60;
- }
- // If the width of the figure is < to the label width
- headerBound.width = Math.min(headerBound.width, getBounds().width);
- }
- return headerBound;
- }
-
/**
* Sets the checks for header.
*
@@ -761,9 +855,10 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
}
/**
- * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#hasHeader()
+ * Checks for header.
*
- * @return
+ * @return true, if successful
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#hasHeader()
*/
@Override
public boolean hasHeader() {
@@ -801,4 +896,29 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements
return labelDimension;
}
+
+ /**
+ * Gets the name background color.
+ *
+ * @return the label background color
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#getNameBackgroundColor()
+ */
+ @Override
+ public String getNameBackgroundColor() {
+ return labelColor;
+ }
+
+
+ /**
+ * Sets the label background color.
+ *
+ * @param labelBackgroundColor
+ * the new label background color
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#setNameBackgroundColor(java.lang.String)
+ */
+ @Override
+ public void setNameBackgroundColor(String labelBackgroundColor) {
+ this.labelColor = labelBackgroundColor;
+ }
+
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/ShapeCustomisationTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/ShapeCustomisationTest.java
index a3a2629a57f..4d2ea5d4f56 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/ShapeCustomisationTest.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/ShapeCustomisationTest.java
@@ -123,6 +123,9 @@ public class ShapeCustomisationTest extends AbstractPapyrusTest {
// Test shadowColor with command on notation.
testShadowColor(componentEditPart);
+ // Test the name background color on notation
+ testNameBackgroundColor(componentEditPart);
+
// Test isPackage with command on notation.
testIsPackage(componentEditPart);
// Test hasHeader with command on notation.
@@ -306,6 +309,9 @@ public class ShapeCustomisationTest extends AbstractPapyrusTest {
// Test shadowColor CSS
testShadowColorWithCSS(componentEditPart);
+ // Test name background color with CSS
+ testNameBackgroundColorWithCSS(componentEditPart);
+
// Test isPackage with CSS
testIsPackageWithCSS(componentEditPart);
@@ -679,6 +685,65 @@ public class ShapeCustomisationTest extends AbstractPapyrusTest {
}
/**
+ * Test background label color.
+ *
+ * @param editPart
+ * the edit part"true"
+ */
+ private void testNameBackgroundColor(EditPart editPart) {
+ IFigure primaryShape = ((IPapyrusEditPart) editPart).getPrimaryShape();
+ Assert.assertTrue("The Figure must implement IRoundedRectangleFigure", primaryShape instanceof IRoundedRectangleFigure);
+
+ String labelBackgroundColorDefaultValue = ((IRoundedRectangleFigure) primaryShape).getNameBackgroundColor();
+ String labelBackgroundColorForTest1 = "red";
+
+ getCommandStack()
+ .execute(new CustomStyleValueCommand((View) editPart.getModel(), labelBackgroundColorForTest1, NotationPackage.eINSTANCE.getStringValueStyle(), NotationPackage.eINSTANCE.getStringValueStyle_StringValue(),
+ NamedStyleProperties.NAME_BACKGROUND_COLOR));
+ Assert.assertEquals("nameBackgroundColor not well set on IRoundedRectangleFigure", labelBackgroundColorForTest1, ((IRoundedRectangleFigure) primaryShape).getNameBackgroundColor());
+ getCommandStack().undo();
+ Assert.assertEquals("nameBackgroundColor not well undo on IRoundedRectangleFigure", labelBackgroundColorDefaultValue, ((IRoundedRectangleFigure) primaryShape).getNameBackgroundColor());
+ getCommandStack().redo();
+ Assert.assertEquals("nameBackgroundColor not well redo on IRoundedRectangleFigure", labelBackgroundColorForTest1, ((IRoundedRectangleFigure) primaryShape).getNameBackgroundColor());
+ getCommandStack().undo();
+
+ String labelBackgroundColorForTest2 = "#336699";
+ getCommandStack()
+ .execute(new CustomStyleValueCommand((View) editPart.getModel(), labelBackgroundColorForTest2, NotationPackage.eINSTANCE.getStringValueStyle(), NotationPackage.eINSTANCE.getStringValueStyle_StringValue(),
+ NamedStyleProperties.NAME_BACKGROUND_COLOR));
+ Assert.assertEquals("nameBackgroundColor not well set on IRoundedRectangleFigure", labelBackgroundColorForTest2, ((IRoundedRectangleFigure) primaryShape).getNameBackgroundColor());
+ getCommandStack().undo();
+ Assert.assertEquals("nameBackgroundColor not well undo on IRoundedRectangleFigure", labelBackgroundColorDefaultValue, ((IRoundedRectangleFigure) primaryShape).getNameBackgroundColor());
+ }
+
+ /**
+ * Test name Background Color with css.
+ *
+ * @param editPart
+ * the edit part
+ * @throws NotHandledException
+ * @throws NotEnabledException
+ * @throws NotDefinedException
+ * @throws ExecutionException
+ */
+ private void testNameBackgroundColorWithCSS(EditPart editPart) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException {
+ IFigure primaryShape = ((IPapyrusEditPart) editPart).getPrimaryShape();
+ Assert.assertTrue("The Figure must implement IRoundedRectangleFigure", primaryShape instanceof IRoundedRectangleFigure);
+
+ setEmbeddedStyleSheet("*", NamedStyleProperties.NAME_BACKGROUND_COLOR, "red", false);
+ editPart.refresh();
+
+ Assert.assertEquals("nameBackgroundColor not well set on IRoundedRectangleFigure", "red", ((IRoundedRectangleFigure) primaryShape).getNameBackgroundColor());
+ resetEmbeddedStyleSheet();
+
+ setEmbeddedStyleSheet("*", NamedStyleProperties.NAME_BACKGROUND_COLOR, "\"#336699\"", false);// need to ass \" \" because #123456 is reconise as RGBColor whitch is not managed by papyrus.
+ editPart.refresh();
+
+ Assert.assertEquals("nameBackgroundColor not well set on IRoundedRectangleFigure", "#336699", ((IRoundedRectangleFigure) primaryShape).getNameBackgroundColor());
+ resetEmbeddedStyleSheet();
+ }
+
+ /**
* Test has header.
*
* @param editPart

Back to the top