Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCéline Janssens2014-09-25 13:53:34 +0000
committerCamille Letavernier2014-09-25 15:03:34 +0000
commit84b7754d168b0ae91f06faf45d4356f5d9b38111 (patch)
tree2a994a3cd4282bd9fcc1053c1c395a4e4c00ea0b /plugins
parent77daacb6e47f3da75f212e9888a9818cc79d936f (diff)
downloadorg.eclipse.papyrus-84b7754d168b0ae91f06faf45d4356f5d9b38111.tar.gz
org.eclipse.papyrus-84b7754d168b0ae91f06faf45d4356f5d9b38111.tar.xz
org.eclipse.papyrus-84b7754d168b0ae91f06faf45d4356f5d9b38111.zip
440230: [All Diagrams] Add Margins to the Labels
https://bugs.eclipse.org/bugs/show_bug.cgi?id=440230 - Allow 4 sides Labe lMargin instead of vertical and horizontal only Change-Id: I1970e2317ce6c3c5708bad3a880ea4abf9c04018 Signed-off-by: Céline Janssens <Celine.Janssens@all4tec.net>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java30
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/IPapyrusWrappingLabel.java14
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/PapyrusWrappingLabel.java23
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/BorderNamedElementEditPart.java52
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java35
5 files changed, 79 insertions, 75 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 208b2876c81..c7815db0d5a 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
@@ -8,7 +8,7 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- * Céline Janssens (ALL4TEC) celine.janssens@all4tec.net
+ * Céline Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 440230
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 443235
* Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - text alignment implementation
*
@@ -52,12 +52,22 @@ public abstract class PapyrusLabelEditPart extends LabelEditPart {
/**
* CSS Integer property to define the horizontal Label Margin
*/
- static final String X_MARGIN_PROPERTY = "xMarginLabel"; //$NON-NLS$
+ static final String TOP_MARGIN_PROPERTY = "TopMarginLabel"; //$NON-NLS$
/**
* CSS Integer property to define the vertical Label Margin
*/
- static final String Y_MARGIN_PROPERTY = "yMarginLabel"; //$NON-NLS$
+ static final String LEFT_MARGIN_PROPERTY = "LeftMarginLabel"; //$NON-NLS$
+
+ /**
+ * CSS Integer property to define the horizontal Label Margin
+ */
+ static final String BOTTOM_MARGIN_PROPERTY = "BottomMarginLabel"; //$NON-NLS$
+
+ /**
+ * CSS Integer property to define the vertical Label Margin
+ */
+ static final String RIGHT_MARGIN_PROPERTY = "RightMarginLabel"; //$NON-NLS$
/** The Constant TEXT_ALIGNMENT. */
private static final String TEXT_ALIGNMENT = "textAlignment"; //$NON-NLS$
@@ -355,22 +365,26 @@ public abstract class PapyrusLabelEditPart extends LabelEditPart {
public void refreshLabelMargin() {
IFigure figure = null;
- int horizontalMargin = DEFAULT_MARGIN;
- int verticalMargin = DEFAULT_MARGIN;
+ int leftMargin = DEFAULT_MARGIN;
+ int rightMargin = DEFAULT_MARGIN;
+ int topMargin = DEFAULT_MARGIN;
+ int bottomMargin = DEFAULT_MARGIN;
Object model = this.getModel();
if (model instanceof View) {
- horizontalMargin = NotationUtils.getIntValue((View) model, Y_MARGIN_PROPERTY, DEFAULT_MARGIN);
- verticalMargin = NotationUtils.getIntValue((View) model, X_MARGIN_PROPERTY, DEFAULT_MARGIN);
+ leftMargin = NotationUtils.getIntValue((View) model, LEFT_MARGIN_PROPERTY, DEFAULT_MARGIN);
+ rightMargin = NotationUtils.getIntValue((View) model, RIGHT_MARGIN_PROPERTY, DEFAULT_MARGIN);
+ topMargin = NotationUtils.getIntValue((View) model, TOP_MARGIN_PROPERTY, DEFAULT_MARGIN);
+ bottomMargin = NotationUtils.getIntValue((View) model, BOTTOM_MARGIN_PROPERTY, DEFAULT_MARGIN);
}
figure = ((GraphicalEditPart) this).getFigure();
if (figure instanceof IPapyrusWrappingLabel) {
- ((IPapyrusWrappingLabel) figure).setMarginLabel(verticalMargin,horizontalMargin);
+ ((IPapyrusWrappingLabel) figure).setMarginLabel(leftMargin, topMargin, rightMargin, bottomMargin);
}
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/IPapyrusWrappingLabel.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/IPapyrusWrappingLabel.java
index 1c1c8def10d..1aa7ead09c7 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/IPapyrusWrappingLabel.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/IPapyrusWrappingLabel.java
@@ -31,4 +31,16 @@ public interface IPapyrusWrappingLabel extends IFigure {
*/
void setMarginLabel(int xMargin , int yMargin);
-}
+
+
+
+
+ /**
+ * Set the margin of the Label in the horizontal direction and vertical Direction
+ * @param xMargin Horizontal Margin
+ * @param yMargin Vertical Margin
+ *
+ */
+ void setMarginLabel(int leftMargin , int topMargin, int rightMargin, int bottomMargin);
+
+} \ No newline at end of file
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/PapyrusWrappingLabel.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/PapyrusWrappingLabel.java
index 0a47beb6bf0..f7eb0c705a6 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/PapyrusWrappingLabel.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/PapyrusWrappingLabel.java
@@ -88,20 +88,31 @@ public class PapyrusWrappingLabel extends WrappingLabel implements IPapyrusWrapp
/**
* @see org.eclipse.papyrus.infra.gmfdiag.common.figure.IPapyrusWrappingLabel#setMarginLabel(int, int)
*
- * @param xMargin Horizontal margin
- * @param yMargin Vertical margin
+ * @param xMargin Vertical margin
+ * @param yMargin Horizontal margin
*/
@Override
public void setMarginLabel(int xMargin, int yMargin) {
- MarginBorder mb = new MarginBorder(xMargin, yMargin, xMargin, yMargin);
+ this.setMarginLabel(xMargin, yMargin , xMargin, yMargin);
+
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.IPapyrusWrappingLabel#setMarginLabel(int, int, int, int)
+ *
+ * @param leftMargin
+ * @param topMargin
+ * @param rightMargin
+ * @param bottomMargin
+ */
+ @Override
+ public void setMarginLabel(int leftMargin, int topMargin, int rightMargin, int bottomMargin) {
+ MarginBorder mb = new MarginBorder(topMargin, leftMargin, bottomMargin, rightMargin);
this.setBorder(mb);
repaint();
revalidate();
-
-
-
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/BorderNamedElementEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/BorderNamedElementEditPart.java
index dfb03ba281e..8ee9a110732 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/BorderNamedElementEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/BorderNamedElementEditPart.java
@@ -14,18 +14,11 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editparts;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.emf.appearance.helper.NameLabelIconHelper;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.IPapyrusWrappingLabel;
-import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
-import org.eclipse.papyrus.infra.gmfdiag.common.utils.FigureUtils;
import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeNamedElementFigure;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
@@ -40,12 +33,7 @@ import org.eclipse.uml2.uml.NamedElement;
*/
public abstract class BorderNamedElementEditPart extends BorderUMLNodeEditPart implements IUMLNamedElementEditPart {
- /**
- * Default Margin when not present in CSS
- */
- private static final int DEFAULT_MARGIN = NamedElementEditPart.DEFAULT_MARGIN;
-
/**
*
* Constructor.
@@ -95,52 +83,12 @@ public abstract class BorderNamedElementEditPart extends BorderUMLNodeEditPart i
refreshIconNamedLabel();
refreshFontColor();
}
- refreshLabelMargin();
refreshBounds();
}
/**
- * Refresh margin of bordered named element children labels
- * <ul>
- * <li> Get Css values </li>
- * <li> Get all the children figure </li>
- * <li> If the child is a label then apply the margin </li>
- * </ul>
- */
- private void refreshLabelMargin() {
- IFigure figure = null;
-
- int horizontalMargin = DEFAULT_MARGIN;
- int verticalMargin= DEFAULT_MARGIN;
-
- Object model = this.getModel();
-
-
- // Get notation Margin values (from CSS)
- if (model instanceof View) {
- horizontalMargin = NotationUtils.getIntValue((View)model, NamedElementEditPart.Y_MARGIN_PROPERTY, DEFAULT_MARGIN);
- verticalMargin = NotationUtils.getIntValue((View)model, NamedElementEditPart.X_MARGIN_PROPERTY, DEFAULT_MARGIN);
- }
-
- // Get all children figures of the Edit Part and set margin according to the retrieve values
- if (this instanceof IPapyrusEditPart){
- figure = ((IPapyrusEditPart) this).getPrimaryShape();
- List<IPapyrusWrappingLabel> labelChildFigureList = FigureUtils.findChildFigureInstances(figure, IPapyrusWrappingLabel.class);
-
- for (IPapyrusWrappingLabel label : labelChildFigureList){
- if (label != null){
- label.setMarginLabel(verticalMargin, horizontalMargin);
-
- }
- }
- }
-
-
- }
-
- /**
* A method to specify the labels to be update when the font is refreshed.
* Subclasses should call super.refreshLabelsFont(font)
*
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java
index 1be0c326524..20f68d45d06 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
+ * Copyright (c) 2008-2014 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Céline Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 440230 : Label Margin
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editparts;
@@ -59,12 +60,23 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
/**
* CSS Integer property to define the horizontal Label Margin
*/
- public static final String X_MARGIN_PROPERTY = "xMarginLabel"; //$NON-NLS$
+ public static final String TOP_MARGIN_PROPERTY = "TopMarginLabel"; //$NON-NLS$
+
+ /**
+ * CSS Integer property to define the vertical Label Margin
+ */
+ public static final String LEFT_MARGIN_PROPERTY = "LeftMarginLabel"; //$NON-NLS$
/**
+ * CSS Integer property to define the horizontal Label Margin
+ */
+ public static final String BOTTOM_MARGIN_PROPERTY = "BottomMarginLabel"; //$NON-NLS$
+
+ /**
* CSS Integer property to define the vertical Label Margin
*/
- public static final String Y_MARGIN_PROPERTY = "yMarginLabel"; //$NON-NLS$
+ public static final String RIGHT_MARGIN_PROPERTY = "RightMarginLabel"; //$NON-NLS$
+
/**
@@ -124,23 +136,30 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
private void refreshLabelMargin() {
IFigure figure = null;
- int horizontalMargin = DEFAULT_MARGIN;
- int verticalMargin= DEFAULT_MARGIN;
+ int leftMargin = DEFAULT_MARGIN;
+ int rightMargin = DEFAULT_MARGIN;
+ int topMargin = DEFAULT_MARGIN;
+ int bottomMargin = DEFAULT_MARGIN;
Object model = this.getModel();
+
+
if (model instanceof View) {
- horizontalMargin = NotationUtils.getIntValue((View)model, Y_MARGIN_PROPERTY, DEFAULT_MARGIN);
- verticalMargin = NotationUtils.getIntValue((View)model, X_MARGIN_PROPERTY, DEFAULT_MARGIN);
+ leftMargin = NotationUtils.getIntValue((View) model, LEFT_MARGIN_PROPERTY, DEFAULT_MARGIN);
+ rightMargin = NotationUtils.getIntValue((View) model, RIGHT_MARGIN_PROPERTY, DEFAULT_MARGIN);
+ topMargin = NotationUtils.getIntValue((View) model, TOP_MARGIN_PROPERTY, DEFAULT_MARGIN);
+ bottomMargin = NotationUtils.getIntValue((View) model, BOTTOM_MARGIN_PROPERTY, DEFAULT_MARGIN);
}
+ // Get all children figures of the Edit Part and set margin according to the retrieve values
if (this instanceof IPapyrusEditPart){
figure = ((IPapyrusEditPart) this).getPrimaryShape();
List<IPapyrusWrappingLabel> labelChildFigureList = FigureUtils.findChildFigureInstances(figure, IPapyrusWrappingLabel.class);
for (IPapyrusWrappingLabel label : labelChildFigureList){
if (label != null){
- label.setMarginLabel(verticalMargin, horizontalMargin);
+ label.setMarginLabel(leftMargin, topMargin, rightMargin, bottomMargin);
}
}
}

Back to the top