Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMélanie Bats2015-01-15 13:20:17 +0000
committerLaurent Redor2015-05-18 15:36:44 +0000
commitecdfe17e35aa9e6c802adfbca9767a0959266950 (patch)
tree932592425224e8352cabeb6899f1b943a95bdc3f
parent0310bf9e08bd6a301b4ef012445c65df9025a2e7 (diff)
downloadorg.eclipse.sirius-ecdfe17e35aa9e6c802adfbca9767a0959266950.tar.gz
org.eclipse.sirius-ecdfe17e35aa9e6c802adfbca9767a0959266950.tar.xz
org.eclipse.sirius-ecdfe17e35aa9e6c802adfbca9767a0959266950.zip
[424422] Update diagram, table, tree and tests to support underline and
strike through in label format Update the diagram, tree and table figures to support the new styles. Update the related tests. All compilations problems of the previous commit are fixed. The test suites are KO for this commit because a migration participant is needed. It will be added in the next commit. Bug: 424422 Change-Id: I0aacf17d85f631d2ebb8f01c41ed663cce088c54 Signed-off-by: Mélanie Bats <melanie.bats@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/query/ViewQuery.java1
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/DiagramNameEditPartOperation.java5
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramElementEditPartOperation.java4
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/AbstractGeneratedDiagramNameEditPart.java29
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/BundledImageEditPart.java2
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/ViewPropertiesSynchronizer.java58
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/listeners/FontFormatUpdater.java38
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/StylePropertySection.java69
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/BestStyleDescriptionRegistry.java7
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/StyleHelper.java9
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release Notes.html2
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release Notes.textile2
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/specifier/diagrams/Diagrams.html4
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/specifier/diagrams/Diagrams.textile2
-rw-r--r--plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/DTableViewerManager.java4
-rw-r--r--plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/DTableColumnLabelProvider.java67
-rw-r--r--plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/TableUIUpdaterRunnable.java20
-rw-r--r--plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableElementSynchronizerSpec.java6
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/refresh/EdgeWithConditionalStyleTest.java9
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/refresh/RefreshWithCustomizedStyleTests.java13
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/RepairOnStyleCustomizationsTest.java15
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/modeler/ecore/design/EntitiesDiagramToolsTests.java10
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/StyleHelperTest.java18
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/customization/RefreshWithCustomizationTests.java42
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableCellStylesTest.java17
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableSynchronizerTest.java15
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/TreeItemLabelFontFormatQuery.java2
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/SWTBotUtils.java19
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/tree/TreeUtils.java21
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractFontModificationTest.java29
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractRefreshWithCustomizedStyleOnCompleteExampleTest.java20
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/HideRevealDiagramElementsLabelsTest.java11
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/LabelFontModificationsTest.java13
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RefreshWithCustomizedStyleTests.java12
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/condition/CheckTreeItemFontFormat.java19
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/AbstractTreeSiriusSWTBotGefTestCase.java19
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeItemStyleDescriptionTest.java33
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeUIRefreshTests.java2
-rw-r--r--plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeViewerManager.java15
-rw-r--r--plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/provider/DTreeItemLabelProvider.java58
-rw-r--r--plugins/org.eclipse.sirius.tree/src/org/eclipse/sirius/tree/business/internal/refresh/DTreeElementSynchronizerSpec.java5
-rw-r--r--plugins/org.eclipse.sirius.ui/plugin.properties4
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/color/VisualBindingManager.java60
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/DefaultFontStyler.java71
44 files changed, 622 insertions, 259 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/query/ViewQuery.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/query/ViewQuery.java
index 29d34d00f2..2e2118bdcc 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/query/ViewQuery.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/query/ViewQuery.java
@@ -97,6 +97,7 @@ public class ViewQuery {
private static boolean isStylePropertyExistingInSiriusStyleModel(EAttribute eAttribute) {
// CHECKSTYLE:OFF
boolean isStylePropertyExistingInSiriusStyleModel = eAttribute == NotationPackage.Literals.FONT_STYLE__BOLD || eAttribute == NotationPackage.Literals.FONT_STYLE__ITALIC
+ || eAttribute == NotationPackage.Literals.FONT_STYLE__UNDERLINE || eAttribute == NotationPackage.Literals.FONT_STYLE__STRIKE_THROUGH
|| eAttribute == NotationPackage.Literals.FONT_STYLE__FONT_COLOR || eAttribute == NotationPackage.Literals.FONT_STYLE__FONT_HEIGHT
|| eAttribute == NotationPackage.Literals.FILL_STYLE__FILL_COLOR || eAttribute == NotationPackage.Literals.ROUTING_STYLE__ROUTING
|| eAttribute == NotationPackage.Literals.LINE_STYLE__LINE_COLOR;
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/DiagramNameEditPartOperation.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/DiagramNameEditPartOperation.java
index dec94746d8..bba31fcdb3 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/DiagramNameEditPartOperation.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/DiagramNameEditPartOperation.java
@@ -101,14 +101,15 @@ public final class DiagramNameEditPartOperation {
* @param style
*/
private static void refreshFont(final IDiagramNameEditPart self, final IFigure figure, BasicLabelStyle style) {
+ // Set basic label style
final BasicLabelStyle lStyle = style;
figure.setFont(VisualBindingManager.getDefault().getFontFromLabelStyle(lStyle, DiagramNameEditPartOperation.getFontName(self)));
final FontStyle fontStyle = DiagramNameEditPartOperation.getFontStyle(self);
if (fontStyle != null && figure instanceof SiriusWrapLabel) {
final SiriusWrapLabel wrap = (SiriusWrapLabel) figure;
- wrap.setTextUnderline(fontStyle.isUnderline());
- wrap.setTextStrikeThrough(fontStyle.isStrikeThrough());
+ wrap.setTextUnderline(VisualBindingManager.getDefault().isUnderlineFromLabelStyle(lStyle));
+ wrap.setTextStrikeThrough(VisualBindingManager.getDefault().isStrikeThroughFromLabelStyle(lStyle));
}
RGBValues labelRGBColor = lStyle.getLabelColor();
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramElementEditPartOperation.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramElementEditPartOperation.java
index f55a8311e9..671f03f398 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramElementEditPartOperation.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramElementEditPartOperation.java
@@ -506,8 +506,8 @@ public final class DiagramElementEditPartOperation {
final FontStyle fontStyle = (FontStyle) self.getNotationView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
if (fontStyle != null && figure instanceof SiriusWrapLabel) {
final SiriusWrapLabel wrap = (SiriusWrapLabel) figure;
- wrap.setTextUnderline(fontStyle.isUnderline());
- wrap.setTextStrikeThrough(fontStyle.isStrikeThrough());
+ wrap.setTextUnderline(VisualBindingManager.getDefault().isUnderlineFromLabelStyle(lStyle));
+ wrap.setTextStrikeThrough(VisualBindingManager.getDefault().isStrikeThroughFromLabelStyle(lStyle));
}
RGBValues labelRGBColor = lStyle.getLabelColor();
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/AbstractGeneratedDiagramNameEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/AbstractGeneratedDiagramNameEditPart.java
index 0a5fb3b2c0..0c778bedc4 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/AbstractGeneratedDiagramNameEditPart.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/AbstractGeneratedDiagramNameEditPart.java
@@ -358,8 +358,6 @@ public abstract class AbstractGeneratedDiagramNameEditPart extends AbstractDiagr
refreshLabel();
refreshFont();
refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
}
/**
@@ -375,26 +373,6 @@ public abstract class AbstractGeneratedDiagramNameEditPart extends AbstractDiagr
}
/**
- * @not-generated
- */
- protected void refreshUnderline() {
- final FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof SiriusWrapLabel) {
- ((SiriusWrapLabel) getFigure()).setTextUnderline(style.isUnderline());
- }
- }
-
- /**
- * @not-generated
- */
- protected void refreshStrikeThrough() {
- final FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof SiriusWrapLabel) {
- ((SiriusWrapLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
* @was-generated
*/
@Override
@@ -465,12 +443,9 @@ public abstract class AbstractGeneratedDiagramNameEditPart extends AbstractDiagr
if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
final Integer c = (Integer) event.getNewValue();
setFontColor(DiagramColorRegistry.getInstance().getColor(c));
- } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
- refreshUnderline();
- } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
- refreshStrikeThrough();
} else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature)
- || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
refreshFont();
} else {
if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/BundledImageEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/BundledImageEditPart.java
index 53d9b4e827..4e541ea215 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/BundledImageEditPart.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/BundledImageEditPart.java
@@ -115,7 +115,7 @@ public class BundledImageEditPart extends AbstractNotSelectableShapeNodeEditPart
DiagramPlugin.getDefault().logWarning("The element is not a BundledImage");
final BundledImage bundle = DiagramFactory.eINSTANCE.createBundledImage();
bundle.setShape(BundledImageShape.SQUARE_LITERAL);
- bundle.setLabelFormat(FontFormat.NORMAL_LITERAL);
+ bundle.getLabelFormat().clear();
bundle.setLabelSize(10);
bundle.setColor(VisualBindingManager.getDefault().getRGBValuesFor(SystemColors.BLUE_LITERAL));
bundle.setBorderColor(VisualBindingManager.getDefault().getRGBValuesFor(SystemColors.DARK_BLUE_LITERAL));
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 5212de89b2..d5a9cd2096 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
@@ -25,6 +25,7 @@ import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.Style;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.sirius.business.api.color.RGBValuesProvider;
+import org.eclipse.sirius.business.api.metamodel.helper.FontFormatHelper;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
import org.eclipse.sirius.diagram.BeginLabelStyle;
import org.eclipse.sirius.diagram.BorderedStyle;
@@ -59,6 +60,8 @@ import org.eclipse.sirius.viewpoint.description.FixedColor;
import org.eclipse.sirius.viewpoint.description.SystemColors;
import org.eclipse.swt.graphics.RGB;
+import com.google.common.collect.Lists;
+
/**
* Update the GMF {@link View} properties according to Sirius properties and
* vice versa.
@@ -77,6 +80,8 @@ public class ViewPropertiesSynchronizer {
GMF_TO_DDIAGRAMELEMENT_STYLE_FEATURES_MAPPING.put(NotationPackage.Literals.FONT_STYLE__FONT_HEIGHT, ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE);
GMF_TO_DDIAGRAMELEMENT_STYLE_FEATURES_MAPPING.put(NotationPackage.Literals.FONT_STYLE__ITALIC, ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
GMF_TO_DDIAGRAMELEMENT_STYLE_FEATURES_MAPPING.put(NotationPackage.Literals.FONT_STYLE__BOLD, ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
+ GMF_TO_DDIAGRAMELEMENT_STYLE_FEATURES_MAPPING.put(NotationPackage.Literals.FONT_STYLE__UNDERLINE, ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
+ GMF_TO_DDIAGRAMELEMENT_STYLE_FEATURES_MAPPING.put(NotationPackage.Literals.FONT_STYLE__STRIKE_THROUGH, ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
GMF_TO_DDIAGRAMELEMENT_STYLE_FEATURES_MAPPING.put(NotationPackage.Literals.FONT_STYLE__FONT_COLOR, ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_COLOR);
GMF_TO_DDIAGRAMELEMENT_STYLE_FEATURES_MAPPING.put(NotationPackage.Literals.FONT_STYLE__FONT_HEIGHT, ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE);
}
@@ -125,23 +130,18 @@ public class ViewPropertiesSynchronizer {
private void updateGMFFontStyle(View view, BasicLabelStyle basicLabelStyle) {
FontStyle fontStyle = (FontStyle) createOrFindStyle(view, NotationPackage.eINSTANCE.getFontStyle());
- switch (basicLabelStyle.getLabelFormat().getValue()) {
- case FontFormat.BOLD:
- fontStyle.setBold(true);
- break;
- case FontFormat.ITALIC:
- fontStyle.setItalic(true);
- break;
- case FontFormat.BOLD_ITALIC:
- fontStyle.setBold(true);
- fontStyle.setItalic(true);
- break;
- case FontFormat.NORMAL:
- fontStyle.setBold(false);
- fontStyle.setItalic(false);
- break;
- default:
- break;
+ List<FontFormat> labelFormat = basicLabelStyle.getLabelFormat();
+ if (fontStyle.isBold() != labelFormat.contains(FontFormat.BOLD_LITERAL)) {
+ fontStyle.setBold(labelFormat.contains(FontFormat.BOLD_LITERAL));
+ }
+ if (fontStyle.isItalic() != labelFormat.contains(FontFormat.ITALIC_LITERAL)) {
+ fontStyle.setItalic(labelFormat.contains(FontFormat.ITALIC_LITERAL));
+ }
+ if (fontStyle.isUnderline() != labelFormat.contains(FontFormat.UNDERLINE_LITERAL)) {
+ fontStyle.setUnderline(labelFormat.contains(FontFormat.UNDERLINE_LITERAL));
+ }
+ if (fontStyle.isStrikeThrough() != labelFormat.contains(FontFormat.STRIKE_THROUGH_LITERAL)) {
+ fontStyle.setStrikeThrough(labelFormat.contains(FontFormat.STRIKE_THROUGH_LITERAL));
}
fontStyle.setFontHeight(basicLabelStyle.getLabelSize());
@@ -319,17 +319,25 @@ public class ViewPropertiesSynchronizer {
}
private void updateLabelStyle(View notationView, BasicLabelStyle labelStyle) {
+
if (labelStyle != null) {
+ List<FontFormat> newFontFormats = Lists.newArrayList();
final FontStyle fontStyle = (FontStyle) createOrFindStyle(notationView, NotationPackage.eINSTANCE.getFontStyle());
- if (fontStyle.isBold() && fontStyle.isItalic()) {
- labelStyle.setLabelFormat(FontFormat.BOLD_ITALIC_LITERAL);
- } else if (fontStyle.isBold()) {
- labelStyle.setLabelFormat(FontFormat.BOLD_LITERAL);
- } else if (fontStyle.isItalic()) {
- labelStyle.setLabelFormat(FontFormat.ITALIC_LITERAL);
- } else {
- labelStyle.setLabelFormat(FontFormat.NORMAL_LITERAL);
+
+ if (fontStyle.isBold()) {
+ newFontFormats.add(FontFormat.BOLD_LITERAL);
+ }
+ if (fontStyle.isItalic()) {
+ newFontFormats.add(FontFormat.ITALIC_LITERAL);
+ }
+ if (fontStyle.isUnderline()) {
+ newFontFormats.add(FontFormat.UNDERLINE_LITERAL);
}
+ if (fontStyle.isStrikeThrough()) {
+ newFontFormats.add(FontFormat.STRIKE_THROUGH_LITERAL);
+ }
+
+ FontFormatHelper.setFontFormat(labelStyle.getLabelFormat(), newFontFormats);
labelStyle.setLabelSize(fontStyle.getFontHeight());
}
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/listeners/FontFormatUpdater.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/listeners/FontFormatUpdater.java
index a5f37885b7..c188931178 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/listeners/FontFormatUpdater.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/listeners/FontFormatUpdater.java
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.sirius.diagram.ui.internal.refresh.listeners;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@@ -31,6 +33,7 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
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.business.api.metamodel.helper.FontFormatHelper;
import org.eclipse.sirius.diagram.DDiagramElement;
import org.eclipse.sirius.diagram.EdgeStyle;
import org.eclipse.sirius.diagram.ui.internal.refresh.SynchronizeDDiagramElementStylePropertiesCommand;
@@ -52,8 +55,12 @@ import org.eclipse.sirius.viewpoint.ViewpointPackage;
public class FontFormatUpdater extends ResourceSetListenerImpl {
private static final NotificationFilter FEATURES_TO_REFACTOR_FILTER = NotificationFilter.NOT_TOUCH
- .and(NotificationFilter.createFeatureFilter(NotationPackage.eINSTANCE.getFontStyle_Bold()).or(NotificationFilter.createFeatureFilter(NotationPackage.eINSTANCE.getFontStyle_Italic())))
- .or((NotificationFilter.createFeatureFilter(NotationPackage.eINSTANCE.getFontStyle_Bold())).and(NotificationFilter.createFeatureFilter(NotationPackage.eINSTANCE.getFontStyle_Italic())))
+ .and(NotificationFilter.createFeatureFilter(NotationPackage.eINSTANCE.getFontStyle_Bold()).or(NotificationFilter.createFeatureFilter(NotationPackage.eINSTANCE.getFontStyle_Italic()))
+ .or(NotificationFilter.createFeatureFilter(NotationPackage.eINSTANCE.getFontStyle_Underline()))
+ .or(NotificationFilter.createFeatureFilter(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough())))
+ .or((NotificationFilter.createFeatureFilter(NotationPackage.eINSTANCE.getFontStyle_Bold())).and(NotificationFilter.createFeatureFilter(NotationPackage.eINSTANCE.getFontStyle_Italic()))
+ .and(NotificationFilter.createFeatureFilter(NotationPackage.eINSTANCE.getFontStyle_Underline()))
+ .and(NotificationFilter.createFeatureFilter(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough())))
.or(NotificationFilter.createFeatureFilter(NotationPackage.eINSTANCE.getFontStyle_FontHeight()))
.or(NotificationFilter.createFeatureFilter(NotationPackage.eINSTANCE.getFontStyle_FontColor()));
@@ -174,18 +181,27 @@ public class FontFormatUpdater extends ResourceSetListenerImpl {
return isViewFontStylePropertiesDifferentOfGMFOne;
}
+ @SuppressWarnings("unchecked")
private Object convertToSiriusPropertyValue(org.eclipse.gmf.runtime.notation.Style gmfStyle, EStructuralFeature gmfStyleAttribute) {
Object gmfStylePropertyValue = gmfStyle.eGet(gmfStyleAttribute);
- if (gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__BOLD || gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__ITALIC) {
+ if (gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__BOLD || gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__ITALIC
+ || gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__UNDERLINE || gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__STRIKE_THROUGH) {
FontStyle gmfFontStyle = (FontStyle) gmfStyle;
- if (gmfFontStyle.isBold() && gmfFontStyle.isItalic()) {
- gmfStylePropertyValue = FontFormat.BOLD_ITALIC_LITERAL;
- } else if (gmfFontStyle.isBold()) {
- gmfStylePropertyValue = FontFormat.BOLD_LITERAL;
- } else if (gmfFontStyle.isItalic()) {
- gmfStylePropertyValue = FontFormat.ITALIC_LITERAL;
- } else {
- gmfStylePropertyValue = FontFormat.NORMAL_LITERAL;
+ gmfStylePropertyValue = new ArrayList<FontFormat>();
+ if (gmfFontStyle.isBold()) {
+ FontFormatHelper.setFontFormat(((List<FontFormat>) gmfStylePropertyValue), FontFormat.BOLD_LITERAL);
+ }
+ if (gmfFontStyle.isItalic()) {
+ FontFormatHelper.setFontFormat(((List<FontFormat>) gmfStylePropertyValue), FontFormat.ITALIC_LITERAL);
+ }
+ if (gmfFontStyle.isUnderline()) {
+ FontFormatHelper.setFontFormat(((List<FontFormat>) gmfStylePropertyValue), FontFormat.UNDERLINE_LITERAL);
+ }
+ if (gmfFontStyle.isStrikeThrough()) {
+ FontFormatHelper.setFontFormat(((List<FontFormat>) gmfStylePropertyValue), FontFormat.STRIKE_THROUGH_LITERAL);
+ }
+ if (!gmfFontStyle.isBold() && !gmfFontStyle.isItalic() && !gmfFontStyle.isUnderline() && !gmfFontStyle.isStrikeThrough()) {
+ ((List<FontFormat>) gmfStylePropertyValue).clear();
}
} else if (gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__FONT_COLOR) {
FontStyle gmfFontStyle = (FontStyle) gmfStyle;
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 54b81a9972..f02fc2da24 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
@@ -11,6 +11,7 @@
package org.eclipse.sirius.diagram.ui.tools.internal.properties;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.IAdaptable;
@@ -214,38 +215,48 @@ public class StylePropertySection extends SemanticPropertySection {
}
}
+ @SuppressWarnings({ "rawtypes" })
private void updateNotationView(final Object propertyId, final Object value) {
- if (view != null && view.getStyles() != null) {
- for (Object notationStyle : view.getStyles()) {
- if (notationStyle instanceof FontStyle) {
- final FontStyle fontStyle = (FontStyle) notationStyle;
- if (value instanceof FontFormat && propertyId.equals(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT.getName())) {
- if (FontFormat.BOLD_LITERAL == value) {
- fontStyle.setBold(true);
- fontStyle.setItalic(false);
- } else if (FontFormat.ITALIC_LITERAL == value) {
- fontStyle.setBold(false);
- fontStyle.setItalic(true);
- } else if (FontFormat.BOLD_ITALIC_LITERAL == value) {
- fontStyle.setBold(true);
- fontStyle.setItalic(true);
- } else if (FontFormat.NORMAL_LITERAL == value) {
- fontStyle.setBold(false);
- fontStyle.setItalic(false);
+ if (view == null || view.getStyles() == null) {
+ return;
+ }
+ for (Object notationStyle : view.getStyles()) {
+ if (notationStyle instanceof FontStyle) {
+ final FontStyle fontStyle = (FontStyle) notationStyle;
+ if (propertyId.equals(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT.getName())) {
+ // Case bold, italic, underline, strike through
+ if (value instanceof List) {
+ if (fontStyle.isBold() != ((List) value).contains(FontFormat.BOLD_LITERAL)) {
+ fontStyle.setBold(((List) value).contains(FontFormat.BOLD_LITERAL));
}
- } else if (value instanceof Integer && propertyId.equals(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE.getName())) {
- fontStyle.setFontHeight((Integer) value);
- }
- } else if (notationStyle instanceof ConnectorStyle) {
- ConnectorStyle connectorStyle = (ConnectorStyle) notationStyle;
- if (value instanceof EdgeRouting && propertyId.equals(DiagramPackage.Literals.EDGE_STYLE__ROUTING_STYLE.getName())) {
- if (EdgeRouting.MANHATTAN_LITERAL == value) {
- connectorStyle.setRouting(Routing.RECTILINEAR_LITERAL);
- } else if (EdgeRouting.STRAIGHT_LITERAL == value) {
- connectorStyle.setRouting(Routing.MANUAL_LITERAL);
- } else if (EdgeRouting.TREE_LITERAL == value) {
- connectorStyle.setRouting(Routing.TREE_LITERAL);
+ if (fontStyle.isItalic() != ((List) value).contains(FontFormat.ITALIC_LITERAL)) {
+ fontStyle.setItalic(((List) value).contains(FontFormat.ITALIC_LITERAL));
+ }
+ if (fontStyle.isUnderline() != ((List) value).contains(FontFormat.UNDERLINE_LITERAL)) {
+ fontStyle.setUnderline(((List) value).contains(FontFormat.UNDERLINE_LITERAL));
}
+ if (fontStyle.isStrikeThrough() != ((List) value).contains(FontFormat.STRIKE_THROUGH_LITERAL)) {
+ fontStyle.setStrikeThrough(((List) value).contains(FontFormat.STRIKE_THROUGH_LITERAL));
+ }
+ } else {
+ // Case normal font style
+ fontStyle.setBold(false);
+ fontStyle.setItalic(false);
+ fontStyle.setUnderline(false);
+ fontStyle.setStrikeThrough(false);
+ }
+ } else if (value instanceof Integer && propertyId.equals(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE.getName())) {
+ fontStyle.setFontHeight((Integer) value);
+ }
+ } else if (notationStyle instanceof ConnectorStyle) {
+ ConnectorStyle connectorStyle = (ConnectorStyle) notationStyle;
+ if (value instanceof EdgeRouting && propertyId.equals(DiagramPackage.Literals.EDGE_STYLE__ROUTING_STYLE.getName())) {
+ if (EdgeRouting.MANHATTAN_LITERAL == value) {
+ connectorStyle.setRouting(Routing.RECTILINEAR_LITERAL);
+ } else if (EdgeRouting.STRAIGHT_LITERAL == value) {
+ connectorStyle.setRouting(Routing.MANUAL_LITERAL);
+ } else if (EdgeRouting.TREE_LITERAL == value) {
+ connectorStyle.setRouting(Routing.TREE_LITERAL);
}
}
}
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/BestStyleDescriptionRegistry.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/BestStyleDescriptionRegistry.java
index 3504182166..cdc02ca63a 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/BestStyleDescriptionRegistry.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/BestStyleDescriptionRegistry.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.sirius.diagram.business.internal.metamodel.helper;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -186,7 +187,11 @@ public class BestStyleDescriptionRegistry extends HashMap<BestStyleDescriptionKe
instanceClass = Primitives.wrap(instanceClass);
}
Object convertedObject = EcoreUtil.createFromString(eAttributeType, newAttributeValue);
- if (convertedObject != null && instanceClass.isAssignableFrom(convertedObject.getClass())) {
+ if (eAttribute.isMany() && convertedObject != null && instanceClass.isAssignableFrom(convertedObject.getClass())) {
+ List<Object> manyConvertedObject = new ArrayList<Object>();
+ manyConvertedObject.add(convertedObject);
+ realEltToCustomize.eSet(eAttribute, manyConvertedObject);
+ } else if (convertedObject != null && instanceClass.isAssignableFrom(convertedObject.getClass())) {
realEltToCustomize.eSet(eAttribute, convertedObject);
}
}
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 e0176df59d..0f283a56ac 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
@@ -20,6 +20,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.sirius.business.api.logger.RuntimeLoggerManager;
+import org.eclipse.sirius.business.api.metamodel.helper.FontFormatHelper;
import org.eclipse.sirius.common.tools.api.interpreter.EvaluationException;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
import org.eclipse.sirius.common.tools.api.util.EqualityHelper;
@@ -517,7 +518,7 @@ public final class StyleHelper {
}
private void updateBasicLabelStyleFeatures(final BasicLabelStyleDescription description, final BasicLabelStyle style, Option<? extends BasicLabelStyle> previousStyle) {
- final FontFormat format = description.getLabelFormat();
+ final List<FontFormat> format = description.getLabelFormat();
final int size = description.getLabelSize();
if (previousStyle.some() && previousStyle.get().getCustomFeatures().contains(ViewpointPackage.Literals.BASIC_LABEL_STYLE__SHOW_ICON.getName())) {
@@ -540,11 +541,11 @@ public final class StyleHelper {
}
if (previousStyle.some() && previousStyle.get().getCustomFeatures().contains(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT.getName())) {
- style.setLabelFormat(previousStyle.get().getLabelFormat());
+ FontFormatHelper.setFontFormat(style.getLabelFormat(), previousStyle.get().getLabelFormat());
style.getCustomFeatures().add(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT.getName());
} else {
- if (style.getLabelFormat() != format && !style.getCustomFeatures().contains(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT.getName())) {
- style.setLabelFormat(format);
+ if (!style.getLabelFormat().equals(format) && !style.getCustomFeatures().contains(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT.getName())) {
+ FontFormatHelper.setFontFormat(style.getLabelFormat(), format);
}
}
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
index 6522d7dd2b..180b9d1271 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
@@ -47,6 +47,7 @@
<li>The ability to print table representations has been re-introduced.</li>
<li>The quick outline feature has been added for tree and table editors, see documentation for details.</li>
<li>The label of a list or container can now be hidden by the user from the outline, the tabbar or the contextual menu.</li>
+ <li>In the Appearance tab, in addition to Bold and Italic, it is now possible to set the font formatting style to Underline and Strike through.</li>
</ul>
<h3 id="SpecifierVisibleChanges">Specifier-Visible Changes</h3>
<ul>
@@ -64,6 +65,7 @@
<code>Vertical Stack</code> and
<code>Horizontal Stack</code>. They indicates that a container will present its children containers as a vertical/horizontal stack of compartments. These two stack values are experimental.
</li>
+ <li>In addition to Bold and Italic, Underline and Strike through styles have been added on the label font format.</li>
</ul>
<h3 id="APIChanges">API Changes</h3>
<h4 id="Changesinorg.eclipse.sirius">Changes in
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
index 45f00ec63e..05693ebc91 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
@@ -12,6 +12,7 @@ h3. User-Visible Changes
* The ability to print table representations has been re-introduced.
* The quick outline feature has been added for tree and table editors, see documentation for details.
* The label of a list or container can now be hidden by the user from the outline, the tabbar or the contextual menu.
+* In the Appearance tab, in addition to Bold and Italic, it is now possible to set the font formatting style to Underline and Strike through.
h3. Specifier-Visible Changes
@@ -24,6 +25,7 @@ h3. Specifier-Visible Changes
* The hide label per default capability has been added to the container styles.
* Property sections for image paths now have a button next to the text field to open a dialog browsing for images.
* The children presentation property of a ContainerMapping has two new values @Vertical Stack@ and @Horizontal Stack@. They indicates that a container will present its children containers as a vertical/horizontal stack of compartments. These two stack values are experimental.
+* In addition to Bold and Italic, Underline and Strike through styles have been added on the label font format.
h3. API Changes
diff --git a/plugins/org.eclipse.sirius.doc/doc/specifier/diagrams/Diagrams.html b/plugins/org.eclipse.sirius.doc/doc/specifier/diagrams/Diagrams.html
index 5d20cea7ff..d34e405f1c 100644
--- a/plugins/org.eclipse.sirius.doc/doc/specifier/diagrams/Diagrams.html
+++ b/plugins/org.eclipse.sirius.doc/doc/specifier/diagrams/Diagrams.html
@@ -1116,7 +1116,9 @@
<li>
<em>Label Format</em> is used to specify the font style attributes (
<em>Bold</em> and/or
- <em>Italic</em>).
+ <em>Italic</em> and/or
+ <em>Underline</em> and/or
+ <em>Strike through</em>).
</li>
<li>
<em>Label Alignment</em> is used for labels positioned inside node to specify their alignment (note that not all alignment values are supported for all styles). For nodes, this attribute only applies when
diff --git a/plugins/org.eclipse.sirius.doc/doc/specifier/diagrams/Diagrams.textile b/plugins/org.eclipse.sirius.doc/doc/specifier/diagrams/Diagrams.textile
index f1eea56638..c390045ed5 100644
--- a/plugins/org.eclipse.sirius.doc/doc/specifier/diagrams/Diagrams.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/specifier/diagrams/Diagrams.textile
@@ -385,7 +385,7 @@ One of the responsibility of styles is to describe labels which will be displaye
* _Label Expression_ is used to compute the text of the label describing the element. It is evaluated in the context of the semantic target element.
* _Label Position_ is used to set the position of the label relative to nodes (this property is not available for containers and edges). The label can be put on the _border_ of the node (outside), where it can be freely moved around the node's border, or in the _node_ itself.
* _Label Size_ indicates the font size to use in points.
-* _Label Format_ is used to specify the font style attributes (_Bold_ and/or _Italic_).
+* _Label Format_ is used to specify the font style attributes (_Bold_ and/or _Italic_ and/or _Underline_ and/or _Strike through_).
* _Label Alignment_ is used for labels positioned inside node to specify their alignment (note that not all alignment values are supported for all styles). For nodes, this attribute only applies when *Label position* is set to *node* (otherwise, the label is freely movable by the user). For containers, it only applies to the container's label itself, not its content. This attribute does not apply to edges (again, their label is freely movable by users) and list items.
* _Label border style_ (only available for a _Flat Container Style_): the specifier can choose a label border style among a list. As a result a border will be drawn around the container label.
* _Show icon_ indicates whether or not the element's icon should be made visible. If set, the icon used is the one associated with the type of the target element, and is rendered on the left of the label. Note that end-user will always be able to hide such icons by using the _Label icons_ preferences (_Window_/ _Preferences_/ _Sirius_/ _Sirius Diagram_/ _Appearance_).
diff --git a/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/DTableViewerManager.java b/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/DTableViewerManager.java
index b52c2d8e9c..e0fbf32d89 100644
--- a/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/DTableViewerManager.java
+++ b/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/DTableViewerManager.java
@@ -26,6 +26,7 @@ import org.eclipse.jface.viewers.CellLabelProvider;
import org.eclipse.jface.viewers.ColumnPixelData;
import org.eclipse.jface.viewers.ColumnViewerEditor;
import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
import org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ILabelProvider;
@@ -625,7 +626,8 @@ public class DTableViewerManager extends AbstractDTableViewerManager {
// Add the LabelProvider with decorating feature
ILabelDecorator decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
- treeViewerColumn.setLabelProvider(new DTableDecoratingLabelProvider(newColumn, decorator));
+ DTableDecoratingLabelProvider labelProvider = new DTableDecoratingLabelProvider(newColumn, decorator);
+ treeViewerColumn.setLabelProvider(new DelegatingStyledCellLabelProvider(labelProvider));
if (newColumn instanceof DFeatureColumn) {
treeViewerColumn.setEditingSupport(new DFeatureColumnEditingSupport(treeViewer, (DFeatureColumn) newColumn, getEditingDomain(), getAccessor(), getTableCommandFactory(),
diff --git a/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/DTableColumnLabelProvider.java b/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/DTableColumnLabelProvider.java
index 53cefe66a3..391c77ada9 100644
--- a/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/DTableColumnLabelProvider.java
+++ b/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/DTableColumnLabelProvider.java
@@ -11,15 +11,16 @@
package org.eclipse.sirius.table.ui.tools.internal.editor.provider;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.sirius.common.tools.api.util.StringUtil;
import org.eclipse.sirius.ext.base.Option;
import org.eclipse.sirius.ext.base.Options;
@@ -31,15 +32,19 @@ import org.eclipse.sirius.table.metamodel.table.DLine;
import org.eclipse.sirius.table.metamodel.table.DTableElementStyle;
import org.eclipse.sirius.table.metamodel.table.provider.TableUIPlugin;
import org.eclipse.sirius.ui.tools.api.color.VisualBindingManager;
+import org.eclipse.sirius.ui.tools.internal.editor.DefaultFontStyler;
import org.eclipse.sirius.viewpoint.FontFormat;
import org.eclipse.sirius.viewpoint.RGBValues;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
/**
* Label provider for all the DTable column (except the line header column).
*
* @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a>
*/
-public class DTableColumnLabelProvider extends ColumnLabelProvider {
+public class DTableColumnLabelProvider extends ColumnLabelProvider implements IStyledLabelProvider {
/** The key for the image which represents a checkbox checked. */
public static final String CHECKED_IMAGE = "table/checked";
@@ -116,11 +121,11 @@ public class DTableColumnLabelProvider extends ColumnLabelProvider {
}
if (styleToApply != null && styleToApply.some()) {
final int size = styleToApply.get().getLabelSize();
- FontFormat labelFormat = null;
+ List<FontFormat> labelFormat = new ArrayList<FontFormat>();
if (styleToApply.get().getLabelFormat() != null) {
labelFormat = styleToApply.get().getLabelFormat();
} else {
- labelFormat = FontFormat.NORMAL_LITERAL;
+ labelFormat.clear();
}
return VisualBindingManager.getDefault().getFontFromLabelFormatAndSize(labelFormat, size);
}
@@ -232,4 +237,54 @@ public class DTableColumnLabelProvider extends ColumnLabelProvider {
public boolean isProvideColumn(final DColumn currentColumn) {
return this.column.equals(currentColumn);
}
+
+ @Override
+ public StyledString getStyledText(Object element) {
+ String text = getText(element);
+ DefaultFontStyler styler = new DefaultFontStyler(getFont(element), getForeground(element), getBackground(element), getUnderline(element), getStrikeout(element));
+ if (text == null) {
+ text = "";
+ }
+ StyledString styledString = new StyledString(text, styler);
+
+ return styledString;
+ }
+
+ private boolean getStrikeout(Object element) {
+ if (column != null) {
+ Option<DCell> optionalCell = getDCell(element);
+ Option<DTableElementStyle> styleToApply = null;
+ if (optionalCell.some()) {
+ styleToApply = new DCellQuery(optionalCell.get()).getForegroundStyleToApply();
+ } else if (element instanceof DLine) {
+ styleToApply = TableHelper.getForegroundStyleToApply((DLine) element, column);
+ }
+ if (styleToApply != null && styleToApply.some()) {
+ List<FontFormat> labelFormat = styleToApply.get().getLabelFormat();
+ if (labelFormat != null) {
+ return labelFormat.contains(FontFormat.STRIKE_THROUGH_LITERAL);
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean getUnderline(Object element) {
+ if (column != null) {
+ Option<DCell> optionalCell = getDCell(element);
+ Option<DTableElementStyle> styleToApply = null;
+ if (optionalCell.some()) {
+ styleToApply = new DCellQuery(optionalCell.get()).getForegroundStyleToApply();
+ } else if (element instanceof DLine) {
+ styleToApply = TableHelper.getForegroundStyleToApply((DLine) element, column);
+ }
+ if (styleToApply != null && styleToApply.some()) {
+ List<FontFormat> labelFormat = styleToApply.get().getLabelFormat();
+ if (labelFormat != null) {
+ return labelFormat.contains(FontFormat.UNDERLINE_LITERAL);
+ }
+ }
+ }
+ return false;
+ }
}
diff --git a/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/TableUIUpdaterRunnable.java b/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/TableUIUpdaterRunnable.java
index 10d674a15d..728320e9ac 100644
--- a/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/TableUIUpdaterRunnable.java
+++ b/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/TableUIUpdaterRunnable.java
@@ -17,6 +17,8 @@ import java.util.Set;
import org.eclipse.jface.layout.TreeColumnLayout;
import org.eclipse.jface.viewers.CellLabelProvider;
import org.eclipse.jface.viewers.ColumnPixelData;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.sirius.common.tools.DslCommonPlugin;
import org.eclipse.sirius.table.metamodel.table.DColumn;
@@ -195,7 +197,14 @@ public class TableUIUpdaterRunnable implements Runnable {
private void updateColumns() {
for (DColumn dColumnToUpdateDirectly : dColumnsToUpdateDirectly) {
for (int i = 0; i < dTableTreeViewer.getTree().getColumns().length; i++) {
- final CellLabelProvider labelProvider = dTableTreeViewer.getLabelProvider(i);
+ CellLabelProvider labelProvider = dTableTreeViewer.getLabelProvider(i);
+ if (labelProvider instanceof DelegatingStyledCellLabelProvider) {
+ // Use the original label provider if possible
+ IStyledLabelProvider styledLabelProvider = ((DelegatingStyledCellLabelProvider) labelProvider).getStyledStringProvider();
+ if (styledLabelProvider instanceof CellLabelProvider) {
+ labelProvider = (CellLabelProvider) styledLabelProvider;
+ }
+ }
if (labelProvider instanceof DTableColumnLabelProvider && ((DTableColumnLabelProvider) labelProvider).isProvideColumn(dColumnToUpdateDirectly)) {
DslCommonPlugin.PROFILER.startWork(SiriusTasksKey.SET_COLUMN_NAME_KEY);
@@ -239,7 +248,14 @@ public class TableUIUpdaterRunnable implements Runnable {
DColumn dColumn = entry.getKey();
Boolean visible = entry.getValue();
for (int i = 0; i < dTableTreeViewer.getTree().getColumns().length; i++) {
- final CellLabelProvider labelProvider = dTableTreeViewer.getLabelProvider(i);
+ CellLabelProvider labelProvider = dTableTreeViewer.getLabelProvider(i);
+ if (labelProvider instanceof DelegatingStyledCellLabelProvider) {
+ // Use the original label provider if possible
+ IStyledLabelProvider styledLabelProvider = ((DelegatingStyledCellLabelProvider) labelProvider).getStyledStringProvider();
+ if (styledLabelProvider instanceof CellLabelProvider) {
+ labelProvider = (CellLabelProvider) styledLabelProvider;
+ }
+ }
if (labelProvider instanceof DTableColumnLabelProvider && ((DTableColumnLabelProvider) labelProvider).isProvideColumn(dColumn)) {
DslCommonPlugin.PROFILER.startWork(SiriusTasksKey.CHANGE_SWT_COLUMN_VISIBLE_STATE_KEY);
final TreeColumn treeColumn = dTableTreeViewer.getTree().getColumn(i);
diff --git a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableElementSynchronizerSpec.java b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableElementSynchronizerSpec.java
index 1e982950e7..d914472eac 100644
--- a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableElementSynchronizerSpec.java
+++ b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableElementSynchronizerSpec.java
@@ -729,7 +729,7 @@ public class DTableElementSynchronizerSpec extends DTableElementSynchronizerImpl
style.eUnset(TablePackage.eINSTANCE.getDTableElementStyle_ForegroundColor());
}
if (style.getLabelFormat() != null) {
- style.setLabelFormat(null);
+ style.getLabelFormat().clear();
}
if (style.eIsSet(TablePackage.eINSTANCE.getDTableElementStyle_LabelSize())) {
style.eUnset(TablePackage.eINSTANCE.getDTableElementStyle_LabelSize());
@@ -740,9 +740,9 @@ public class DTableElementSynchronizerSpec extends DTableElementSynchronizerImpl
}
}
- private boolean isEqual(FontFormat labelFormat, FontFormat labelFormat2) {
+ private boolean isEqual(List<FontFormat> labelFormat, List<FontFormat> labelFormat2) {
if (labelFormat != null && labelFormat2 != null) {
- return labelFormat.getLiteral().equals(labelFormat2.getLiteral());
+ return labelFormat.equals(labelFormat2);
}
return false;
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/refresh/EdgeWithConditionalStyleTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/refresh/EdgeWithConditionalStyleTest.java
index 445b80e47b..d467de2042 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/refresh/EdgeWithConditionalStyleTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/refresh/EdgeWithConditionalStyleTest.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.sirius.tests.unit.api.refresh;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
@@ -210,7 +213,9 @@ public class EdgeWithConditionalStyleTest extends DocbookTestCase {
assertFalse("Wrong showIcon for first Edge description.", edgeStyleDescription.getCenterLabelStyleDescription().isShowIcon());
assertEquals("Wrong EdgeSourceArrow for first Edge.", EdgeArrows.INPUT_ARROW_LITERAL, edgeStyle.getSourceArrow());
assertEquals("Wrong EdgeTargetArrow for first Edge.", EdgeArrows.NO_DECORATION_LITERAL, edgeStyle.getTargetArrow());
- assertEquals("Wrong LabelFormat for first Edge.", FontFormat.ITALIC_LITERAL, edgeStyle.getCenterLabelStyle().getLabelFormat());
+ List<FontFormat> fontFormat = new ArrayList<FontFormat>();
+ fontFormat.add(FontFormat.ITALIC_LITERAL);
+ assertEquals("Wrong LabelFormat for first Edge.", fontFormat, edgeStyle.getCenterLabelStyle().getLabelFormat());
assertEquals("Wrong LabelSize for first Edge.", 8, edgeStyle.getCenterLabelStyle().getLabelSize());
if (custom) {
assertFalse("The edge style should be custom.", edgeStyle.getCustomFeatures().isEmpty());
@@ -242,7 +247,7 @@ public class EdgeWithConditionalStyleTest extends DocbookTestCase {
assertTrue("Wrong showIcon for first Edge description.", edgeStyleDescription.getCenterLabelStyleDescription().isShowIcon());
assertEquals("Wrong EdgeSourceArrow for second Edge.", EdgeArrows.NO_DECORATION_LITERAL, edgeStyle.getSourceArrow());
assertEquals("Wrong EdgeTargetArrow for second Edge.", EdgeArrows.INPUT_ARROW_LITERAL, edgeStyle.getTargetArrow());
- assertEquals("Wrong LabelFormat for second Edge.", FontFormat.NORMAL_LITERAL, edgeStyle.getCenterLabelStyle().getLabelFormat());
+ assertEquals("Wrong LabelFormat for second Edge.", new ArrayList<FontFormat>(), edgeStyle.getCenterLabelStyle().getLabelFormat());
assertEquals("Wrong LabelSize for second Edge.", 8, edgeStyle.getCenterLabelStyle().getLabelSize());
assertEquals("Wrong LineStyle for second Edge.", LineStyle.SOLID_LITERAL, edgeStyle.getLineStyle());
assertEquals("Wrong RoutingStyle for second Edge.", EdgeRouting.STRAIGHT_LITERAL, edgeStyleDescription.getRoutingStyle());
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/refresh/RefreshWithCustomizedStyleTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/refresh/RefreshWithCustomizedStyleTests.java
index 0b7d10fd56..e2ba4017dd 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/refresh/RefreshWithCustomizedStyleTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/refresh/RefreshWithCustomizedStyleTests.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.util.Enumerator;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -61,6 +62,8 @@ import org.eclipse.sirius.viewpoint.description.FixedColor;
import org.eclipse.sirius.viewpoint.description.style.StyleDescription;
import org.eclipse.ui.IEditorPart;
+import com.google.common.collect.Lists;
+
/**
* Test the style customization features with conditional style description.
*
@@ -561,6 +564,7 @@ public class RefreshWithCustomizedStyleTests extends SiriusDiagramTestCase {
return conditionalStyleDescriptions;
}
+ @SuppressWarnings({ "rawtypes", "unchecked" })
private void customizeFeature(DDiagramElement dDiagramElement, EStructuralFeature feature) {
Style style = dDiagramElement.getStyle();
Object currentValue = style.eGet(feature);
@@ -570,6 +574,15 @@ public class RefreshWithCustomizedStyleTests extends SiriusDiagramTestCase {
RGBValues red = RGBValues.create(255, 0, 0);
Command customizeStyleCmd = SetCommand.create(domain, style, feature, red);
domain.getCommandStack().execute(customizeStyleCmd);
+ } else if (feature.getEType() instanceof EEnum && currentValue instanceof List && ((List) currentValue).isEmpty()) {
+ List newList = Lists.newArrayList();
+ EEnum eEnum = (EEnum) feature.getEType();
+ for (EEnumLiteral literal : eEnum.getELiterals()) {
+ Enumerator newEnumerator = literal.getInstance();
+ newList.add(newEnumerator);
+ }
+ Command customizeStyleCmd = SetCommand.create(domain, style, feature, newList);
+ domain.getCommandStack().execute(customizeStyleCmd);
} else if (feature.getEType() instanceof EEnum && currentValue instanceof Enumerator) {
EEnum eEnum = (EEnum) feature.getEType();
Enumerator enumerator = (Enumerator) currentValue;
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/RepairOnStyleCustomizationsTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/RepairOnStyleCustomizationsTest.java
index afab9b073b..8b702aef03 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/RepairOnStyleCustomizationsTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/RepairOnStyleCustomizationsTest.java
@@ -12,6 +12,7 @@ package org.eclipse.sirius.tests.unit.diagram.migration;
import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.URI;
@@ -79,6 +80,7 @@ public class RepairOnStyleCustomizationsTest extends AbstractRepairMigrateTest {
*
* @throws Exception
*/
+ @SuppressWarnings({ "unchecked" })
public void testRepairOnStyleCustomizations() throws Exception {
// Launch a repair
runRepairProcess(REPRESENTATIONS_RESOURCE_NAME);
@@ -133,11 +135,14 @@ public class RepairOnStyleCustomizationsTest extends AbstractRepairMigrateTest {
EAttribute labelFormatFeature = ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT;
assertEquals(assertMessage, Collections.emptyList(), dEdgeOfEReference.getOwnedStyle().getCustomFeatures());
assertEquals(assertMessage, Collections.singletonList(labelFormatFeature.getName()), dEdgeOfEReference.getOwnedStyle().getCenterLabelStyle().getCustomFeatures());
- assertEquals(assertMessage, FontFormat.BOLD_ITALIC_LITERAL, dEdgeOfEReference.getOwnedStyle().getCenterLabelStyle().eGet(labelFormatFeature));
+ assertEquals(assertMessage, FontFormat.BOLD_LITERAL, ((List<FontFormat>) dEdgeOfEReference.getOwnedStyle().getCenterLabelStyle().eGet(labelFormatFeature)).get(1));
+ assertEquals(assertMessage, FontFormat.ITALIC_LITERAL, ((List<FontFormat>) dEdgeOfEReference.getOwnedStyle().getCenterLabelStyle().eGet(labelFormatFeature)).get(0));
assertEquals(assertMessage, Collections.singletonList(labelFormatFeature.getName()), dNodeListOfEClass.getStyle().getCustomFeatures());
- assertEquals(assertMessage, FontFormat.BOLD_ITALIC_LITERAL, dNodeListOfEClass.getStyle().eGet(labelFormatFeature));
+ assertEquals(assertMessage, FontFormat.BOLD_LITERAL, ((List<FontFormat>) dNodeListOfEClass.getStyle().eGet(labelFormatFeature)).get(1));
+ assertEquals(assertMessage, FontFormat.ITALIC_LITERAL, ((List<FontFormat>) dNodeListOfEClass.getStyle().eGet(labelFormatFeature)).get(0));
assertEquals(assertMessage, Collections.singletonList(labelFormatFeature.getName()), dNodeContainerOfEPackage.getStyle().getCustomFeatures());
- assertEquals(assertMessage, FontFormat.BOLD_ITALIC_LITERAL, dNodeContainerOfEPackage.getStyle().eGet(labelFormatFeature));
+ assertEquals(assertMessage, FontFormat.BOLD_LITERAL, ((List<FontFormat>) dNodeContainerOfEPackage.getStyle().eGet(labelFormatFeature)).get(1));
+ assertEquals(assertMessage, FontFormat.ITALIC_LITERAL, ((List<FontFormat>) dNodeContainerOfEPackage.getStyle().eGet(labelFormatFeature)).get(0));
assertMessage = "The repair process shouldn't reset the WorkspaceImage seted to display a background image";
assertTrue(assertMessage, dNodeContainerOfEPackageWithWorkspaceImage.getStyle() instanceof WorkspaceImage);
@@ -145,7 +150,9 @@ public class RepairOnStyleCustomizationsTest extends AbstractRepairMigrateTest {
assertEquals(assertMessage, 2, dNodeContainerOfEPackageWithWorkspaceImage.getStyle().getCustomFeatures().size());
assertTrue(assertMessage, dNodeContainerOfEPackageWithWorkspaceImage.getStyle().getCustomFeatures().contains(labelFormatFeature.getName()));
assertTrue(assertMessage, dNodeContainerOfEPackageWithWorkspaceImage.getStyle().getCustomFeatures().contains(DiagramPackage.Literals.WORKSPACE_IMAGE__WORKSPACE_PATH.getName()));
- assertEquals(assertMessage, FontFormat.BOLD_ITALIC_LITERAL, workspaceImage.getLabelFormat());
+ assertEquals(assertMessage, FontFormat.BOLD_LITERAL, ((List<FontFormat>) workspaceImage.getLabelFormat()).get(1));
+ assertEquals(assertMessage, FontFormat.ITALIC_LITERAL, ((List<FontFormat>) workspaceImage.getLabelFormat()).get(0));
+
assertEquals(assertMessage, TEMPORARY_PROJECT_NAME + "/" + IMAGE, workspaceImage.getWorkspacePath());
// Open a session and a diagram editor
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/modeler/ecore/design/EntitiesDiagramToolsTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/modeler/ecore/design/EntitiesDiagramToolsTests.java
index aa261c853f..8cbba8a251 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/modeler/ecore/design/EntitiesDiagramToolsTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/modeler/ecore/design/EntitiesDiagramToolsTests.java
@@ -10,6 +10,10 @@
*******************************************************************************/
package org.eclipse.sirius.tests.unit.diagram.modeler.ecore.design;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EAttribute;
@@ -114,7 +118,7 @@ public class EntitiesDiagramToolsTests extends SiriusDiagramTestCase implements
DDiagramElement elt = getFirstDiagramElement(diagram, eReference);
assertTrue(elt.getStyle() instanceof EdgeStyle);
assertFalse("The label of the reference should not start with /", elt.getName().startsWith("/"));
- assertEquals("The label of the reference should have a normal font format.", FontFormat.get("normal"), ((EdgeStyle) elt.getStyle()).getCenterLabelStyle().getLabelFormat());
+ assertEquals("The label of the reference should have a normal font format.", Collections.emptyList(), ((EdgeStyle) elt.getStyle()).getCenterLabelStyle().getLabelFormat());
Command cmd2 = new RecordingCommand(session.getTransactionalEditingDomain()) {
@@ -130,7 +134,9 @@ public class EntitiesDiagramToolsTests extends SiriusDiagramTestCase implements
refresh(diagram);
assertTrue("The label of the reference should contain /", elt.getName().contains("/"));
- assertEquals("The label of the reference should be italicised.", FontFormat.get("italic"), ((EdgeStyle) elt.getStyle()).getCenterLabelStyle().getLabelFormat());
+ List<FontFormat> fontFormat = new ArrayList<FontFormat>();
+ fontFormat.add(FontFormat.ITALIC_LITERAL);
+ assertEquals("The label of the reference should be italicised.", fontFormat, ((EdgeStyle) elt.getStyle()).getCenterLabelStyle().getLabelFormat());
Command cmd3 = new RecordingCommand(session.getTransactionalEditingDomain()) {
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/StyleHelperTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/StyleHelperTest.java
index 1e68f5abe0..1f585d73ce 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/StyleHelperTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/StyleHelperTest.java
@@ -13,6 +13,8 @@ package org.eclipse.sirius.tests.unit.diagram.refresh;
import junit.framework.TestCase;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.sirius.business.api.metamodel.helper.FontFormatHelper;
import org.eclipse.sirius.common.tools.api.interpreter.CompoundInterpreter;
import org.eclipse.sirius.diagram.AlignmentKind;
import org.eclipse.sirius.diagram.BackgroundStyle;
@@ -1431,7 +1433,7 @@ public class StyleHelperTest extends TestCase {
public Object caseLabelStyleDescription(LabelStyleDescription object) {
object.setLabelAlignment(LabelAlignment.CENTER);
object.setLabelExpression("LabelExpression");
- object.setLabelFormat(FontFormat.BOLD_LITERAL);
+ FontFormatHelper.setFontFormat(object.getLabelFormat(), FontFormat.BOLD_LITERAL);
object.setLabelSize(6);
object.setLabelColor(LABEL_COLOR_FIRST);
object.setShowIcon(true);
@@ -1531,19 +1533,19 @@ public class StyleHelperTest extends TestCase {
if (object.getBeginLabelStyleDescription() != null) {
object.getBeginLabelStyleDescription().setLabelColor(LABEL_COLOR_FIRST);
object.getBeginLabelStyleDescription().setLabelExpression("begin first LabelExpression");
- object.getBeginLabelStyleDescription().setLabelFormat(FontFormat.BOLD_LITERAL);
+ FontFormatHelper.setFontFormat(object.getBeginLabelStyleDescription().getLabelFormat(), FontFormat.BOLD_LITERAL);
object.getBeginLabelStyleDescription().setLabelSize(5);
}
if (object.getCenterLabelStyleDescription() != null) {
object.getCenterLabelStyleDescription().setLabelColor(LABEL_COLOR_FIRST);
object.getCenterLabelStyleDescription().setLabelExpression("center first LabelExpression");
- object.getCenterLabelStyleDescription().setLabelFormat(FontFormat.BOLD_LITERAL);
+ FontFormatHelper.setFontFormat(object.getCenterLabelStyleDescription().getLabelFormat(), FontFormat.BOLD_LITERAL);
object.getCenterLabelStyleDescription().setLabelSize(5);
}
if (object.getEndLabelStyleDescription() != null) {
object.getEndLabelStyleDescription().setLabelColor(LABEL_COLOR_FIRST);
object.getEndLabelStyleDescription().setLabelExpression("end first LabelExpression");
- object.getEndLabelStyleDescription().setLabelFormat(FontFormat.BOLD_LITERAL);
+ FontFormatHelper.setFontFormat(object.getEndLabelStyleDescription().getLabelFormat(), FontFormat.BOLD_LITERAL);
object.getEndLabelStyleDescription().setLabelSize(5);
}
object.setTargetArrow(EdgeArrows.DIAMOND_LITERAL);
@@ -1726,7 +1728,7 @@ public class StyleHelperTest extends TestCase {
public Object caseLabelStyleDescription(LabelStyleDescription object) {
object.setLabelAlignment(LabelAlignment.LEFT);
object.setLabelExpression("LabelExpression");
- object.setLabelFormat(FontFormat.ITALIC_LITERAL);
+ FontFormatHelper.setFontFormat(object.getLabelFormat(), FontFormat.ITALIC_LITERAL);
object.setLabelColor(LABEL_COLOR_SECOND);
object.setLabelSize(6);
object.setShowIcon(false);
@@ -1827,19 +1829,19 @@ public class StyleHelperTest extends TestCase {
if (object.getBeginLabelStyleDescription() != null) {
object.getBeginLabelStyleDescription().setLabelColor(LABEL_COLOR_SECOND);
object.getBeginLabelStyleDescription().setLabelExpression("begin second LabelExpression");
- object.getBeginLabelStyleDescription().setLabelFormat(FontFormat.ITALIC_LITERAL);
+ FontFormatHelper.setFontFormat(object.getBeginLabelStyleDescription().getLabelFormat(), FontFormat.ITALIC_LITERAL);
object.getBeginLabelStyleDescription().setLabelSize(6);
}
if (object.getCenterLabelStyleDescription() != null) {
object.getCenterLabelStyleDescription().setLabelColor(LABEL_COLOR_SECOND);
object.getCenterLabelStyleDescription().setLabelExpression("center second LabelExpression");
- object.getCenterLabelStyleDescription().setLabelFormat(FontFormat.ITALIC_LITERAL);
+ FontFormatHelper.setFontFormat(object.getCenterLabelStyleDescription().getLabelFormat(), FontFormat.ITALIC_LITERAL);
object.getCenterLabelStyleDescription().setLabelSize(6);
}
if (object.getEndLabelStyleDescription() != null) {
object.getEndLabelStyleDescription().setLabelColor(LABEL_COLOR_SECOND);
object.getEndLabelStyleDescription().setLabelExpression("end second LabelExpression");
- object.getEndLabelStyleDescription().setLabelFormat(FontFormat.ITALIC_LITERAL);
+ FontFormatHelper.setFontFormat(object.getEndLabelStyleDescription().getLabelFormat(), FontFormat.ITALIC_LITERAL);
object.getEndLabelStyleDescription().setLabelSize(6);
}
object.setTargetArrow(EdgeArrows.FILL_DIAMOND_LITERAL);
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/customization/RefreshWithCustomizationTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/customization/RefreshWithCustomizationTests.java
index 72477426d4..b7389ca81f 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/customization/RefreshWithCustomizationTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/customization/RefreshWithCustomizationTests.java
@@ -176,13 +176,15 @@ public class RefreshWithCustomizationTests extends SiriusDiagramTestCase {
String assertMessage = "The new label size must be that of the EAttributeCustomization.value";
Integer customizedLabelSize = Integer.valueOf(eAttributeCustomizationLabelSize.getValue());
FontFormat customizedLabelFormat = FontFormat.get(eAttributeCustomizationLabelFormat.getValue());
+ List<FontFormat> fontFormat = new ArrayList<FontFormat>();
+ fontFormat.add(customizedLabelFormat);
assertEquals(assertMessage, customizedLabelSize, p1.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE));
assertEquals(assertMessage, customizedLabelSize, eClass1.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE));
assertEquals(assertMessage, customizedLabelSize, eClass11.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE));
assertEquals(assertMessage, customizedLabelSize, eClass1Attribute.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE));
assertEquals(assertMessage, customizedLabelSize, eClass11Attribute.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE));
assertMessage = "The new label Font Format must be that of the EAttributeCustomization.value";
- assertEquals(assertMessage, customizedLabelFormat, eClass11Attribute.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT));
+ assertEquals(assertMessage, fontFormat, eClass11Attribute.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT));
assertMessage = "As the edge labels are not customized, their size must be unchanged";
assertEquals(assertMessage, edgeBeginStyleOriginalLabelSize, dEdge.getOwnedStyle().getBeginLabelStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE));
assertEquals(assertMessage, edgeCenterStyleOriginalLabelSize, dEdge.getOwnedStyle().getCenterLabelStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE));
@@ -271,7 +273,8 @@ public class RefreshWithCustomizationTests extends SiriusDiagramTestCase {
String assertMessage = "The new label size must be that of the EAttributeCustomization.value";
Integer customizedLabelSize = Integer.valueOf(eAttributeCustomizationLabelSize.getValue());
- FontFormat customizedLabelFormat = FontFormat.get(eAttributeCustomizationLabelFormat.getValue());
+ List<FontFormat> customizedLabelFormat = new ArrayList<FontFormat>();
+ customizedLabelFormat.add(FontFormat.get(eAttributeCustomizationLabelFormat.getValue()));
assertEquals(assertMessage, customizedLabelSize, p1.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE));
assertEquals(assertMessage, customizedLabelSize, eClass1.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE));
assertEquals(assertMessage, customizedLabelSize, eClass11.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE));
@@ -372,6 +375,7 @@ public class RefreshWithCustomizationTests extends SiriusDiagramTestCase {
* Test a style description element with "apply on all" setted. In this
* case, all labels font style should be bold.
*/
+ @SuppressWarnings("unchecked")
public void testAppliedOnAllPropertyCustomization() {
activateViewpoint("StyleCustomizations_ExtensionB");
@@ -389,26 +393,28 @@ public class RefreshWithCustomizationTests extends SiriusDiagramTestCase {
DNodeListElement eClass11AttributeBis = (DNodeListElement) eClass11Bis.getOwnedElements().get(0);
DEdge dEdgeBis = dDiagram.getEdges().get(0);
- FontFormat p1BisLabelFormat = (FontFormat) p1Bis.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
- FontFormat eClass1BisLabelFormat = (FontFormat) eClass1Bis.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
- FontFormat eClass11BisLabelFormat = (FontFormat) eClass11Bis.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
- FontFormat eClass1AttributeBisLabelFormat = (FontFormat) eClass1AttributeBis.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
- FontFormat eClass11AttributeBisLabelFormat = (FontFormat) eClass11AttributeBis.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
- FontFormat edgeBeginBisLabelFormat = dEdgeBis.getOwnedStyle().getBeginLabelStyle().getLabelFormat();
- FontFormat edgeCenterBisLabelFormat = dEdgeBis.getOwnedStyle().getCenterLabelStyle().getLabelFormat();
- FontFormat edgeEndBisLabelFormat = dEdgeBis.getOwnedStyle().getEndLabelStyle().getLabelFormat();
+ List<FontFormat> p1BisLabelFormat = (List<FontFormat>) p1Bis.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
+ List<FontFormat> eClass1BisLabelFormat = (List<FontFormat>) eClass1Bis.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
+ List<FontFormat> eClass11BisLabelFormat = (List<FontFormat>) eClass11Bis.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
+ List<FontFormat> eClass1AttributeBisLabelFormat = (List<FontFormat>) eClass1AttributeBis.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
+ List<FontFormat> eClass11AttributeBisLabelFormat = (List<FontFormat>) eClass11AttributeBis.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
+ List<FontFormat> edgeBeginBisLabelFormat = dEdgeBis.getOwnedStyle().getBeginLabelStyle().getLabelFormat();
+ List<FontFormat> edgeCenterBisLabelFormat = dEdgeBis.getOwnedStyle().getCenterLabelStyle().getLabelFormat();
+ List<FontFormat> edgeEndBisLabelFormat = dEdgeBis.getOwnedStyle().getEndLabelStyle().getLabelFormat();
// Asserts
String assertMessage = "All label font format should be in Bold";
- assertEquals(assertMessage, FontFormat.BOLD_LITERAL, p1BisLabelFormat);
- assertEquals(assertMessage, FontFormat.BOLD_LITERAL, eClass1BisLabelFormat);
- assertEquals(assertMessage, FontFormat.BOLD_LITERAL, eClass11BisLabelFormat);
- assertEquals(assertMessage, FontFormat.BOLD_LITERAL, eClass1AttributeBisLabelFormat);
- assertEquals(assertMessage, FontFormat.BOLD_LITERAL, eClass11AttributeBisLabelFormat);
- assertEquals(assertMessage, FontFormat.BOLD_LITERAL, edgeBeginBisLabelFormat);
- assertEquals(assertMessage, FontFormat.BOLD_LITERAL, edgeCenterBisLabelFormat);
- assertEquals(assertMessage, FontFormat.BOLD_LITERAL, edgeEndBisLabelFormat);
+ List<FontFormat> fontFormat = new ArrayList<FontFormat>();
+ fontFormat.add(FontFormat.BOLD_LITERAL);
+ assertEquals(assertMessage, fontFormat, p1BisLabelFormat);
+ assertEquals(assertMessage, fontFormat, eClass1BisLabelFormat);
+ assertEquals(assertMessage, fontFormat, eClass11BisLabelFormat);
+ assertEquals(assertMessage, fontFormat, eClass1AttributeBisLabelFormat);
+ assertEquals(assertMessage, fontFormat, eClass11AttributeBisLabelFormat);
+ assertEquals(assertMessage, fontFormat, edgeBeginBisLabelFormat);
+ assertEquals(assertMessage, fontFormat, edgeCenterBisLabelFormat);
+ assertEquals(assertMessage, fontFormat, edgeEndBisLabelFormat);
session.save(new NullProgressMonitor());
refresh(dDiagram);
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableCellStylesTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableCellStylesTest.java
index b781ee6a97..031e8679ee 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableCellStylesTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableCellStylesTest.java
@@ -10,6 +10,10 @@
*******************************************************************************/
package org.eclipse.sirius.tests.unit.table.unit.refresh;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
@@ -382,8 +386,7 @@ public class DTableCellStylesTest extends TableTestCase {
Option<DTableElementStyle> optionalForegroundStyleToApply = class1CellQuery.getForegroundStyleToApply();
assertTrue("We should have a currentStyle for the cell.", optionalForegroundStyleToApply.some());
assertNotNull("We should have a label format for the cell.", optionalForegroundStyleToApply.get().getLabelFormat());
- assertEquals("The label format should be normal (the conditional foreground label format of the line mapping).", FontFormat.NORMAL_LITERAL, optionalForegroundStyleToApply.get()
- .getLabelFormat());
+ assertEquals("The label format should be normal (the conditional foreground label format of the line mapping).", Collections.emptyList(), optionalForegroundStyleToApply.get().getLabelFormat());
// Get the line corresponding to the Class Class2
DLine class2Line = null;
@@ -410,7 +413,7 @@ public class DTableCellStylesTest extends TableTestCase {
optionalForegroundStyleToApply = class2CellQuery.getForegroundStyleToApply();
assertTrue("We should have a currentStyle for the cell.", optionalForegroundStyleToApply.some());
assertNotNull("We should have a label format for the cell.", optionalForegroundStyleToApply.get().getLabelFormat());
- assertEquals("The label format should be normal (the default foreground label format of the line mapping).", FontFormat.NORMAL_LITERAL, optionalForegroundStyleToApply.get().getLabelFormat());
+ assertEquals("The label format should be normal (the default foreground label format of the line mapping).", Collections.emptyList(), optionalForegroundStyleToApply.get().getLabelFormat());
/*
* Let's change the isActive value of the Class1 (use for conditional
@@ -433,13 +436,13 @@ public class DTableCellStylesTest extends TableTestCase {
optionalForegroundStyleToApply = class1CellQuery.getForegroundStyleToApply();
assertTrue("We should have a currentStyle for the cell.", optionalForegroundStyleToApply.some());
assertNotNull("We should have a label format for the cell.", optionalForegroundStyleToApply.get().getLabelFormat());
- assertEquals("The label format should be normal (the conditional foreground label format of the line mapping).", FontFormat.NORMAL_LITERAL, optionalForegroundStyleToApply.get()
- .getLabelFormat());
+ assertEquals("The label format should be normal (the conditional foreground label format of the line mapping).", Collections.emptyList(), optionalForegroundStyleToApply.get().getLabelFormat());
optionalForegroundStyleToApply = class2CellQuery.getForegroundStyleToApply();
assertTrue("We should have a currentStyle for the cell.", optionalForegroundStyleToApply.some());
assertNotNull("We should have a label format for the cell.", optionalForegroundStyleToApply.get().getLabelFormat());
- assertEquals("The label format should be italic (the conditional foreground label format of the column mapping).", FontFormat.ITALIC_LITERAL, optionalForegroundStyleToApply.get()
- .getLabelFormat());
+ List<FontFormat> fontFormat = new ArrayList<FontFormat>();
+ fontFormat.add(FontFormat.ITALIC_LITERAL);
+ assertEquals("The label format should be italic (the conditional foreground label format of the column mapping).", fontFormat, optionalForegroundStyleToApply.get().getLabelFormat());
}
}
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableSynchronizerTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableSynchronizerTest.java
index 77bd3dc4c5..cddf7d62f7 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableSynchronizerTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/table/unit/refresh/DTableSynchronizerTest.java
@@ -11,6 +11,7 @@
package org.eclipse.sirius.tests.unit.table.unit.refresh;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -19,6 +20,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.sirius.business.api.metamodel.helper.FontFormatHelper;
import org.eclipse.sirius.ext.base.Option;
import org.eclipse.sirius.table.business.api.query.DCellQuery;
import org.eclipse.sirius.table.business.api.query.DTableQuery;
@@ -520,7 +522,7 @@ public class DTableSynchronizerTest extends TableTestCase {
if (optionalCell.some()) {
Option<DTableElementStyle> optionalForegroundStyleToApply = new DCellQuery(optionalCell.get()).getForegroundStyleToApply();
assertTrue("We should have a currentStyle for the cell.", optionalForegroundStyleToApply.some());
- checkStyle(optionalForegroundStyleToApply.get(), false, 8, FontFormat.NORMAL_LITERAL);
+ checkStyle(optionalForegroundStyleToApply.get(), false, 8, Collections.emptyList());
}
final LineMapping mapping = findLineMapping(desc, lineMappingName);
@@ -531,7 +533,7 @@ public class DTableSynchronizerTest extends TableTestCase {
@Override
protected void doExecute() {
ForegroundStyleDescription foregroundStyle = DescriptionFactory.eINSTANCE.createForegroundStyleDescription();
- foregroundStyle.setLabelFormat(FontFormat.BOLD_LITERAL);
+ FontFormatHelper.setFontFormat(foregroundStyle.getLabelFormat(), FontFormat.BOLD_LITERAL);
foregroundStyle.setLabelSize(14);
mapping.setDefaultForeground(foregroundStyle);
}
@@ -544,7 +546,9 @@ public class DTableSynchronizerTest extends TableTestCase {
if (optionalCell.some()) {
Option<DTableElementStyle> optionalForegroundStyleToApply = new DCellQuery(optionalCell.get()).getForegroundStyleToApply();
assertTrue("We should have a currentStyle for the cell.", optionalForegroundStyleToApply.some());
- checkStyle(optionalForegroundStyleToApply.get(), true, 14, FontFormat.BOLD_LITERAL);
+ List<FontFormat> fontFormat = new ArrayList<FontFormat>();
+ fontFormat.add(FontFormat.BOLD_LITERAL);
+ checkStyle(optionalForegroundStyleToApply.get(), true, 14, fontFormat);
}
domain.getCommandStack().execute(new RecordingCommand(domain) {
@@ -562,11 +566,12 @@ public class DTableSynchronizerTest extends TableTestCase {
if (optionalCell.some()) {
Option<DTableElementStyle> optionalForegroundStyleToApply = new DCellQuery(optionalCell.get()).getForegroundStyleToApply();
assertTrue("We should have a currentStyle for the cell.", optionalForegroundStyleToApply.some());
- checkStyle(optionalForegroundStyleToApply.get(), false, 8, FontFormat.NORMAL_LITERAL);
+ checkStyle(optionalForegroundStyleToApply.get(), false, 8, Collections.emptyList());
}
}
- private void checkStyle(DTableElementStyle style, boolean isStyle, int labelSize, FontFormat fontFormat) {
+ @SuppressWarnings("rawtypes")
+ private void checkStyle(DTableElementStyle style, boolean isStyle, int labelSize, List fontFormat) {
if (!isStyle)
assertEquals(RGBValues.create(0,0,0), style.getForegroundColor());
assertEquals(labelSize, style.getLabelSize());
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/TreeItemLabelFontFormatQuery.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/TreeItemLabelFontFormatQuery.java
index bd35a22d9b..0f678cd956 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/TreeItemLabelFontFormatQuery.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/TreeItemLabelFontFormatQuery.java
@@ -69,7 +69,7 @@ public class TreeItemLabelFontFormatQuery extends RunnableWithResult.Impl<FontFo
int style = fontData[0].getStyle();
switch (style) {
case SWT.NORMAL:
- setResult(FontFormat.NORMAL_LITERAL);
+ setResult(null);
break;
case SWT.BOLD:
setResult(FontFormat.BOLD_LITERAL);
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/SWTBotUtils.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/SWTBotUtils.java
index 924949333d..e7dc8a1988 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/SWTBotUtils.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/SWTBotUtils.java
@@ -10,6 +10,8 @@
*/
package org.eclipse.sirius.tests.swtbot.support.utils;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import org.eclipse.sirius.tests.swtbot.support.utils.menu.SWTBotContextMenu;
@@ -377,25 +379,22 @@ public final class SWTBotUtils {
* the {@link TreeItem} under investigation
* @return the {@link FontFormat} of the {@link TreeItem}
*/
- public static FontFormat getWidgetFormat(final TreeItem widget) {
- return UIThreadRunnable.syncExec(new Result<FontFormat>() {
+ public static List<FontFormat> getWidgetFormat(final TreeItem widget) {
+ return UIThreadRunnable.syncExec(new Result<List<FontFormat>>() {
@Override
- public FontFormat run() {
- FontFormat result = FontFormat.NORMAL_LITERAL;
+ public List<FontFormat> run() {
+ List<FontFormat> result = new ArrayList<FontFormat>();
Font font = widget.getFont(0);
if (font.getFontData().length > 0) {
switch (font.getFontData()[0].getStyle()) {
case SWT.BOLD:
- result = FontFormat.BOLD_LITERAL;
+ result.add(FontFormat.BOLD_LITERAL);
break;
case SWT.ITALIC:
- result = FontFormat.ITALIC_LITERAL;
- break;
- case SWT.BOLD | SWT.ITALIC:
- result = FontFormat.BOLD_ITALIC_LITERAL;
+ result.add(FontFormat.ITALIC_LITERAL);
break;
default:
- result = FontFormat.NORMAL_LITERAL;
+ result = null;
break;
}
}
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 dea201d9eb..7ddc60e728 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
@@ -10,6 +10,9 @@
*/
package org.eclipse.sirius.tests.swtbot.support.utils.tree;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.edit.command.SetCommand;
@@ -367,9 +370,9 @@ public final class TreeUtils {
* the {@link DTreeItem}
*/
public static void checkTreeItemLabelFormat(SWTBotEditor swtBotTreeEditor, DTreeItem dTreeItem) {
- FontFormat fontFormat = dTreeItem.getOwnedStyle().getLabelFormat();
+ List<FontFormat> fontFormat = dTreeItem.getOwnedStyle().getLabelFormat();
TreeItem treeItem = TreeUtils.getTreeItem(swtBotTreeEditor, dTreeItem);
- FontFormat widgetFontFormat = TreeUtils.getWidgetLabelFormat(treeItem);
+ List<FontFormat> widgetFontFormat = TreeUtils.getWidgetLabelFormat(treeItem);
Assert.assertEquals("The TreeItem label font format should corresponds to its DTreeItem.ownedStyle.fontFormat", fontFormat, widgetFontFormat);
}
@@ -386,10 +389,10 @@ public final class TreeUtils {
public static void checkTreeItemLabelFormat(SWTBotEditor swtBotTableEditor, DCell dCell) {
Option<DTableElementStyle> optionalForegroundStyleToApply = new DCellQuery(dCell).getForegroundStyleToApply();
Assert.assertTrue("We should have a currentStyle for the cell.", optionalForegroundStyleToApply.some());
- FontFormat fontFormat = optionalForegroundStyleToApply.get().getLabelFormat();
+ List<FontFormat> fontFormat = optionalForegroundStyleToApply.get().getLabelFormat();
TreeItem treeItem = TreeUtils.getTreeItem(swtBotTableEditor, dCell.getLine());
int dCellIndex = new DCellQuery(dCell).getColumnIndex();
- FontFormat widgetFontFormat = TreeUtils.getWidgetLabelFormat(treeItem, dCellIndex + 1);
+ List<FontFormat> widgetFontFormat = TreeUtils.getWidgetLabelFormat(treeItem, dCellIndex + 1);
Assert.assertEquals("The TreeItem label font format should corresponds to its DCell.currentStyle.fontFormat", fontFormat, widgetFontFormat);
}
@@ -710,8 +713,8 @@ public final class TreeUtils {
* @return the swt {@link TreeItem} label font format a specified
* {@link TreeItem}
*/
- private static FontFormat getWidgetLabelFormat(TreeItem treeItem) {
- FontFormat widgetLabelFormat = TreeUtils.getWidgetLabelFormat(treeItem, 0);
+ private static List<FontFormat> getWidgetLabelFormat(TreeItem treeItem) {
+ List<FontFormat> widgetLabelFormat = TreeUtils.getWidgetLabelFormat(treeItem, 0);
return widgetLabelFormat;
}
@@ -727,11 +730,11 @@ public final class TreeUtils {
* @return the swt {@link TreeItem} label font format a specified
* {@link TreeItem}
*/
- private static FontFormat getWidgetLabelFormat(TreeItem treeItem, int index) {
- FontFormat widgetLabelFormat = null;
+ private static List<FontFormat> getWidgetLabelFormat(TreeItem treeItem, int index) {
+ List<FontFormat> widgetLabelFormat = new ArrayList<FontFormat>();
TreeItemLabelFontFormatQuery treeItemBackgroundColorQuery = new TreeItemLabelFontFormatQuery(treeItem, index);
Display.getDefault().syncExec(treeItemBackgroundColorQuery);
- widgetLabelFormat = treeItemBackgroundColorQuery.getResult();
+ widgetLabelFormat.add(treeItemBackgroundColorQuery.getResult());
return widgetLabelFormat;
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractFontModificationTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractFontModificationTest.java
index 90f902c6ea..ddfecf635b 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractFontModificationTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractFontModificationTest.java
@@ -10,11 +10,15 @@
*******************************************************************************/
package org.eclipse.sirius.tests.swtbot;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.FontStyle;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.sirius.business.api.metamodel.helper.FontFormatHelper;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DDiagramElement;
import org.eclipse.sirius.diagram.DDiagramElementContainer;
@@ -82,7 +86,7 @@ public class AbstractFontModificationTest extends AbstractRefreshWithCustomizedS
* the {@link SWTBotGefEditPart} to test
*/
protected static void checkNormalFontStyle(SWTBotGefEditPart myEClassEP) {
- checkFontStyle(myEClassEP, SWT.NORMAL, SWT.NORMAL, FontFormat.NORMAL, false, false);
+ checkFontStyle(myEClassEP, SWT.NORMAL, SWT.NORMAL, new ArrayList<FontFormat>(), false, false);
}
/**
@@ -93,7 +97,9 @@ public class AbstractFontModificationTest extends AbstractRefreshWithCustomizedS
* the {@link SWTBotGefEditPart} to test
*/
protected static void checkBoldFontStyle(SWTBotGefEditPart myEClassEP) {
- checkFontStyle(myEClassEP, SWT.BOLD, SWT.BOLD, FontFormat.BOLD, false, false);
+ List<FontFormat> viewpointStyle = new ArrayList<FontFormat>();
+ viewpointStyle.add(FontFormat.BOLD_LITERAL);
+ checkFontStyle(myEClassEP, SWT.BOLD, SWT.BOLD, viewpointStyle, false, false);
}
/**
@@ -104,7 +110,9 @@ public class AbstractFontModificationTest extends AbstractRefreshWithCustomizedS
* the {@link SWTBotGefEditPart} to test
*/
protected static void checkItalicFontStyle(SWTBotGefEditPart myEClassEP) {
- checkFontStyle(myEClassEP, SWT.ITALIC, SWT.ITALIC, FontFormat.ITALIC, false, false);
+ List<FontFormat> viewpointStyle = new ArrayList<FontFormat>();
+ viewpointStyle.add(FontFormat.ITALIC_LITERAL);
+ checkFontStyle(myEClassEP, SWT.ITALIC, SWT.ITALIC, viewpointStyle, false, false);
}
/**
@@ -115,7 +123,10 @@ public class AbstractFontModificationTest extends AbstractRefreshWithCustomizedS
* the {@link SWTBotGefEditPart} to test
*/
protected void checkBoldItalicFontStyle(SWTBotGefEditPart myEClassEP) {
- checkFontStyle(myEClassEP, SWT.BOLD | SWT.ITALIC, SWT.BOLD | SWT.ITALIC, FontFormat.BOLD_ITALIC, false, false);
+ List<FontFormat> viewpointStyle = new ArrayList<FontFormat>();
+ FontFormatHelper.setFontFormat(viewpointStyle, FontFormat.BOLD_LITERAL);
+ FontFormatHelper.setFontFormat(viewpointStyle, FontFormat.ITALIC_LITERAL);
+ checkFontStyle(myEClassEP, SWT.BOLD + SWT.ITALIC, SWT.BOLD + SWT.ITALIC, viewpointStyle, false, false);
}
/**
@@ -138,7 +149,7 @@ public class AbstractFontModificationTest extends AbstractRefreshWithCustomizedS
* stroke through
*
*/
- protected static void checkFontStyle(SWTBotGefEditPart editPart, int d2dStyle, int gmfStyle, int viewpointStyle, boolean underlined, boolean strikedThrough) {
+ protected static void checkFontStyle(SWTBotGefEditPart editPart, int d2dStyle, int gmfStyle, List<FontFormat> viewpointStyle, boolean underlined, boolean strikedThrough) {
checkFontStyle(editPart, d2dStyle, gmfStyle, viewpointStyle, underlined, strikedThrough, null, -1, -1);
}
@@ -173,8 +184,8 @@ public class AbstractFontModificationTest extends AbstractRefreshWithCustomizedS
* label
*
*/
- protected static void checkFontStyle(SWTBotGefEditPart editPart, int d2dStyle, int gmfStyle, int viewpointStyle, boolean underlined, boolean strikedThrough, String fontName, int fontSize,
- int fontColor) {
+ protected static void checkFontStyle(SWTBotGefEditPart editPart, int d2dStyle, int gmfStyle, List<FontFormat> viewpointStyle, boolean underlined, boolean strikedThrough, String fontName,
+ int fontSize, int fontColor) {
// Check the state of draw2d label, GMF view and Sirius style.
if (editPart.part() instanceof AbstractDiagramNameEditPart) {
AbstractDiagramNameEditPart part = (AbstractDiagramNameEditPart) editPart.part();
@@ -297,7 +308,7 @@ public class AbstractFontModificationTest extends AbstractRefreshWithCustomizedS
* @param style
* style to find.
*/
- protected static void checkFont(DDiagramElement element, int style) {
+ protected static void checkFont(DDiagramElement element, List<FontFormat> style) {
BasicLabelStyle label = null;
if (element instanceof DDiagramElementContainer) {
@@ -309,7 +320,7 @@ public class AbstractFontModificationTest extends AbstractRefreshWithCustomizedS
}
assertNotNull(label);
- assertEquals("Wrong viewpoint font format (" + FontFormat.get(style) + ")", style, label.getLabelFormat().getValue());
+ assertEquals("Wrong viewpoint font format (" + style + ")", style, label.getLabelFormat());
}
/**
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractRefreshWithCustomizedStyleOnCompleteExampleTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractRefreshWithCustomizedStyleOnCompleteExampleTest.java
index c92c8ee062..3a59d0149d 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractRefreshWithCustomizedStyleOnCompleteExampleTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractRefreshWithCustomizedStyleOnCompleteExampleTest.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.sirius.tests.swtbot;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -580,8 +581,8 @@ public class AbstractRefreshWithCustomizedStyleOnCompleteExampleTest extends Abs
if (viewpointStyle instanceof GaugeCompositeStyle) {
return;
}
- FontFormat fontFormat = (FontFormat) viewpointStyle.eGet(feature);
- FontFormat swtFontFormat = getFigureFontFormat(font);
+ List<FontFormat> fontFormat = (List<FontFormat>) viewpointStyle.eGet(feature);
+ List<FontFormat> swtFontFormat = getFigureFontFormat(font);
assertEquals("The label format of the figure should corresponds to the labelFormat feature value of the customized style", fontFormat, swtFontFormat);
} else if (feature == ViewpointPackage.Literals.BASIC_LABEL_STYLE__SHOW_ICON) {
boolean showIcon = (Boolean) viewpointStyle.eGet(feature);
@@ -1310,20 +1311,21 @@ public class AbstractRefreshWithCustomizedStyleOnCompleteExampleTest extends Abs
return figureLabelAlignment;
}
- FontFormat getFigureFontFormat(Font font) {
- FontFormat fontFormat = null;
+ List<FontFormat> getFigureFontFormat(Font font) {
+ List<FontFormat> fontFormat = new ArrayList<FontFormat>();
FontData[] fontData = font.getFontData();
int swtFontStyle = fontData[0].getStyle();
if ((SWT.NORMAL & swtFontStyle) != 0) {
- fontFormat = FontFormat.NORMAL_LITERAL;
+ fontFormat = null;
} else if ((SWT.BOLD & swtFontStyle) != 0 && (SWT.ITALIC & swtFontStyle) != 0) {
- fontFormat = FontFormat.BOLD_ITALIC_LITERAL;
+ fontFormat.add(FontFormat.BOLD_LITERAL);
+ fontFormat.add(FontFormat.ITALIC_LITERAL);
} else if ((SWT.ITALIC & swtFontStyle) != 0) {
- fontFormat = FontFormat.ITALIC_LITERAL;
+ fontFormat.add(FontFormat.ITALIC_LITERAL);
} else if ((SWT.BOLD & swtFontStyle) != 0) {
- fontFormat = FontFormat.BOLD_LITERAL;
+ fontFormat.add(FontFormat.BOLD_LITERAL);
} else {
- fontFormat = FontFormat.NORMAL_LITERAL;
+ fontFormat = null;
}
return fontFormat;
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/HideRevealDiagramElementsLabelsTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/HideRevealDiagramElementsLabelsTest.java
index 07e465b5d9..9226690e07 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/HideRevealDiagramElementsLabelsTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/HideRevealDiagramElementsLabelsTest.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.sirius.tests.swtbot;
+import java.util.List;
+
import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramEdgeEditPart;
import org.eclipse.sirius.tests.support.api.TestsUtil;
import org.eclipse.sirius.tests.swtbot.sequence.condition.CheckTreeItemFontFormat;
@@ -624,7 +626,7 @@ public class HideRevealDiagramElementsLabelsTest extends AbstractHideRevealDiagr
item.contextMenu(REVEAL_ELEMENT_TOOLTIP).click();
checkLabelIsHidden(NODE_WITH_LABEL_NAME);
checkNodeIsVisible(nodeEditPart);
- bot.waitUntil(new CheckTreeItemFontFormat(item, FontFormat.NORMAL));
+ bot.waitUntil(new CheckTreeItemFontFormat(item, null));
// Step 4 : reveal the label (using outline)
item = view.bot().tree().getTreeItem("p").getNode(NODE_WITH_LABEL_NAME).click();
@@ -636,10 +638,11 @@ public class HideRevealDiagramElementsLabelsTest extends AbstractHideRevealDiagr
// Validates that the FontFormat of the TreeItem changes when the
// visibility changes
- FontFormat widgetFormat = SWTBotUtils.getWidgetFormat(item.getNode(NODE_WITH_LABEL_NAME + " label").widget);
- assertEquals(FontFormat.ITALIC, widgetFormat.getValue());
+ List<FontFormat> widgetFormat = SWTBotUtils.getWidgetFormat(item.getNode(NODE_WITH_LABEL_NAME + " label").widget);
+ assertEquals(FontFormat.ITALIC, widgetFormat.get(0).getValue());
SWTBotUtils.clickContextMenu(item, REVEAL_LABEL_TOOLTIP);
- bot.waitUntil(new CheckTreeItemFontFormat(item, FontFormat.NORMAL));
+
+ bot.waitUntil(new CheckTreeItemFontFormat(item, null));
checkLabelIsVisible(NODE_WITH_LABEL_NAME);
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/LabelFontModificationsTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/LabelFontModificationsTest.java
index 64d04e8192..10c46c5e12 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/LabelFontModificationsTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/LabelFontModificationsTest.java
@@ -23,7 +23,6 @@ import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeListEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeListElementEditPart;
import org.eclipse.sirius.tests.support.api.TestsUtil;
import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
-import org.eclipse.sirius.viewpoint.FontFormat;
import org.eclipse.swt.SWT;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
import org.eclipse.swtbot.swt.finder.SWTBot;
@@ -100,7 +99,7 @@ public class LabelFontModificationsTest extends AbstractFontModificationTest {
@Override
public boolean apply(SWTBotGefEditPart input) {
try {
- checkFontStyle(input, SWT.NORMAL, SWT.NORMAL, FontFormat.NORMAL, true, false);
+ checkFontStyle(input, SWT.NORMAL, SWT.NORMAL, null, true, false);
return true;
} catch (AssertionError e) {
return false;
@@ -115,7 +114,7 @@ public class LabelFontModificationsTest extends AbstractFontModificationTest {
@Override
public boolean apply(SWTBotGefEditPart input) {
try {
- checkFontStyle(input, SWT.NORMAL, SWT.NORMAL, FontFormat.NORMAL, false, true);
+ checkFontStyle(input, SWT.NORMAL, SWT.NORMAL, null, false, true);
return true;
} catch (AssertionError e) {
return false;
@@ -128,7 +127,7 @@ public class LabelFontModificationsTest extends AbstractFontModificationTest {
@Override
public boolean apply(SWTBotGefEditPart input) {
try {
- checkFontStyle(input, SWT.NORMAL, SWT.NORMAL, FontFormat.NORMAL, false, false, null, -1, 10011046);
+ checkFontStyle(input, SWT.NORMAL, SWT.NORMAL, null, false, false, null, -1, 10011046);
return true;
} catch (AssertionError e) {
return false;
@@ -261,7 +260,7 @@ public class LabelFontModificationsTest extends AbstractFontModificationTest {
@Override
public boolean apply(SWTBotGefEditPart input) {
try {
- checkFontStyle(input, SWT.NORMAL, SWT.NORMAL, FontFormat.NORMAL, false, false, null, -1, 8905185);
+ checkFontStyle(input, SWT.NORMAL, SWT.NORMAL, null, false, false, null, -1, 8905185);
return true;
} catch (AssertionError e) {
return false;
@@ -630,7 +629,7 @@ public class LabelFontModificationsTest extends AbstractFontModificationTest {
@Override
public boolean apply(SWTBotGefEditPart input) {
try {
- checkFontStyle(input, SWT.NORMAL, SWT.NORMAL, FontFormat.NORMAL, false, false, null, 12, -1);
+ checkFontStyle(input, SWT.NORMAL, SWT.NORMAL, null, false, false, null, 12, -1);
return true;
} catch (AssertionError e) {
return false;
@@ -676,7 +675,7 @@ public class LabelFontModificationsTest extends AbstractFontModificationTest {
@Override
public boolean apply(SWTBotGefEditPart input) {
try {
- checkFontStyle(input, SWT.NORMAL, SWT.NORMAL, FontFormat.NORMAL, false, false, modifiedFont, -1, -1);
+ checkFontStyle(input, SWT.NORMAL, SWT.NORMAL, null, false, false, modifiedFont, -1, -1);
return true;
} catch (AssertionError e) {
return false;
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 3bac1c27e2..faccd95e63 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
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.sirius.tests.swtbot;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EAttribute;
@@ -436,17 +437,18 @@ public class RefreshWithCustomizedStyleTests extends AbstractRefreshWithCustomiz
}
private Object convertToSiriusPropertyValue(org.eclipse.gmf.runtime.notation.Style gmfStyle, EAttribute gmfStyleAttribute) {
- Object gmfStylePropertyValue = gmfStyle.eGet(gmfStyleAttribute);
+ List<FontFormat> gmfStylePropertyValue = new ArrayList<FontFormat>();
if (gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__BOLD || gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__ITALIC) {
FontStyle gmfFontStyle = (FontStyle) gmfStyle;
if (gmfFontStyle.isBold() && gmfFontStyle.isItalic()) {
- gmfStylePropertyValue = FontFormat.BOLD_ITALIC_LITERAL;
+ gmfStylePropertyValue.add(FontFormat.BOLD_LITERAL);
+ gmfStylePropertyValue.add(FontFormat.ITALIC_LITERAL);
} else if (gmfFontStyle.isBold()) {
- gmfStylePropertyValue = FontFormat.BOLD_LITERAL;
+ gmfStylePropertyValue.add(FontFormat.BOLD_LITERAL);
} else if (gmfFontStyle.isItalic()) {
- gmfStylePropertyValue = FontFormat.ITALIC_LITERAL;
+ gmfStylePropertyValue.add(FontFormat.ITALIC_LITERAL);
} else {
- gmfStylePropertyValue = FontFormat.NORMAL_LITERAL;
+ gmfStylePropertyValue = null;
}
}
return gmfStylePropertyValue;
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/condition/CheckTreeItemFontFormat.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/condition/CheckTreeItemFontFormat.java
index 0cdf4b0c47..689e5c3012 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/condition/CheckTreeItemFontFormat.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/condition/CheckTreeItemFontFormat.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.sirius.tests.swtbot.sequence.condition;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
import org.eclipse.sirius.viewpoint.FontFormat;
@@ -29,7 +32,7 @@ public class CheckTreeItemFontFormat extends DefaultCondition {
*/
private String text;
- private int expectedFontFormat;
+ private List<FontFormat> expectedFontFormat;
/**
* Default Constructor
@@ -40,7 +43,7 @@ public class CheckTreeItemFontFormat extends DefaultCondition {
* the expected {@link FontFormat} for the treeItem
*
*/
- public CheckTreeItemFontFormat(SWTBotTreeItem treeItem, int expectedFontFormat) {
+ public CheckTreeItemFontFormat(SWTBotTreeItem treeItem, List<FontFormat> expectedFontFormat) {
this.treeItem = treeItem;
this.expectedFontFormat = expectedFontFormat;
}
@@ -54,7 +57,7 @@ public class CheckTreeItemFontFormat extends DefaultCondition {
treeItem.widget.getDisplay().syncExec(new Runnable() {
public void run() {
text = treeItem.widget.getText();
- setResult(SWTBotUtils.getWidgetFormat(treeItem.widget).getValue() == expectedFontFormat);
+ setResult(SWTBotUtils.getWidgetFormat(treeItem.widget).equals(expectedFontFormat));
}
});
}
@@ -67,7 +70,15 @@ public class CheckTreeItemFontFormat extends DefaultCondition {
* {@inheritDoc}
*/
public String getFailureMessage() {
- return "The FontFormat of widget" + text + "is not " + FontFormat.get(expectedFontFormat);
+ return "The FontFormat of widget" + text + "is not " + getFontFormatLiterals(expectedFontFormat);
+ }
+
+ private List<String> getFontFormatLiterals(List<FontFormat> fontFormat) {
+ List<String> expected = new ArrayList<String>();
+ for (FontFormat style : fontFormat) {
+ expected.add(style.getName());
+ }
+ return expected;
}
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/AbstractTreeSiriusSWTBotGefTestCase.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/AbstractTreeSiriusSWTBotGefTestCase.java
index 48853569d3..981f57afe8 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/AbstractTreeSiriusSWTBotGefTestCase.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/AbstractTreeSiriusSWTBotGefTestCase.java
@@ -10,7 +10,9 @@
*******************************************************************************/
package org.eclipse.sirius.tests.swtbot.tree;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.eclipse.emf.common.util.EList;
@@ -25,6 +27,7 @@ import org.eclipse.sirius.tree.DTreeItem;
import org.eclipse.sirius.tree.description.TreeItemMapping;
import org.eclipse.sirius.ui.business.api.preferences.SiriusUIPreferencesKeys;
import org.eclipse.sirius.ui.tools.api.color.VisualBindingManager;
+import org.eclipse.sirius.viewpoint.FontFormat;
import org.eclipse.sirius.viewpoint.description.tool.RepresentationCreationDescription;
import org.eclipse.sirius.viewpoint.description.tool.RepresentationNavigationDescription;
import org.eclipse.swt.graphics.Color;
@@ -469,14 +472,22 @@ public class AbstractTreeSiriusSWTBotGefTestCase extends AbstractSiriusSwtBotGef
* widget is not an instance of {@link Control}.
* @since 1.0
*/
- public String getLabelFormat(final TreeItem widget) {
- return syncExec(new Result<String>() {
- public String run() {
- return ((DTreeItem) widget.getData()).getOwnedStyle().getLabelFormat().getName();
+ public List<String> getLabelFormat(final TreeItem widget) {
+ return syncExec(new Result<List<String>>() {
+ public List<String> run() {
+ return getFontFormatLiterals(((DTreeItem) widget.getData()).getOwnedStyle().getLabelFormat());
}
});
}
+ private List<String> getFontFormatLiterals(List<FontFormat> fontFormat) {
+ List<String> expected = new ArrayList<String>();
+ for (FontFormat style : fontFormat) {
+ expected.add(style.getName());
+ }
+ return expected;
+ }
+
/**
* Gets the label alignment of the widget.
*
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeItemStyleDescriptionTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeItemStyleDescriptionTest.java
index 9a1670ace0..24ae1b44a7 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeItemStyleDescriptionTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeItemStyleDescriptionTest.java
@@ -13,8 +13,13 @@ package org.eclipse.sirius.tests.swtbot.tree;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
import org.eclipse.sirius.tests.swtbot.Activator;
import org.eclipse.sirius.tests.swtbot.support.api.business.UILocalSession;
import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource;
@@ -23,6 +28,7 @@ import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotVSMEditor;
import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
import org.eclipse.sirius.tree.DTree;
import org.eclipse.sirius.ui.tools.api.color.VisualBindingManager;
+import org.eclipse.sirius.viewpoint.FontFormat;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
@@ -353,7 +359,7 @@ public class TreeItemStyleDescriptionTest extends AbstractTreeSiriusSWTBotGefTes
String labelExpression = null;
// String labelAlignment = null;
String iconPath = null;
- String labelFormat = null;
+ List<String> labelFormat = null;
Color colorBackground = null;
Color labelColor = null;
@@ -377,18 +383,30 @@ public class TreeItemStyleDescriptionTest extends AbstractTreeSiriusSWTBotGefTes
assertThat(labelSize, equalTo(8));
assertThat(labelExpression, equalTo(NEWECLASS1));
// assertThat(labelAlignment, equalTo("CENTER"));
- assertThat(labelFormat, equalTo("bold"));
+ List<String> actual = labelFormat;
+ List<String> expected = Arrays.asList("bold");
+ assertThat(actual, is(expected));
assertThat(iconPath, anyOf(equalTo(""), nullValue()));
assertThat(colorBackground, equalTo(lightYellow));
assertThat(labelColor, equalTo(lightGreen));
- assertThat(SWTBotUtils.getWidgetFormat(widgetNewEclass1).getName(), equalTo("bold"));
+ SWTBotUtils.getWidgetFormat(widgetNewEclass1);
+ actual = getFontFormatLiterals(SWTBotUtils.getWidgetFormat(widgetNewEclass1));
+ assertThat(actual, is(expected));
assertThat(getWidgetBackgroundColor(widgetNewEclass1), equalTo(lightYellow));
assertThat(getWidgetLabelColor(widgetNewEclass1), equalTo(lightGreen));
assertNull(getWidgetImage(widgetNewEclass1));
assertThat(getWidgetSize(widgetNewEclass1), equalTo(8));
}
+ private static List<String> getFontFormatLiterals(List<FontFormat> fontFormat) {
+ List<String> expected = new ArrayList<String>();
+ for (FontFormat style : fontFormat) {
+ expected.add(style.getName());
+ }
+ return expected;
+ }
+
/**
* Modify all fields in properties view of tree item style description in
* viewpoint specific model (.odesign).
@@ -448,7 +466,7 @@ public class TreeItemStyleDescriptionTest extends AbstractTreeSiriusSWTBotGefTes
String labelExpression = null;
// String labelAlignment = null;
String iconPath = null;
- String labelFormat = null;
+ List<String> labelFormat = null;
Color colorBackground = null;
Color labelColor = null;
@@ -473,10 +491,13 @@ public class TreeItemStyleDescriptionTest extends AbstractTreeSiriusSWTBotGefTes
assertThat(labelSize, equalTo(12));
assertThat(labelExpression, equalTo("Testnew EClass 1"));
// assertThat(labelAlignment, equalTo("RIGHT"));
- assertThat(labelFormat, equalTo("bold_italic"));
+ List<String> actual = labelFormat;
+ List<String> expected = Arrays.asList("bold", "italic");
+ assertThat(actual, is(expected));
assertThat(colorBackground, equalTo(black));
assertThat(labelColor, equalTo(blue));
- assertThat(SWTBotUtils.getWidgetFormat(widgetNewEclass1).getName(), equalTo("bold_italic"));
+ actual = getFontFormatLiterals(SWTBotUtils.getWidgetFormat(widgetNewEclass1));
+ assertThat(actual, is(expected));
assertThat(getWidgetSize(widgetNewEclass1), equalTo(12));
assertThat(getWidgetBackgroundColor(widgetNewEclass1), equalTo(black));
assertThat(getWidgetLabelColor(widgetNewEclass1), equalTo(blue));
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 3d82193af4..ec0813e2ef 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
@@ -248,7 +248,7 @@ public class TreeUIRefreshTests extends AbstractTreeSiriusSWTBotGefTestCase {
TreeUtils.checkTreeItemLabelFormat(treeEditorBot, thirdDTreeItem);
// Test a the normal font format
- changeDTreeItemLabelStyleCmd = SetCommand.create(transactionalEditingDomain, treeItemStyle, ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT, FontFormat.NORMAL_LITERAL);
+ changeDTreeItemLabelStyleCmd = SetCommand.create(transactionalEditingDomain, treeItemStyle, ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT, null);
commandStack.execute(changeDTreeItemLabelStyleCmd);
TreeUtils.checkTreeItemLabelFormat(treeEditorBot, secondDTreeItem);
diff --git a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeViewerManager.java b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeViewerManager.java
index f842061e72..5a50070087 100644
--- a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeViewerManager.java
+++ b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeViewerManager.java
@@ -28,6 +28,7 @@ import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.ColumnViewerEditor;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
import org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -183,7 +184,8 @@ public class DTreeViewerManager extends AbstractDTableViewerManager {
// Wrap the LabelProvider in a DecoratingLabelProvider
ILabelDecorator decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
AdapterFactory adapterFactory = TreeUIPlugin.getPlugin().getItemProvidersAdapterFactory();
- treeViewer.setLabelProvider(new DTreeDecoratingLabelProvider(adapterFactory, decorator));
+ DTreeDecoratingLabelProvider labelProvider = new DTreeDecoratingLabelProvider(adapterFactory, decorator);
+ treeViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(labelProvider));
fillMenu();
triggerColumnSelectedColumn();
@@ -197,8 +199,8 @@ public class DTreeViewerManager extends AbstractDTableViewerManager {
// Create a new CellFocusManager
final TreeViewerFocusCellManager focusCellManager = new TreeViewerFocusCellManager(treeViewer, new FocusCellOwnerDrawHighlighter(treeViewer));
// Create a TreeViewerEditor with focusable cell
- TreeViewerEditor.create(treeViewer, focusCellManager, new DTableColumnViewerEditorActivationStrategy(treeViewer), ColumnViewerEditor.TABBING_HORIZONTAL
- | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
+ TreeViewerEditor.create(treeViewer, focusCellManager, new DTableColumnViewerEditorActivationStrategy(treeViewer),
+ ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
// The input for the table viewer is the instance of DTable
treeViewer.setInput(dRepresentation);
@@ -257,8 +259,8 @@ public class DTreeViewerManager extends AbstractDTableViewerManager {
ISelectionProvider selectionProvider = this.treeViewer;
this.treeViewer.addDragSupport(supportedOperations, new ByteArrayTransfer[] { LocalSelectionTransfer.getTransfer() }, new ModelDragTargetAdapter(selectionProvider));
- this.treeViewer.addDropSupport(supportedOperations, new ByteArrayTransfer[] { LocalSelectionTransfer.getTransfer() }, new DTreeItemDropListener(this.treeViewer, this.editingDomain,
- this.treeCommandFactory, this.accessor));
+ this.treeViewer.addDropSupport(supportedOperations, new ByteArrayTransfer[] { LocalSelectionTransfer.getTransfer() },
+ new DTreeItemDropListener(this.treeViewer, this.editingDomain, this.treeCommandFactory, this.accessor));
}
/**
@@ -297,7 +299,8 @@ public class DTreeViewerManager extends AbstractDTableViewerManager {
}
/**
- * Initialize a cache and add, if needed, the contextual menu for the table. <BR>
+ * Initialize a cache and add, if needed, the contextual menu for the table.
+ * <BR>
* Cached the actions of creation and deletion in order to increase
* performance and not calculate it on each contextual menu.<BR>
*/
diff --git a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/provider/DTreeItemLabelProvider.java b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/provider/DTreeItemLabelProvider.java
index eb8c29fa94..6f1172132e 100644
--- a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/provider/DTreeItemLabelProvider.java
+++ b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/provider/DTreeItemLabelProvider.java
@@ -12,30 +12,36 @@ package org.eclipse.sirius.tree.ui.tools.internal.editor.provider;
import java.io.File;
import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.sirius.common.tools.api.resource.FileProvider;
import org.eclipse.sirius.common.tools.api.util.StringUtil;
import org.eclipse.sirius.tree.DTreeItem;
+import org.eclipse.sirius.tree.TreeItemStyle;
import org.eclipse.sirius.tree.ui.provider.TreeUIPlugin;
import org.eclipse.sirius.ui.tools.api.color.VisualBindingManager;
import org.eclipse.sirius.ui.tools.api.provider.DSemanticTargetBasedLabelProvider;
+import org.eclipse.sirius.ui.tools.internal.editor.DefaultFontStyler;
import org.eclipse.sirius.viewpoint.BasicLabelStyle;
import org.eclipse.sirius.viewpoint.FontFormat;
import org.eclipse.sirius.viewpoint.RGBValues;
import org.eclipse.sirius.viewpoint.SiriusPlugin;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
/**
* Label provider for all the tree item.
*
* @author <a href="mailto:nathalie.lepine@obeo.fr">Nathalie Lepine</a>
*/
-public class DTreeItemLabelProvider extends DSemanticTargetBasedLabelProvider {
+public class DTreeItemLabelProvider extends DSemanticTargetBasedLabelProvider implements IStyledLabelProvider {
/**
* Default constructor.
@@ -68,11 +74,11 @@ public class DTreeItemLabelProvider extends DSemanticTargetBasedLabelProvider {
final DTreeItem item = (DTreeItem) element;
if (item.getOwnedStyle() != null) {
final int size = item.getOwnedStyle().getLabelSize();
- FontFormat labelFormat = null;
+ List<FontFormat> labelFormat = new ArrayList<FontFormat>();
if (item.getOwnedStyle().getLabelFormat() != null) {
labelFormat = item.getOwnedStyle().getLabelFormat();
} else {
- labelFormat = FontFormat.NORMAL_LITERAL;
+ labelFormat.clear();
}
return VisualBindingManager.getDefault().getFontFromLabelFormatAndSize(labelFormat, size);
}
@@ -147,4 +153,44 @@ public class DTreeItemLabelProvider extends DSemanticTargetBasedLabelProvider {
}
return result;
}
+
+ @Override
+ public StyledString getStyledText(Object element) {
+ String text = getText(element);
+ DefaultFontStyler styler = new DefaultFontStyler(getFont(element), getForeground(element), getBackground(element), getUnderline(element), getStrikeout(element));
+ if (text == null) {
+ text = "";
+ }
+ StyledString styledString = new StyledString(text, styler);
+
+ return styledString;
+ }
+
+ private boolean getStrikeout(Object element) {
+ if (element instanceof DTreeItem) {
+ final DTreeItem item = (DTreeItem) element;
+ TreeItemStyle ownedStyle = item.getOwnedStyle();
+ if (ownedStyle != null) {
+ List<FontFormat> labelFormat = ownedStyle.getLabelFormat();
+ if (labelFormat != null) {
+ return labelFormat.contains(FontFormat.STRIKE_THROUGH_LITERAL);
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean getUnderline(Object element) {
+ if (element instanceof DTreeItem) {
+ final DTreeItem item = (DTreeItem) element;
+ TreeItemStyle ownedStyle = item.getOwnedStyle();
+ if (ownedStyle != null) {
+ List<FontFormat> labelFormat = ownedStyle.getLabelFormat();
+ if (labelFormat != null) {
+ return labelFormat.contains(FontFormat.UNDERLINE_LITERAL);
+ }
+ }
+ }
+ return false;
+ }
}
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 551f3dd390..7f5d6f687c 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
@@ -13,6 +13,7 @@ package org.eclipse.sirius.tree.business.internal.refresh;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
@@ -250,9 +251,9 @@ public class DTreeElementSynchronizerSpec extends DTreeElementSynchronizerImpl {
}
}
- private boolean isEqual(FontFormat labelFormat, FontFormat labelFormat2) {
+ private boolean isEqual(List<FontFormat> labelFormat, List<FontFormat> labelFormat2) {
if (labelFormat != null && labelFormat2 != null) {
- return labelFormat.getLiteral().equals(labelFormat2.getLiteral());
+ return labelFormat.equals(labelFormat2);
}
return false;
diff --git a/plugins/org.eclipse.sirius.ui/plugin.properties b/plugins/org.eclipse.sirius.ui/plugin.properties
index 7ac1bbcb44..d255edfb6c 100644
--- a/plugins/org.eclipse.sirius.ui/plugin.properties
+++ b/plugins/org.eclipse.sirius.ui/plugin.properties
@@ -208,6 +208,8 @@ _UI_DefaultColors_light_gray_literal = light gray
_UI_FontFormat_normal_literal = Normal
_UI_FontFormat_italic_literal = Italic
_UI_FontFormat_bold_literal = Bold
+_UI_FontFormat_underline_literal = Underline
+_UI_FontFormat_strike_through_literal = Strike through
_UI_ResizeKind_NONE_literal = None
_UI_ResizeKind_NSEW_literal = NSEW
_UI_ResizeKind_NORTH_SOUTH_literal = North South
@@ -1032,5 +1034,3 @@ _UI_Viewpoint_customizes_feature = Customizes
_UI_EStructuralFeatureCustomization_applyOnAll_feature = Apply On All
_UI_EStructuralFeatureCustomization_applyOnAll_description = If true, this customization will be applied on all style description.
_UI_DAnalysis_semanticResources_feature = Semantic Resources
-_UI_FontFormat_underline_literal = Underline
-_UI_FontFormat_strike_through_literal = StrikeThrough
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/color/VisualBindingManager.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/color/VisualBindingManager.java
index 410a11e8aa..6e2f0694f9 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/color/VisualBindingManager.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/color/VisualBindingManager.java
@@ -13,6 +13,7 @@ package org.eclipse.sirius.ui.tools.api.color;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
@@ -620,6 +621,40 @@ public class VisualBindingManager {
}
/**
+ * Retrieves if a label is underlined from a label style.
+ *
+ * @param style
+ * current {@link BasicLabelStyle}.
+ * @return true if label is underlined otherwise false.
+ */
+ public boolean isUnderlineFromLabelStyle(final BasicLabelStyle style) {
+ List<FontFormat> labelFormat = style.getLabelFormat();
+ for (FontFormat fontFormat : labelFormat) {
+ if (FontFormat.UNDERLINE_LITERAL == fontFormat) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Retrieves if a label is strike through from a label style.
+ *
+ * @param style
+ * current {@link BasicLabelStyle}.
+ * @return true if label is strike through otherwise false.
+ */
+ public boolean isStrikeThroughFromLabelStyle(final BasicLabelStyle style) {
+ List<FontFormat> labelFormat = style.getLabelFormat();
+ for (FontFormat fontFormat : labelFormat) {
+ if (FontFormat.STRIKE_THROUGH_LITERAL == fontFormat) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Return a font from a label format and a label size.
*
* @param labelFormat
@@ -628,7 +663,7 @@ public class VisualBindingManager {
* current size
* @return a Font from a {@link FontFormat} and a size.
*/
- public Font getFontFromLabelFormatAndSize(final FontFormat labelFormat, final int labelSize) {
+ public Font getFontFromLabelFormatAndSize(final List<FontFormat> labelFormat, final int labelSize) {
return getFontFromLabelFormatAndSize(labelFormat, labelSize, DEFAULT_FONT_NAME);
}
@@ -643,20 +678,21 @@ public class VisualBindingManager {
* the name of the font.
* @return a Font from a {@link FontFormat} and a size.
*/
- public Font getFontFromLabelFormatAndSize(final FontFormat labelFormat, final int labelSize, final String fontName) {
+ public Font getFontFromLabelFormatAndSize(final List<FontFormat> labelFormat, final int labelSize, final String fontName) {
final int rangedSize = Math.max(labelSize, 1);
final FontStyleDescriptor desc = new FontStyleDescriptor(labelFormat, rangedSize, fontName);
if (!fontCache.containsKey(desc)) {
int format = SWT.NORMAL;
- if (FontFormat.BOLD_LITERAL.equals(labelFormat)) {
- format = SWT.BOLD;
- }
- if (FontFormat.ITALIC_LITERAL.equals(labelFormat)) {
- format = SWT.ITALIC;
- }
- if (FontFormat.BOLD_ITALIC_LITERAL.equals(labelFormat)) {
- format = SWT.BOLD | SWT.ITALIC;
+
+ for (FontFormat fontFormat : labelFormat) {
+ if (FontFormat.BOLD_LITERAL.equals(fontFormat)) {
+ format = format | SWT.BOLD;
+ }
+ if (FontFormat.ITALIC_LITERAL.equals(fontFormat)) {
+ format = format | SWT.ITALIC;
+ }
}
+
fontCache.put(desc, new Font(Display.getDefault(), fontName, rangedSize, format));
}
return fontCache.get(desc);
@@ -671,11 +707,11 @@ public class VisualBindingManager {
private static final class FontStyleDescriptor {
final String name;
- final FontFormat format;
+ final List<FontFormat> format;
final int size;
- public FontStyleDescriptor(final FontFormat format, final int size, final String name) {
+ public FontStyleDescriptor(final List<FontFormat> format, final int size, final String name) {
this.format = format;
this.size = size;
this.name = name;
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/DefaultFontStyler.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/DefaultFontStyler.java
new file mode 100644
index 0000000000..0429a3209f
--- /dev/null
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/DefaultFontStyler.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.ui.tools.internal.editor;
+
+import org.eclipse.jface.viewers.StyledString.Styler;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.TextStyle;
+
+/**
+ * A default font styler used by tables and trees.
+ *
+ * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a>
+ */
+public class DefaultFontStyler extends Styler {
+ private final Font font;
+
+ private final Color foregroundColor;
+
+ private final Color backgroundColor;
+
+ private boolean strikeout;
+
+ private boolean underline;
+
+ /**
+ * Default constructor.
+ *
+ * @param font
+ * Font to use.
+ * @param foregroundColor
+ * foreground color to use.
+ * @param backgroundColor
+ * background color to use.
+ * @param strikeout
+ * True if is struck out false otherwise.
+ * @param underline
+ * True if is underlined false otherwise.
+ */
+ public DefaultFontStyler(Font font, Color foregroundColor, Color backgroundColor, boolean underline, boolean strikeout) {
+ this.font = font;
+ this.foregroundColor = foregroundColor;
+ this.backgroundColor = backgroundColor;
+ this.strikeout = strikeout;
+ this.underline = underline;
+ }
+
+ @Override
+ public void applyStyles(TextStyle textStyle) {
+ if (font != null) {
+ textStyle.font = font;
+ }
+ if (foregroundColor != null) {
+ textStyle.foreground = foregroundColor;
+ }
+ if (backgroundColor != null) {
+ textStyle.background = backgroundColor;
+ }
+ textStyle.strikeout = strikeout;
+ textStyle.underline = underline;
+ }
+}

Back to the top