Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2018-06-26 13:59:38 +0000
committerNicolas FAUVERGUE2018-07-03 15:08:56 +0000
commit8c848ad6f5ea600dd74c448f631a19042349ba97 (patch)
treed609d701603f6b6aae0cc86b1a8025f00f105c0f /plugins/infra
parent6b3deccc9dc1d98628dfb300fd87f76606ee44ba (diff)
downloadorg.eclipse.papyrus-8c848ad6f5ea600dd74c448f631a19042349ba97.tar.gz
org.eclipse.papyrus-8c848ad6f5ea600dd74c448f631a19042349ba97.tar.xz
org.eclipse.papyrus-8c848ad6f5ea600dd74c448f631a19042349ba97.zip
Bug 535519: [Sequence Diagram] Sequence Diagram layout (& semantics) do
not support DPI scaling https://bugs.eclipse.org/bugs/show_bug.cgi?id=535519 - Initial version: support a labelHeight / labelWidth in CSS - Remove the layout tolerance from the tests Change-Id: Ie46bb206c3046e6111ebaea2a7cc1f66ca09ea15 Signed-off-by: Camille Letavernier <cletavernier@eclipsesource.com>
Diffstat (limited to 'plugins/infra')
-rwxr-xr-xplugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/pom.xml2
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusCompartmentEditPart.java25
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/PapyrusWrappingLabel.java79
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/NamedStyleProperties.java24
5 files changed, 119 insertions, 13 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
index d5224cbb99d..a9896bff8e1 100755
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
@@ -82,7 +82,7 @@ Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.common.Activator
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
-Bundle-Version: 3.100.0.qualifier
+Bundle-Version: 3.101.0.qualifier
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-ManifestVersion: 2
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/pom.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/pom.xml
index 50f2d50fc3e..f060d90a431 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/pom.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/pom.xml
@@ -7,6 +7,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.gmfdiag.common</artifactId>
- <version>3.100.0-SNAPSHOT</version>
+ <version>3.101.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ 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/editpart/PapyrusCompartmentEditPart.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusCompartmentEditPart.java
index 605425d43a3..312c5d0b85d 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusCompartmentEditPart.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusCompartmentEditPart.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
+ * Copyright (c) 2012 - 2018 CEA LIST, EclipseSource and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,12 +8,16 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * EclipseSource - Bug 535519
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.editpart;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.BorderDisplayEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.NamedStyleProperties;
public abstract class PapyrusCompartmentEditPart extends CompartmentEditPart {
@@ -43,4 +47,23 @@ public abstract class PapyrusCompartmentEditPart extends CompartmentEditPart {
}
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabelSize();
+ }
+
+
+ /**
+ * @since 3.101
+ */
+ // Bug 535519
+ protected void refreshLabelSize() {
+ if (getFigure() instanceof PapyrusWrappingLabel) {
+ int labelWidth = NotationUtils.getIntValue(getNotationView(), NamedStyleProperties.LABEL_WIDTH, PapyrusWrappingLabel.AUTO_SIZE);
+ int labelHeight = NotationUtils.getIntValue(getNotationView(), NamedStyleProperties.LABEL_HEIGHT, PapyrusWrappingLabel.AUTO_SIZE);
+ ((PapyrusWrappingLabel)getFigure() ).setLabelSize(labelWidth, labelHeight);
+ }
+ }
+
}
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 a3718d020d0..a617b8253c5 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
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 Atos Origin.
+ * Copyright (c) 2010 Atos Origin, CEA LIST, EclipseSource and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,11 +11,13 @@
* Atos Origin - Initial API and implementation
* Arthur Daussy - Bug 354622 - [ActivityDiagram] Object Flows selection prevent selecting other close elements.
* CĂ©line Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 440230 - Margin Label
+ * EclipseSource - Bug 535519
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.figure.node;
import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.IPapyrusWrappingLabel;
import org.eclipse.swt.graphics.Image;
@@ -25,7 +27,19 @@ import org.eclipse.swt.graphics.Image;
*
* @author arthur daussy
*/
-public class PapyrusWrappingLabel extends WrappingLabel implements IPapyrusWrappingLabel{
+public class PapyrusWrappingLabel extends WrappingLabel implements IPapyrusWrappingLabel {
+
+ /**
+ * A constant used for {@link #setLabelSize(int, int)}, {@link #setLabelHeight(int)}, {@link #setLabelWidth(int)}
+ * to indicate that the label size should be automatically derived from the current font size.
+ *
+ * @since 3.101
+ */
+ public static final int AUTO_SIZE = -1;
+
+ private int labelWidth = AUTO_SIZE;
+
+ private int labelHeight = AUTO_SIZE;
/**
* Constructor.
@@ -94,7 +108,7 @@ public class PapyrusWrappingLabel extends WrappingLabel implements IPapyrusWrapp
public void setMarginLabel(int xMargin, int yMargin) {
this.setMarginLabel(xMargin, yMargin , xMargin, yMargin);
-
+
}
/**
@@ -111,7 +125,62 @@ public class PapyrusWrappingLabel extends WrappingLabel implements IPapyrusWrapp
this.setBorder(mb);
repaint();
revalidate();
-
+
}
-
+
+ /**
+ * Set the height of this Label, in pixels. Use {@linksetText #AUTO_SIZE} to
+ * compute the best size based on the current font size.
+ *
+ * @param labelHeight
+ * @since 3.101
+ */
+ public void setLabelHeight(int labelHeight) {
+ this.labelHeight = labelHeight;
+ }
+
+ /**
+ * Set the width of this Label, in pixels. Use {@link #AUTO_SIZE} to
+ * compute the best size based on the current font size.
+ *
+ * @param labelWidthgetStringExtents
+ * @since 3.101
+ */
+ public void setLabelWidth(int labelWidth) {
+ this.labelWidth = labelWidth;
+ }
+
+ /**
+ * Set the size (Width, Height) of this label, in pixels. Use {@link #AUTO_SIZE} to
+ * compute the best size based on the current font size.
+ *
+ * @param height
+ * @param width
+ * @since 3.101
+ */
+ public void setLabelSize(int width, int height) {
+ setLabelWidth(width);
+ setLabelHeight(height);
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel#getPreferredSize(int, int)
+ *
+ * @param wHint
+ * @param hHint
+ * @return
+ */
+ @Override
+ public Dimension getPreferredSize(int wHint, int hHint) {
+ //TODO Compute the best font size to fit the height, and truncate on width
+ Dimension prefSize = super.getPreferredSize(wHint, hHint);
+ if (labelHeight > 0) {
+ prefSize.height = labelHeight;
+ }
+ if (labelWidth > 0) {
+ prefSize.width = labelWidth;
+ }
+ return prefSize;
+ }
+
}
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 577b0512c7e..6c61e857cc7 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
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2014 CEA LIST and others.
+ * Copyright (c) 2010, 2018 CEA LIST, EclipseSource and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ * EclipseSource - Bug 535519
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.utils;
@@ -174,19 +175,32 @@ public interface NamedStyleProperties {
/** name of the CSS property that manages the enablement of the {@link StyleBasedShapeProvider} for decoration */
public static final String SHAPE_DECORATION_STYLE_PROPERTY = "shapeDecorationStyle"; //$NON-NLS-1$
- /** NameStyle property to show an icon next to the label of an element.
+ /** NameStyle property to show an icon next to the label of an element.
* @since 3.0*/
public static final String ELEMENT_ICON = "elementIcon"; //$NON-NLS-1$
- /** NameStyle property to define the depth of the qualified name to display.
+ /** NameStyle property to define the depth of the qualified name to display.
* @since 3.0*/
public static final String QUALIFIED_NAME_DEPTH = "qualifiedNameDepth"; //$NON-NLS-1$
- /** NameStyle property to display a shadow under the shape.
+ /** NameStyle property to display a shadow under the shape.
* @since 3.0*/
public static final String SHADOW = "shadow"; //$NON-NLS-1$
- /** NamedStyle property used to show an image on the symbol compartment.
+ /** NamedStyle property used to show an image on the symbol compartment.
* @since 3.0*/
public static final String IMAGE_PATH = "imagePath"; //$NON-NLS-1$
+
+ /**
+ * NamedStyle property used to set a fixed height for a Label, in pixels
+ * @since 3.101
+ */
+ public static final String LABEL_HEIGHT = "labelHeight"; //$NON-NLS-1$
+
+ /**
+ * NamedStyle property used to set a fixed width for a Label, in pixels
+ * @since 3.101
+ */
+ public static final String LABEL_WIDTH = "labelWidth"; //$NON-NLS-1$
+
}

Back to the top