Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Monnier2015-07-22 12:59:38 +0000
committerMaxime Porhel2015-07-27 13:28:43 +0000
commit2a946ad66da34123bdcd0f49ce540d03316240fc (patch)
tree51546568ed19a0a15d969b7185158a88a11eb1c3
parent2bff4d82eecc048b5f8fa4d519c71361858e6de5 (diff)
downloadorg.eclipse.sirius-2a946ad66da34123bdcd0f49ce540d03316240fc.tar.gz
org.eclipse.sirius-2a946ad66da34123bdcd0f49ce540d03316240fc.tar.xz
org.eclipse.sirius-2a946ad66da34123bdcd0f49ce540d03316240fc.zip
[463662] Label size minimal value set to 1
A label size of 0 pixel should be forbidden. Indeed, SWT does not handle a Font with 0 pixel. The label size minimal value of style in Diagram, Table and Tree descriptions have be changed from 0 to 1. The same change has been applied to user label size customization. Forthermore, if the label size is programatically set to 0, the displayed font will still be 1. Bug: 463662 Change-Id: I5d3f3217b818cc38e3764708a23a6241a85778df Signed-off-by: Steve Monnier <steve.monnier@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/ConnectionsFactory.java2
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/ViewPropertiesSynchronizer.java2
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/StylePropertySection.java2
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/StyleHelper.java4
-rw-r--r--plugins/org.eclipse.sirius.editor.table/plugin.xml2
-rw-r--r--plugins/org.eclipse.sirius.editor.table/src/org/eclipse/sirius/table/editor/properties/sections/description/spec/foregroundstyledescription/ForegroundStyleDescriptionLabelSizePropertySectionSpec.java34
-rw-r--r--plugins/org.eclipse.sirius.editor/plugin.xml2
-rw-r--r--plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/style/basiclabelstyledescription/BasicLabelStyleDescriptionLabelSizePropertySectionSpec.java33
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/tree/TreeUtils.java36
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/vsm.odesign15
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RefreshWithCustomizedStyleTests.java148
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/VSMFieldTest.java100
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/TableUIRefreshTests.java7
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeUIRefreshTests.java7
-rw-r--r--plugins/org.eclipse.sirius.tree/src/org/eclipse/sirius/tree/business/internal/refresh/DTreeElementSynchronizerSpec.java2
15 files changed, 384 insertions, 12 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/ConnectionsFactory.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/ConnectionsFactory.java
index 4c86f3c43b..68051039f1 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/ConnectionsFactory.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/ConnectionsFactory.java
@@ -193,7 +193,7 @@ public class ConnectionsFactory {
CenterLabelStyle centerLabelStyle = dEdge.getOwnedStyle().getCenterLabelStyle();
if (centerLabelStyle != null) {
int labelSize = centerLabelStyle.getLabelSize();
- fontStyle.setFontHeight(labelSize);
+ fontStyle.setFontHeight(Math.max(labelSize, 1));
}
}
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/ViewPropertiesSynchronizer.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/ViewPropertiesSynchronizer.java
index d5a9cd2096..e12f20e82d 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/ViewPropertiesSynchronizer.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/ViewPropertiesSynchronizer.java
@@ -144,7 +144,7 @@ public class ViewPropertiesSynchronizer {
fontStyle.setStrikeThrough(labelFormat.contains(FontFormat.STRIKE_THROUGH_LITERAL));
}
- fontStyle.setFontHeight(basicLabelStyle.getLabelSize());
+ fontStyle.setFontHeight(Math.max(basicLabelStyle.getLabelSize(), 1));
//
// Default font (Change the code here to insert new font in the
// case
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/StylePropertySection.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/StylePropertySection.java
index f02fc2da24..b65e036205 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/StylePropertySection.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/StylePropertySection.java
@@ -246,7 +246,7 @@ public class StylePropertySection extends SemanticPropertySection {
fontStyle.setStrikeThrough(false);
}
} else if (value instanceof Integer && propertyId.equals(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE.getName())) {
- fontStyle.setFontHeight((Integer) value);
+ fontStyle.setFontHeight(Math.max((Integer) value, 1));
}
} else if (notationStyle instanceof ConnectorStyle) {
ConnectorStyle connectorStyle = (ConnectorStyle) notationStyle;
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/StyleHelper.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/StyleHelper.java
index 0f283a56ac..1aff33bbef 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/StyleHelper.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/StyleHelper.java
@@ -550,11 +550,11 @@ public final class StyleHelper {
}
if (previousStyle.some() && previousStyle.get().getCustomFeatures().contains(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE.getName())) {
- style.setLabelSize(previousStyle.get().getLabelSize());
+ style.setLabelSize(Math.max(previousStyle.get().getLabelSize(), 1));
style.getCustomFeatures().add(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE.getName());
} else {
if (style.getLabelSize() != size && !style.getCustomFeatures().contains(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE.getName())) {
- style.setLabelSize(size);
+ style.setLabelSize(Math.max(size, 1));
}
}
}
diff --git a/plugins/org.eclipse.sirius.editor.table/plugin.xml b/plugins/org.eclipse.sirius.editor.table/plugin.xml
index c6b03ea97c..6e2011d828 100644
--- a/plugins/org.eclipse.sirius.editor.table/plugin.xml
+++ b/plugins/org.eclipse.sirius.editor.table/plugin.xml
@@ -78,7 +78,7 @@
<input type="org.eclipse.sirius.table.metamodel.table.description.ForegroundStyleDescription"/>
</propertySection>
<propertySection
- class="org.eclipse.sirius.table.editor.properties.sections.description.foregroundstyledescription.ForegroundStyleDescriptionLabelSizePropertySection"
+ class="org.eclipse.sirius.table.editor.properties.sections.description.spec.foregroundstyledescription.ForegroundStyleDescriptionLabelSizePropertySectionSpec"
id="description.section.foregroundStyleDescription.LabelSize"
filter="org.eclipse.sirius.table.editor.properties.filters.description.foregroundstyledescription.ForegroundStyleDescriptionLabelSizeFilter"
tab="viewpoint.tab.label">
diff --git a/plugins/org.eclipse.sirius.editor.table/src/org/eclipse/sirius/table/editor/properties/sections/description/spec/foregroundstyledescription/ForegroundStyleDescriptionLabelSizePropertySectionSpec.java b/plugins/org.eclipse.sirius.editor.table/src/org/eclipse/sirius/table/editor/properties/sections/description/spec/foregroundstyledescription/ForegroundStyleDescriptionLabelSizePropertySectionSpec.java
new file mode 100644
index 0000000000..f7537b8dab
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.table/src/org/eclipse/sirius/table/editor/properties/sections/description/spec/foregroundstyledescription/ForegroundStyleDescriptionLabelSizePropertySectionSpec.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2015 THALES GLOBAL SERVICES.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.table.editor.properties.sections.description.spec.foregroundstyledescription;
+
+import org.eclipse.sirius.table.editor.properties.sections.description.foregroundstyledescription.ForegroundStyleDescriptionLabelSizePropertySection;
+
+/**
+ * An overridden {@link ForegroundStyleDescriptionLabelSizePropertySection} to
+ * change the minimal value of the label size.
+ *
+ * @author <a href="mailto:steve.monnier@obeo.fr">Steve Monnier</a>
+ */
+public class ForegroundStyleDescriptionLabelSizePropertySectionSpec extends ForegroundStyleDescriptionLabelSizePropertySection {
+
+ /**
+ * Minimum value of the field. The label size is not allowed to be 0
+ * anymore.
+ */
+ protected int minimumValue = 1;
+
+ @Override
+ public int getMinimumValue() {
+ return minimumValue;
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.editor/plugin.xml b/plugins/org.eclipse.sirius.editor/plugin.xml
index c4ab82d0e4..545d18429a 100644
--- a/plugins/org.eclipse.sirius.editor/plugin.xml
+++ b/plugins/org.eclipse.sirius.editor/plugin.xml
@@ -606,7 +606,7 @@
<input type="org.eclipse.sirius.viewpoint.description.style.BasicLabelStyleDescription"/>
</propertySection>
<propertySection
- class="org.eclipse.sirius.editor.properties.sections.style.basiclabelstyledescription.BasicLabelStyleDescriptionLabelSizePropertySection"
+ class="org.eclipse.sirius.editor.properties.sections.style.basiclabelstyledescription.BasicLabelStyleDescriptionLabelSizePropertySectionSpec"
filter="org.eclipse.sirius.editor.properties.filters.style.basiclabelstyledescription.BasicLabelStyleDescriptionLabelSizeFilter"
id="style.section.basicLabelStyleDescription.LabelSize"
tab="viewpoint.tab.label">
diff --git a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/style/basiclabelstyledescription/BasicLabelStyleDescriptionLabelSizePropertySectionSpec.java b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/style/basiclabelstyledescription/BasicLabelStyleDescriptionLabelSizePropertySectionSpec.java
new file mode 100644
index 0000000000..0ab819a9e3
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/style/basiclabelstyledescription/BasicLabelStyleDescriptionLabelSizePropertySectionSpec.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2015 THALES GLOBAL SERVICES.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.editor.properties.sections.style.basiclabelstyledescription;
+
+/**
+ * An overridden {@link BasicLabelStyleDescriptionLabelSizePropertySection} to
+ * change the minimal value of the label size.
+ *
+ * @author <a href="mailto:steve.monnier@obeo.fr">Steve Monnier</a>
+ *
+ */
+public class BasicLabelStyleDescriptionLabelSizePropertySectionSpec extends BasicLabelStyleDescriptionLabelSizePropertySection {
+
+ /**
+ * Minimum value of the field. The label size is not allowed to be 0
+ * anymore.
+ */
+ protected int minimumValue = 1;
+
+ @Override
+ public int getMinimumValue() {
+ return minimumValue;
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/tree/TreeUtils.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/tree/TreeUtils.java
index 3e140cf2ee..01473e9429 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/tree/TreeUtils.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/tree/TreeUtils.java
@@ -333,9 +333,25 @@ public final class TreeUtils {
*/
public static void checkTreeItemLabelSize(SWTBotEditor swtBotTreeEditor, DTreeItem dTreeItem) {
int labelSize = dTreeItem.getOwnedStyle().getLabelSize();
+ checkTreeItemLabelSize(swtBotTreeEditor, dTreeItem, labelSize);
+ }
+
+ /**
+ * Checks the swt {@link TreeItem#getFont()}'s label size for a specified
+ * {@link DTreeItem}.
+ *
+ * @param swtBotTreeEditor
+ * the editor bot owning the swt {@link TreeItem} referencing the
+ * specified {@link DTreeItem}
+ * @param dTreeItem
+ * the {@link DTreeItem}
+ * @param expectedLabelSize
+ * expected size of the label
+ */
+ public static void checkTreeItemLabelSize(SWTBotEditor swtBotTreeEditor, DTreeItem dTreeItem, int expectedLabelSize) {
TreeItem treeItem = TreeUtils.getTreeItem(swtBotTreeEditor, dTreeItem);
int treeItemLabelSize = TreeUtils.getWidgetLabelSize(treeItem);
- Assert.assertEquals("The TreeItem label size should corresponds to its DTreeItem.ownedStyle.labelSize", labelSize, treeItemLabelSize);
+ Assert.assertEquals("The TreeItem label size should corresponds to its DTreeItem.ownedStyle.labelSize", expectedLabelSize, treeItemLabelSize);
}
/**
@@ -352,10 +368,26 @@ public final class TreeUtils {
Option<DTableElementStyle> optionalForegroundStyleToApply = new DCellQuery(dCell).getForegroundStyleToApply();
Assert.assertTrue("We should have a foreground Style for the cell.", optionalForegroundStyleToApply.some());
int labelSize = optionalForegroundStyleToApply.get().getLabelSize();
+ checkTreeItemLabelSize(swtBotTableEditor, dCell, labelSize);
+ }
+
+ /**
+ * Checks the swt {@link TreeItem#getFont()}'s label size for a specified
+ * {@link DCell}.
+ *
+ * @param swtBotTableEditor
+ * the editor bot owning the swt {@link TreeItem} referencing the
+ * specified {@link DCell}
+ * @param dCell
+ * the {@link DCell}
+ * @param expectedLabelSize
+ * expected size of the label
+ */
+ public static void checkTreeItemLabelSize(SWTBotEditor swtBotTableEditor, DCell dCell, int expectedLabelSize) {
TreeItem treeItem = TreeUtils.getTreeItem(swtBotTableEditor, dCell.getLine());
int dCellIndex = new DCellQuery(dCell).getColumnIndex();
int treeItemLabelSize = TreeUtils.getWidgetLabelSize(treeItem, dCellIndex + 1);
- Assert.assertEquals("The TreeItem label size should corresponds to its DCell.currentStyle.labelSize", labelSize, treeItemLabelSize);
+ Assert.assertEquals("The TreeItem label size should corresponds to its DCell.currentStyle.labelSize", expectedLabelSize, treeItemLabelSize);
}
/**
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/vsm.odesign b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/vsm.odesign
index ec90a0104d..9aa5d35346 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/vsm.odesign
+++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/vsm.odesign
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
-<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:description_2="http://www.eclipse.org/sirius/table/description/1.1.0" xmlns:description_3="http://www.eclipse.org/sirius/tree/description/1.0.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" version="8.0.0">
+<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:description_2="http://www.eclipse.org/sirius/table/description/1.1.0" xmlns:description_3="http://www.eclipse.org/sirius/tree/description/1.0.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" version="10.1.0.201507101000">
<ownedViewpoints name="vsm">
<ownedRepresentations xsi:type="description_1:DiagramDescription" name="Diagram" domainClass="EPackage">
<containerMappings name="Package" domainClass="EPackage">
- <style xsi:type="style:FlatContainerStyleDescription">
+ <style xsi:type="style:FlatContainerStyleDescription" arcWidth="1" arcHeight="1" borderSizeComputationExpression="1">
<borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
<labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
<backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
@@ -12,6 +12,11 @@
</containerMappings>
</ownedRepresentations>
<ownedRepresentations xsi:type="description_2:EditionTableDescription" name="Table">
+ <ownedLineMappings>
+ <defaultForeground>
+ <foreGroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ </defaultForeground>
+ </ownedLineMappings>
<ownedCreateLine>
<variables name="root" documentation="The semantic element of the table."/>
<variables name="element" documentation="The semantic currently edited element."/>
@@ -27,6 +32,12 @@
<createColumn/>
</ownedRepresentations>
<ownedRepresentations xsi:type="description_3:TreeDescription" name="Tree">
+ <subItemMappings semanticCandidatesExpression="feature:eAllContents">
+ <defaultStyle>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
+ </defaultStyle>
+ </subItemMappings>
<dropTools forceRefresh="true">
<oldContainer name="oldContainer"/>
<newContainer name="newContainer"/>
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RefreshWithCustomizedStyleTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RefreshWithCustomizedStyleTests.java
index faccd95e63..36edea8369 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RefreshWithCustomizedStyleTests.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RefreshWithCustomizedStyleTests.java
@@ -11,30 +11,46 @@
package org.eclipse.sirius.tests.swtbot;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
import org.eclipse.gmf.runtime.notation.FontStyle;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.sirius.diagram.DDiagramElement;
+import org.eclipse.sirius.diagram.DNode;
import org.eclipse.sirius.diagram.DiagramPackage;
import org.eclipse.sirius.diagram.EdgeStyle;
import org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery;
import org.eclipse.sirius.diagram.ui.business.internal.query.CustomizableQuery;
+import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeEditPart;
import org.eclipse.sirius.diagram.ui.internal.refresh.diagram.ViewPropertiesSynchronizer;
import org.eclipse.sirius.tests.support.api.TestsUtil;
+import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusHelper;
import org.eclipse.sirius.viewpoint.FontFormat;
import org.eclipse.sirius.viewpoint.Style;
+import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+
+import com.google.common.collect.Iterables;
/**
* Test the style customization features.
@@ -46,6 +62,47 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
public class RefreshWithCustomizedStyleTests extends AbstractRefreshWithCustomizedStyleOnCompleteExampleTest {
/**
+ * A condition that wait for a text widget to be available in the property
+ * view.
+ *
+ * @author <a href="mailto:steve.monnier@obeo.fr">Steve Monnier</a>
+ *
+ */
+ private final class TextWidgetAppearanceCondition extends DefaultCondition {
+ /**
+ * Current {@link SWTBot} of the property view.
+ */
+ private final SWTBot propertiesBot;
+
+ /**
+ * @param propertiesBot
+ * Current {@link SWTBot} of the property view.
+ */
+ private TextWidgetAppearanceCondition(SWTBot propertiesBot) {
+ this.propertiesBot = propertiesBot;
+ }
+
+ @Override
+ public boolean test() throws Exception {
+ try {
+ propertiesBot.text();
+ } catch (WidgetNotFoundException wnfe) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "no text widget found in the properties view";
+ }
+ }
+
+ private static final String PROPERTIES = "Properties";
+
+ private static final String STYLE = "Style";
+
+ /**
* Test all GMF Note features customization.
*
* @throws Exception
@@ -305,6 +362,97 @@ public class RefreshWithCustomizedStyleTests extends AbstractRefreshWithCustomiz
testStyleCustomization(superTypeEditPartBot);
}
+ /**
+ * Test that label size customization has a minimal value of 1.
+ *
+ * @throws Exception
+ * thrown cause failure
+ */
+ public void testLabelSizeCustomization() throws Exception {
+ editor.select(eClass1WithSquareStyleBot);
+ // set the focus on the Properties view
+ bot.viewByTitle(PROPERTIES).setFocus();
+ // set the focus on the Style tab
+ SWTBotSiriusHelper.selectPropertyTabItem(STYLE);
+
+ // Access the Label Size field
+ final SWTBot propertiesBot = bot.viewByTitle(PROPERTIES).bot();
+ SWTBotTree tree = propertiesBot.tree();
+ tree.expandNode("Misc").select().getNode("Label Size").select().click();
+ SWTBotText text = propertiesBot.text();
+ assertEquals("Initial value of the Label Size is expected to be 8", "8", text.getText());
+
+ // Validate the font size from the graphical element
+ DNode eClass1WithSquareStyleDNode = (DNode) ((DNodeEditPart) eClass1WithSquareStyleBot.part()).resolveSemanticElement();
+ Style style = eClass1WithSquareStyleDNode.getStyle();
+ LabelEditPart labelEditPart = Iterables.getOnlyElement(Iterables.filter(((GraphicalEditPart) eClass1WithSquareStyleBot.part()).getChildren(), LabelEditPart.class));
+ FontData[] fontData = labelEditPart.getFigure().getFont().getFontData();
+ int labelSize = fontData[0].getHeight();
+ assertEquals("Initial value of the Label Size is expected to be 8", 8, labelSize);
+
+ // Set label size value as 3
+ text.setText("3");
+ // Change focus to validate Label Size change
+ editor.setFocus();
+ bot.viewByTitle(PROPERTIES).setFocus();
+ tree.expandNode("Misc").select().getNode("Label Size").select().click();
+ bot.waitUntil(new TextWidgetAppearanceCondition(propertiesBot));
+ text = propertiesBot.text();
+ assertEquals("Value of the Label Size is expected to have been changed to 3", "3", text.getText());
+ fontData = labelEditPart.getFigure().getFont().getFontData();
+ labelSize = fontData[0].getHeight();
+ assertEquals("Value of the Label Size is expected to have been changed to 3", 3, labelSize);
+
+ // Set label size value as 0
+ text.setText("0");
+ // Change focus to validate Label Size change
+ editor.setFocus();
+ bot.viewByTitle(PROPERTIES).setFocus();
+ tree.expandNode("Misc").select().getNode("Label Size").select().click();
+ bot.waitUntil(new TextWidgetAppearanceCondition(propertiesBot));
+ text = propertiesBot.text();
+ assertEquals("Value of the Label Size is expected to have been changed to 1, the minimal value", "1", text.getText());
+ fontData = labelEditPart.getFigure().getFont().getFontData();
+ labelSize = fontData[0].getHeight();
+ assertEquals("Value of the Label Size is expected to have been changed to 1", 1, labelSize);
+
+ // Test to modify the property programmatically
+ Style originalStyle = eClass1WithSquareStyleDNode.getStyle();
+ CustomizableQuery customizableQuery = new CustomizableQuery(originalStyle);
+ Collection<String> customizableFeatureNames = customizableQuery.getCustomizableFeatureNames();
+ for (String customizableFeatureName : customizableFeatureNames) {
+ if ("labelSize".equals(customizableFeatureName)) {
+ // Validate that style label size feature is set as 1
+ EStructuralFeature feature = originalStyle.eClass().getEStructuralFeature(customizableFeatureName);
+ style = eClass1WithSquareStyleDNode.getStyle();
+ Object currentValue = style.eGet(feature);
+ assertEquals("Value of the Label Size is expected to have been changed to 1", 1, currentValue);
+ TransactionalEditingDomain domain = localSession.getOpenedSession().getTransactionalEditingDomain();
+
+ // Set style label size as 3
+ Command customizeStyleCmd = SetCommand.create(domain, style, feature, 3);
+ domain.getCommandStack().execute(customizeStyleCmd);
+ currentValue = style.eGet(feature);
+ assertEquals("Value of the Label Size is expected to have been changed to 3", 3, currentValue);
+ fontData = labelEditPart.getFigure().getFont().getFontData();
+ labelSize = fontData[0].getHeight();
+ assertEquals("Value of the Label Size is expected to have been changed to 3", 3, labelSize);
+
+ // Set style label size as 0
+ customizeStyleCmd = SetCommand.create(domain, style, feature, 0);
+ domain.getCommandStack().execute(customizeStyleCmd);
+ currentValue = style.eGet(feature);
+
+ // Validate that the style label size is set as 0 but that the
+ // diagram element font is set as 1
+ assertEquals("Value of the Label Size is expected to have been changed to 0", 0, currentValue);
+ fontData = labelEditPart.getFigure().getFont().getFontData();
+ labelSize = fontData[0].getHeight();
+ assertEquals("Value of the Label Size is expected to have been changed to 1", 1, labelSize);
+ }
+ }
+ }
+
private void testStyleCustomization(SWTBotGefEditPart swtBotGefEditPart) throws Exception {
// Not available in 4.x specific Tabbar
if (TestsUtil.isDynamicTabbar()) {
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/VSMFieldTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/VSMFieldTest.java
index 494f377fed..528209e1fb 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/VSMFieldTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/VSMFieldTest.java
@@ -25,6 +25,7 @@ import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.Result;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotSpinner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
@@ -97,6 +98,39 @@ public class VSMFieldTest extends AbstractSiriusSwtBotGefTestCase {
}
/**
+ * Tests that on a style in a diagram description, the label size minimal
+ * value is 1.
+ */
+ public void testLabelSizeMinimalValueOnDiagramStyle() {
+ // Open VSM
+ SWTBotVSMEditor odesignEditor = openViewpointSpecificationModel(VSM);
+ // Check background style element choice
+ checkDiagramStyleLabelSize(odesignEditor);
+ }
+
+ /**
+ * Tests that on a style in a table description, the label size minimal
+ * value is 1.
+ */
+ public void testLabelSizeMinimalValueOnTableStyle() {
+ // Open VSM
+ SWTBotVSMEditor odesignEditor = openViewpointSpecificationModel(VSM);
+ // Check background style element choice
+ checkTableStyleLabelSize(odesignEditor);
+ }
+
+ /**
+ * Tests that on a style in a table description, the label size minimal
+ * value is 1.
+ */
+ public void testLabelSizeMinimalValueOnTreeStyle() {
+ // Open VSM
+ SWTBotVSMEditor odesignEditor = openViewpointSpecificationModel(VSM);
+ // Check background style element choice
+ checkTreeStyleLabelSize(odesignEditor);
+ }
+
+ /**
* Test that for Create Line Tool, 'Create View' operation is not available
* in menu.
*/
@@ -321,4 +355,70 @@ public class VSMFieldTest extends AbstractSiriusSwtBotGefTestCase {
assertEquals("Third element must be : " + gradientTopToBottom, gradientTopToBottom, ccomboBox.items()[2]);
}
+
+ /**
+ * Check that the label size of a style in a diagram description cannot be
+ * set as 0.
+ *
+ * @param odesignEditor
+ */
+ private void checkDiagramStyleLabelSize(SWTBotVSMEditor odesignEditor) {
+ // Retrieve properties value of background style choices
+ String gradientLeftToRight = DiagramUIPlugin.getPlugin().getString(GRADIENT_TO_LEFT);
+ assertNotNull("The properties '" + GRADIENT_TO_LEFT + "' should be available", gradientLeftToRight);
+ String gradientTopToBottom = DiagramUIPlugin.getPlugin().getString(GRADIENT_TO_BOTTOM);
+ assertNotNull("The properties '" + GRADIENT_TO_BOTTOM + "' should be available", gradientTopToBottom);
+ String liquid_oblique = DiagramUIPlugin.getPlugin().getString(LIQUID_OBLIQUE);
+ assertNotNull("The properties '" + LIQUID_OBLIQUE + "' should be available", liquid_oblique);
+ String gradient = DiagramUIPlugin.getPlugin().getString(FLAT_CONTAINER_STYLE);
+
+ // expands the tree : Container style description
+ SWTBotTree tree = odesignEditor.bot().tree();
+ tree.expandNode(ODESIGN).expandNode(GROUP).expandNode("vsm").expandNode("Diagram").expandNode("Package").expandNode(gradient + " white to light_gray").select();
+ processLabelSizeTests("8");
+ }
+
+ /**
+ * Check that the label size of a style in a table description cannot be set
+ * as 0.
+ *
+ * @param odesignEditor
+ */
+ private void checkTableStyleLabelSize(SWTBotVSMEditor odesignEditor) {
+ // expands the tree : Container style description
+ SWTBotTree tree = odesignEditor.bot().tree();
+ tree.expandNode(ODESIGN).expandNode(GROUP).expandNode("vsm").expandNode("Table").expandNode("Line").expandNode("Foreground 12").select();
+ processLabelSizeTests("12");
+ }
+
+ /**
+ * Check that the label size of a style in a table description cannot be set
+ * as 0.
+ *
+ * @param odesignEditor
+ */
+ private void checkTreeStyleLabelSize(SWTBotVSMEditor odesignEditor) {
+ // expands the tree : Tree item style description
+ SWTBotTree tree = odesignEditor.bot().tree();
+ tree.expandNode(ODESIGN).expandNode(GROUP).expandNode("vsm").expandNode("Tree").expandNode("Tree").expandNode("feature:name").select();
+ processLabelSizeTests("8");
+ }
+
+ /**
+ *
+ */
+ private void processLabelSizeTests(String initialValue) {
+ // set the focus on the Properties view
+ bot.viewByTitle(PROPERTIES).setFocus();
+ // set the focus on the General tab
+ SWTBotSiriusHelper.selectPropertyTabItem(LABEL);
+
+ // check that background style field choices are correct
+ SWTBotSpinner ccomboBox = bot.viewByTitle(PROPERTIES).bot().spinner();
+ assertEquals("Initial value of the Label Size is expected to be " + initialValue, initialValue, ccomboBox.getText());
+ ccomboBox.setSelection(3);
+ assertEquals("Value of the Label Size is expected to have been changed to 3", "3", ccomboBox.getText());
+ ccomboBox.setSelection(0);
+ assertEquals("Value of the Label Size is expected to have been changed to 1, the minimal value", "1", ccomboBox.getText());
+ }
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/TableUIRefreshTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/TableUIRefreshTests.java
index c8aa711891..18bdaa9749 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/TableUIRefreshTests.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/TableUIRefreshTests.java
@@ -238,6 +238,13 @@ public class TableUIRefreshTests extends AbstractTreeSiriusSWTBotGefTestCase {
TreeUtils.checkTreeItemLabelSize(tableEditorBot, firstDCellOfSecondDLine);
+ // Test a label size down
+ changeDTreeItemLabelStyleCmd = SetCommand.create(transactionalEditingDomain, dTableElementStyle, TablePackage.Literals.DTABLE_ELEMENT_STYLE__LABEL_SIZE, 0);
+ commandStack.execute(changeDTreeItemLabelStyleCmd);
+
+ // Validates that even if the table model element feature label size is
+ // 0, the graphical table item label size is 1
+ TreeUtils.checkTreeItemLabelSize(tableEditorBot, firstDCellOfSecondDLine, 1);
}
/**
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeUIRefreshTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeUIRefreshTests.java
index 904421be70..c2599f101a 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeUIRefreshTests.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeUIRefreshTests.java
@@ -211,6 +211,13 @@ public class TreeUIRefreshTests extends AbstractTreeSiriusSWTBotGefTestCase {
TreeUtils.checkTreeItemLabelSize(treeEditorBot, thirdDTreeItem);
+ // Test a label size down
+ changeDTreeItemLabelStyleCmd = SetCommand.create(transactionalEditingDomain, treeItemStyle, ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE, 0);
+ commandStack.execute(changeDTreeItemLabelStyleCmd);
+
+ // Validates that even if the tree model element feature label size is
+ // 0, the graphical tree item label size is 1
+ TreeUtils.checkTreeItemLabelSize(treeEditorBot, thirdDTreeItem, 1);
}
/**
diff --git a/plugins/org.eclipse.sirius.tree/src/org/eclipse/sirius/tree/business/internal/refresh/DTreeElementSynchronizerSpec.java b/plugins/org.eclipse.sirius.tree/src/org/eclipse/sirius/tree/business/internal/refresh/DTreeElementSynchronizerSpec.java
index 7f5d6f687c..f2460dcb53 100644
--- a/plugins/org.eclipse.sirius.tree/src/org/eclipse/sirius/tree/business/internal/refresh/DTreeElementSynchronizerSpec.java
+++ b/plugins/org.eclipse.sirius.tree/src/org/eclipse/sirius/tree/business/internal/refresh/DTreeElementSynchronizerSpec.java
@@ -196,7 +196,7 @@ public class DTreeElementSynchronizerSpec extends DTreeElementSynchronizerImpl {
if (bestTreeItemStyle.getLabelFormat() != null && !isEqual(style.getLabelFormat(), bestTreeItemStyle.getLabelFormat())) {
FontFormatHelper.setFontFormat(style.getLabelFormat(), bestTreeItemStyle.getLabelFormat());
}
- if (bestTreeItemStyle.getLabelSize() != -1 && style.getLabelSize() != bestTreeItemStyle.getLabelSize()) {
+ if (bestTreeItemStyle.getLabelSize() > 0 && style.getLabelSize() != bestTreeItemStyle.getLabelSize()) {
style.setLabelSize(bestTreeItemStyle.getLabelSize());
}
if (bestTreeItemStyle.getLabelAlignment() != null && style.getLabelAlignment() != bestTreeItemStyle.getLabelAlignment()) {

Back to the top