From 0915ecc9f01fa1c75c8afa3bf81b5db1be490c17 Mon Sep 17 00:00:00 2001 From: Laurent Fasani Date: Wed, 3 Apr 2024 18:05:23 +0200 Subject: [PATCH] [346] Support "Paste Style" when source and target are of different types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note that paste style has been disabled from Edge to Node or from Edge to Container to avoid inconsistency between Sirius and GMF style. https://github.com/eclipse-sirius/sirius-desktop/issues/346 Signed-off-by: Laurent Fasani Signed-off-by: Séraphin Costa --- .../AbstractSiriusFormatDataManager.java | 19 +- .../api/format/SiriusStyleApplicator.java | 75 +++++++- .../layout/PasteStylePureGraphicalAction.java | 15 +- .../data/unit/copyAppearance/490444.aird | 85 ++++++++- .../data/unit/copyAppearance/490444.ecore | 2 + .../data/unit/copyAppearance/My.odesign | 11 +- .../tabbar/PasteStylePureGraphicalTest.java | 177 +++++++++++++++--- 7 files changed, 342 insertions(+), 42 deletions(-) diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/AbstractSiriusFormatDataManager.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/AbstractSiriusFormatDataManager.java index bff1c9a70b..42cadd22aa 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/AbstractSiriusFormatDataManager.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/AbstractSiriusFormatDataManager.java @@ -63,6 +63,7 @@ import org.eclipse.sirius.diagram.DNodeContainer; import org.eclipse.sirius.diagram.DNodeList; import org.eclipse.sirius.diagram.DNodeListElement; +import org.eclipse.sirius.diagram.EdgeStyle; import org.eclipse.sirius.diagram.EdgeTarget; import org.eclipse.sirius.diagram.business.api.query.DDiagramElementQuery; import org.eclipse.sirius.diagram.formatdata.AbstractFormatData; @@ -788,15 +789,17 @@ protected void applySiriusStyle(DSemanticDecorator semanticDecorator, AbstractFo @SuppressWarnings("unchecked") protected void applyGMFStyle(View newView, AbstractFormatData formatData) { if (newView != null && formatData.getGmfView() != null) { - @SuppressWarnings("rawtypes") - List excludedStyles = new ArrayList<>(); - if (newView instanceof Edge) { - // The style of RoutingStyle class is considered as format - // properties. So they have already been pasted during paste - // format. - excludedStyles.add(NotationPackage.eINSTANCE.getRoutingStyle()); + if (!(formatData.getSiriusStyle() instanceof EdgeStyle) || newView.getElement() instanceof DEdge) { + @SuppressWarnings("rawtypes") + List excludedStyles = new ArrayList<>(); + if (newView instanceof Edge) { + // The style of RoutingStyle class is considered as format + // properties. So they have already been pasted during paste + // format. + excludedStyles.add(NotationPackage.eINSTANCE.getRoutingStyle()); + } + new ViewRefactorHelper().copyViewAppearance(formatData.getGmfView(), newView, excludedStyles); } - new ViewRefactorHelper().copyViewAppearance(formatData.getGmfView(), newView, excludedStyles); } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/SiriusStyleApplicator.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/SiriusStyleApplicator.java index 70d06274ba..be5bb779f2 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/SiriusStyleApplicator.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/SiriusStyleApplicator.java @@ -12,6 +12,11 @@ *******************************************************************************/ package org.eclipse.sirius.diagram.ui.tools.api.format; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.sirius.diagram.ContainerStyle; @@ -22,6 +27,7 @@ import org.eclipse.sirius.diagram.EdgeStyle; import org.eclipse.sirius.diagram.NodeStyle; import org.eclipse.sirius.tools.internal.SiriusCopierHelper; +import org.eclipse.sirius.viewpoint.Customizable; import org.eclipse.sirius.viewpoint.DSemanticDecorator; import org.eclipse.sirius.viewpoint.Style; import org.eclipse.sirius.viewpoint.ViewpointPackage; @@ -69,7 +75,66 @@ default void applySiriusStyle(DSemanticDecorator semanticDecorator, Style sirius } else if (semanticDecorator instanceof DEdge && copyOfSiriusStyle instanceof EdgeStyle) { computeCustomFeatures(((DEdge) semanticDecorator).getOwnedStyle(), copyOfSiriusStyle); ((DEdge) semanticDecorator).setOwnedStyle((EdgeStyle) copyOfSiriusStyle); + } else { + // try to apply style if the Diagram elements are different + applySiriusStyleAtBest(semanticDecorator, siriusStyle); + } + } + + private void applySiriusStyleAtBest(DSemanticDecorator targetSemanticDecorator, Style siriusSourceStyle) { + if (!(siriusSourceStyle instanceof EdgeStyle)) { + for (Customizable targetStyle : getStyle(targetSemanticDecorator)) { + addNewValueAndSetCustomFeaturesAtBest(siriusSourceStyle, targetStyle); + } + } + } + + /** + * Check for each attribute of targetStyleToChange if it is the same or equivalent in sourceStyle.
+ * Then it changes the value and add a custom feature. + * + * @param sourceStyle + * The style to compare with + * @param targetStyleToChange + * The style to update. + */ + private void addNewValueAndSetCustomFeaturesAtBest(Customizable sourceStyle, Customizable targetStyleToChange) { + final EAttribute[] exceptionAttributes = { // + ViewpointPackage.Literals.IDENTIFIED_ELEMENT__UID, // + ViewpointPackage.Literals.CUSTOMIZABLE__CUSTOM_FEATURES, // + ViewpointPackage.Literals.BASIC_LABEL_STYLE__SHOW_ICON, // + ViewpointPackage.Literals.BASIC_LABEL_STYLE__ICON_PATH, // + }; + for (EAttribute targetStyleAttribute : targetStyleToChange.eClass().getEAllAttributes()) { + if (!Arrays.asList(exceptionAttributes).contains(targetStyleAttribute)) { + EAttribute sourceStyleAttribute = getCorrespondingEAttribute(targetStyleAttribute, sourceStyle); + if (sourceStyleAttribute != null) { + if (!targetStyleToChange.eGet(targetStyleAttribute).equals(sourceStyle.eGet(sourceStyleAttribute))) { + targetStyleToChange.getCustomFeatures().add(targetStyleAttribute.getName()); + targetStyleToChange.eSet(targetStyleAttribute, sourceStyle.eGet(sourceStyleAttribute)); + } + } + } + } + } + + private List getStyle(DSemanticDecorator semanticDecorator) { + List styles = new ArrayList<>(); + if (semanticDecorator instanceof DNode node) { + styles.add(node.getOwnedStyle()); + } else if (semanticDecorator instanceof DNodeListElement listElement) { + styles.add(listElement.getOwnedStyle()); + } else if (semanticDecorator instanceof DDiagramElementContainer container) { + styles.add(container.getOwnedStyle()); + } else if (semanticDecorator instanceof DEdge edge) { + Style ownedStyle = edge.getOwnedStyle(); + if (ownedStyle instanceof EdgeStyle edgeStyle) { + Arrays.asList(edgeStyle.getCenterLabelStyle(), edgeStyle.getBeginLabelStyle(), edgeStyle.getEndLabelStyle()).stream()// + .filter(Objects::nonNull) // + .forEach(styles::add); // + } } + return styles; } /** @@ -81,9 +146,13 @@ default void applySiriusStyle(DSemanticDecorator semanticDecorator, Style sirius * @param newStyle * The new style in which to add custom features. */ - default void computeCustomFeatures(Style oldStyle, Style newStyle) { + private void computeCustomFeatures(Style oldStyle, Style newStyle) { + final EAttribute[] exceptionAttributes = { // + ViewpointPackage.Literals.IDENTIFIED_ELEMENT__UID, // + ViewpointPackage.Literals.CUSTOMIZABLE__CUSTOM_FEATURES, // + }; for (EAttribute attribute : newStyle.eClass().getEAllAttributes()) { - if (!ViewpointPackage.Literals.CUSTOMIZABLE__CUSTOM_FEATURES.equals(attribute)) { + if (!Arrays.asList(exceptionAttributes).contains(attribute)) { EAttribute attributeOfOldStyle = getCorrespondingEAttribute(attribute, oldStyle); if (attributeOfOldStyle != null) { if (newStyle.eIsSet(attribute)) { @@ -98,7 +167,7 @@ default void computeCustomFeatures(Style oldStyle, Style newStyle) { } } - private EAttribute getCorrespondingEAttribute(EAttribute attribute, Style style) { + private EAttribute getCorrespondingEAttribute(EAttribute attribute, Customizable style) { EAttribute result = null; if (style.eClass().getFeatureID(attribute) != -1) { result = attribute; diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/PasteStylePureGraphicalAction.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/PasteStylePureGraphicalAction.java index 3723f57bb9..d2726fbf1c 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/PasteStylePureGraphicalAction.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/PasteStylePureGraphicalAction.java @@ -31,6 +31,8 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.sirius.common.ui.tools.api.util.EclipseUIUtil; import org.eclipse.sirius.diagram.DDiagramElement; +import org.eclipse.sirius.diagram.DEdge; +import org.eclipse.sirius.diagram.EdgeStyle; import org.eclipse.sirius.diagram.ui.provider.DiagramUIPlugin; import org.eclipse.sirius.diagram.ui.provider.Messages; import org.eclipse.sirius.diagram.ui.tools.api.format.SiriusStyleClipboard; @@ -233,12 +235,15 @@ public void run() { for (IGraphicalEditPart targetEditPart : targetEditParts) { if (targetEditPart.resolveSemanticElement() instanceof DDiagramElement targetElement && canEditElement(targetElement)) { - // create command - clipboard.getGmfView().ifPresent(gmfView -> { - command.add(PasteStyleCommandProvider.createGMFCommand(domain, targetEditPart, gmfView)); - }); clipboard.getSiriusStyle().ifPresent(siriusStyle -> { - command.add(PasteStyleCommandProvider.createSiriusCommand(domain, targetElement, siriusStyle)); + clipboard.getGmfView().ifPresent(gmfView -> { + // exclude copy-paste from Edge to Node/Container + if (!(siriusStyle instanceof EdgeStyle) || targetElement instanceof DEdge) { + // create command + command.add(PasteStyleCommandProvider.createGMFCommand(domain, targetEditPart, gmfView)); + command.add(PasteStyleCommandProvider.createSiriusCommand(domain, targetElement, siriusStyle)); + } + }); }); } } diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/490444.aird b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/490444.aird index d20efb441b..e0b73198cb 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/490444.aird +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/490444.aird @@ -1,17 +1,17 @@ - + 490444.ecore - + - + @@ -113,6 +113,24 @@ + + + + + + + + + + + + + + + + + + @@ -258,6 +276,27 @@ + + + + + labelFormat + labelSize + labelColor + bold + strike_through + + + + + + + + + + + + @@ -333,6 +372,24 @@ + + + + + + + + + + + + + + + + + + @@ -470,6 +527,28 @@ + + + + + labelSize + labelColor + labelFormat + bold + underline + + + + + + + + + underline + + + + diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/490444.ecore b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/490444.ecore index c8fc58f807..7964a29336 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/490444.ecore +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/490444.ecore @@ -15,4 +15,6 @@ + + diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/My.odesign b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/My.odesign index 62e6087fd1..216cced122 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/My.odesign +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/My.odesign @@ -1,5 +1,5 @@ - + @@ -30,6 +30,15 @@ + + + diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/PasteStylePureGraphicalTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/PasteStylePureGraphicalTest.java index 1aad6a3c29..c0c26129cb 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/PasteStylePureGraphicalTest.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/PasteStylePureGraphicalTest.java @@ -30,6 +30,7 @@ import org.eclipse.sirius.diagram.ui.internal.edit.parts.DEdgeBeginNameEditPart; import org.eclipse.sirius.diagram.ui.internal.edit.parts.DEdgeEditPart; import org.eclipse.sirius.diagram.ui.internal.edit.parts.DEdgeNameEditPart; +import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeContainerEditPart; import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeEditPart; import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeListEditPart; import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeNameEditPart; @@ -294,9 +295,11 @@ public void testPasteEnablement() { private static final RGBValues LIGHT_GREY = RGBValues.create(209, 209, 209); - private static final RGBValues RED = RGBValues.create(227, 164, 156); + private static final RGBValues RED = RGBValues.create(239, 41, 41); - private static final RGBValues BLUE = RGBValues.create(194, 239, 255); + private static final RGBValues RED_LEGACY = RGBValues.create(227, 164, 156); + + private static final RGBValues BLUE = RGBValues.create(114, 159, 207); private static final RGBValues YELLOW = RGBValues.create(255, 245, 181); @@ -444,7 +447,7 @@ private void assertEdgeStyle(String name, Class type, Expect public void testCopyBoldLabelToNodeLabel() { openDiagramComplex(); - assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED)); + assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED_LEGACY)); assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), WHITE)); performCopy("NewEClass5", DNodeNameEditPart.class); @@ -452,14 +455,14 @@ public void testCopyBoldLabelToNodeLabel() { performPaste("NewEClass2", DNodeNameEditPart.class); SWTBotUtils.waitAllUiEvents(); - assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED)); - assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED)); + assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED_LEGACY)); + assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED_LEGACY)); } public void testCopyBoldNodeLabelToNode() { openDiagramComplex(); - assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED)); + assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED_LEGACY)); assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), WHITE)); performCopy("NewEClass5", DNodeNameEditPart.class); @@ -467,14 +470,14 @@ public void testCopyBoldNodeLabelToNode() { performPaste("NewEClass2", DNodeEditPart.class); SWTBotUtils.waitAllUiEvents(); - assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED)); - assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED)); + assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED_LEGACY)); + assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED_LEGACY)); } public void testCopyBoldNodeToNodeLabel() { openDiagramComplex(); - assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED)); + assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED_LEGACY)); assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), WHITE)); performCopy("NewEClass5", DNodeEditPart.class); @@ -482,14 +485,14 @@ public void testCopyBoldNodeToNodeLabel() { performPaste("NewEClass2", DNodeNameEditPart.class); SWTBotUtils.waitAllUiEvents(); - assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED)); - assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED)); + assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED_LEGACY)); + assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED_LEGACY)); } public void testCopyBoldNodeToNode() { openDiagramComplex(); - assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED)); + assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED_LEGACY)); assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), WHITE)); performCopy("NewEClass5", DNodeEditPart.class); @@ -497,8 +500,8 @@ public void testCopyBoldNodeToNode() { performPaste("NewEClass2", DNodeEditPart.class); SWTBotUtils.waitAllUiEvents(); - assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED)); - assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED)); + assertNodeStyle("NewEClass5", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED_LEGACY)); + assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), RED_LEGACY)); } public void testCopyDefaultNodeLabelToNodeLabel() { @@ -561,6 +564,7 @@ public void testCopyDefaultNodeToNode() { assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), GREY)); } + // Note: Copy Paste Style from edge to node or from edge to container doen't work for the moment public void testCopyDefaultEdgeToNode() { openDiagramComplex(); @@ -575,9 +579,10 @@ public void testCopyDefaultEdgeToNode() { assertEdgeStyle("Reference2- CENTER", DEdgeEditPart.class, new ExpectedEdgeStyle(new ExpectedFontStyle(false, false, false, false, BLACK), new ExpectedFontStyle(false, false, true, false, DARK_ORANGE), new ExpectedFontStyle(true, true, true, true, LIGHT_BLUE), new ExpectedFontStyle(false, false, false, false, BLACK))); - assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, false, false, false, BLACK), WHITE)); + assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), WHITE)); } + // Note: Copy Paste Style from edge to node or from edge to container doen't work for the moment public void testCopyDefaultLabelEdgeToNode() { openDiagramComplex(); @@ -592,9 +597,10 @@ public void testCopyDefaultLabelEdgeToNode() { assertEdgeStyle("Reference2- CENTER", DEdgeEditPart.class, new ExpectedEdgeStyle(new ExpectedFontStyle(false, false, false, false, BLACK), new ExpectedFontStyle(false, false, true, false, DARK_ORANGE), new ExpectedFontStyle(true, true, true, true, LIGHT_BLUE), new ExpectedFontStyle(false, false, false, false, BLACK))); - assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, false, false, false, BLACK), WHITE)); + assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), WHITE)); } + // Note: Copy Paste Style from edge to node or from edge to container doen't work for the moment public void testCopyDefaultLabelEdgeToLabelNode() { openDiagramComplex(); @@ -609,9 +615,10 @@ public void testCopyDefaultLabelEdgeToLabelNode() { assertEdgeStyle("Reference2- CENTER", DEdgeEditPart.class, new ExpectedEdgeStyle(new ExpectedFontStyle(false, false, false, false, BLACK), new ExpectedFontStyle(false, false, true, false, DARK_ORANGE), new ExpectedFontStyle(true, true, true, true, LIGHT_BLUE), new ExpectedFontStyle(false, false, false, false, BLACK))); - assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, false, false, false, BLACK), WHITE)); + assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), WHITE)); } + // Note: Copy Paste Style from edge to node or from edge to container doen't work for the moment public void testCopyDefaultEdgeToLabelNode() { openDiagramComplex(); @@ -626,9 +633,10 @@ public void testCopyDefaultEdgeToLabelNode() { assertEdgeStyle("Reference2- CENTER", DEdgeEditPart.class, new ExpectedEdgeStyle(new ExpectedFontStyle(false, false, false, false, BLACK), new ExpectedFontStyle(false, false, true, false, DARK_ORANGE), new ExpectedFontStyle(true, true, true, true, LIGHT_BLUE), new ExpectedFontStyle(false, false, false, false, BLACK))); - assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, false, false, false, BLACK), WHITE)); + assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), WHITE)); } + // Note: Copy Paste Style from edge to node or from edge to container doen't work for the moment public void testCopyBoldEdgeToNode() { openDiagramComplex(); @@ -643,10 +651,11 @@ public void testCopyBoldEdgeToNode() { assertEdgeStyle("Reference1- CENTER", DEdgeEditPart.class, new ExpectedEdgeStyle(new ExpectedFontStyle(true, false, false, false, BLACK), new ExpectedFontStyle(true, false, false, false, DARK_ORANGE), new ExpectedFontStyle(true, false, false, false, LIGHT_BLUE), new ExpectedFontStyle(true, false, false, false, BLACK))); - assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, false, false, false, BLACK), WHITE)); + assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), WHITE)); } + // Note: Copy Paste Style from edge to node or from edge to container doen't work for the moment public void testCopyBoldLabelEdgeToNode() { openDiagramComplex(); @@ -661,9 +670,10 @@ public void testCopyBoldLabelEdgeToNode() { assertEdgeStyle("Reference1- CENTER", DEdgeEditPart.class, new ExpectedEdgeStyle(new ExpectedFontStyle(true, false, false, false, BLACK), new ExpectedFontStyle(true, false, false, false, DARK_ORANGE), new ExpectedFontStyle(true, false, false, false, LIGHT_BLUE), new ExpectedFontStyle(true, false, false, false, BLACK))); - assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, false, false, false, BLACK), WHITE)); + assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), WHITE)); } + // Note: Copy Paste Style from edge to node or from edge to container doen't work for the moment public void testCopyBoldEdgeToLabelNode() { openDiagramComplex(); @@ -678,9 +688,10 @@ public void testCopyBoldEdgeToLabelNode() { assertEdgeStyle("Reference1- CENTER", DEdgeEditPart.class, new ExpectedEdgeStyle(new ExpectedFontStyle(true, false, false, false, BLACK), new ExpectedFontStyle(true, false, false, false, DARK_ORANGE), new ExpectedFontStyle(true, false, false, false, LIGHT_BLUE), new ExpectedFontStyle(true, false, false, false, BLACK))); - assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, false, false, false, BLACK), WHITE)); + assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), WHITE)); } + // Note: Copy Paste Style from edge to node or from edge to container doen't work for the moment public void testCopyBoldLabelEdgeToLabelNode() { openDiagramComplex(); @@ -695,7 +706,7 @@ public void testCopyBoldLabelEdgeToLabelNode() { assertEdgeStyle("Reference1- CENTER", DEdgeEditPart.class, new ExpectedEdgeStyle(new ExpectedFontStyle(true, false, false, false, BLACK), new ExpectedFontStyle(true, false, false, false, DARK_ORANGE), new ExpectedFontStyle(true, false, false, false, LIGHT_BLUE), new ExpectedFontStyle(true, false, false, false, BLACK))); - assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, false, false, false, BLACK), WHITE)); + assertNodeStyle("NewEClass2", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), WHITE)); } private void testCopyDefaultStyleRefresh(String sourceContainer, String targetContainer, ExpectedContainerStyle sourceStyle, ExpectedContainerStyle targetStyle) { @@ -764,4 +775,126 @@ public void testCopyGreyBGToBoldAndRefresh() { var boldItalic = new ExpectedFontStyle(true, true, false, false, BLACK); testCopyDefaultStyleRefresh("NewDataType3", "NewEnum2", new ExpectedContainerStyle(DEFAULT_FONT, LIGHT_GREY, LIGHT_GREY), new ExpectedContainerStyle(boldItalic, YELLOW, WHITE)); } + + // Node -> Container + public void testCopyDefaultNodeToDefaultContainer() { + openDiagramComplex(); + + assertNodeStyle("NewEClass6", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), GREY)); + assertContainerStyle("newPackage2", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(false, false, true, false, BLACK), BLUE, LIGHT_GREY)); + + performCopy("NewEClass6", DNodeEditPart.class); + SWTBotUtils.waitAllUiEvents(); + performPaste("newPackage2", DNodeContainerEditPart.class); + SWTBotUtils.waitAllUiEvents(); + + assertNodeStyle("NewEClass6", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), GREY)); + assertContainerStyle("newPackage2", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(false, true, false, false, BLACK), GREY, LIGHT_GREY)); + } + + public void testCopyStylishNodeToDefaultContainer() { + openDiagramComplex(); + + assertNodeStyle("NewEClass3", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), GREY)); + assertContainerStyle("newPackage2", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(false, false, true, false, BLACK), BLUE, LIGHT_GREY)); + + performCopy("NewEClass3", DNodeEditPart.class); + SWTBotUtils.waitAllUiEvents(); + performPaste("newPackage2", DNodeContainerEditPart.class); + SWTBotUtils.waitAllUiEvents(); + + assertNodeStyle("NewEClass3", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), GREY)); + assertContainerStyle("newPackage2", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(true, true, false, false, BLACK), GREY, LIGHT_GREY)); + } + + public void testCopyStylishNodeToStylishContainer() { + openDiagramComplex(); + + assertNodeStyle("NewEClass3", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), GREY)); + assertContainerStyle("newPackage1", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(true, false, true, false, RED), BLUE, LIGHT_GREY)); + + performCopy("NewEClass3", DNodeEditPart.class); + SWTBotUtils.waitAllUiEvents(); + performPaste("newPackage1", DNodeContainerEditPart.class); + SWTBotUtils.waitAllUiEvents(); + + assertNodeStyle("NewEClass3", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), GREY)); + assertContainerStyle("newPackage1", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(true, true, false, false, BLACK), GREY, LIGHT_GREY)); + } + + public void testCopyDefaultNodeToStylishContainer() { + openDiagramComplex(); + + assertNodeStyle("NewEClass6", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), GREY)); + assertContainerStyle("newPackage1", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(true, false, true, false, RED), BLUE, LIGHT_GREY)); + + performCopy("NewEClass6", DNodeEditPart.class); + SWTBotUtils.waitAllUiEvents(); + performPaste("newPackage1", DNodeContainerEditPart.class); + SWTBotUtils.waitAllUiEvents(); + + assertNodeStyle("NewEClass6", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), GREY)); + assertContainerStyle("newPackage1", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(false, true, false, false, BLACK), GREY, LIGHT_GREY)); + } + + // Container -> Node + public void testCopyDefaultContainerToDefaultNode() { + openDiagramComplex(); + + assertContainerStyle("newPackage2", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(false, false, true, false, BLACK), BLUE, LIGHT_GREY)); + assertNodeStyle("NewEClass6", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), GREY)); + + performCopy("newPackage2", DNodeContainerEditPart.class); + SWTBotUtils.waitAllUiEvents(); + performPaste("NewEClass6", DNodeEditPart.class); + SWTBotUtils.waitAllUiEvents(); + + assertContainerStyle("newPackage2", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(false, false, true, false, BLACK), BLUE, LIGHT_GREY)); + assertNodeStyle("NewEClass6", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, false, true, false, BLACK), BLUE)); + } + + public void testCopyDefaultContainerToStylishNode() { + openDiagramComplex(); + + assertContainerStyle("newPackage2", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(false, false, true, false, BLACK), BLUE, LIGHT_GREY)); + assertNodeStyle("NewEClass3", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), GREY)); + + performCopy("newPackage2", DNodeContainerEditPart.class); + SWTBotUtils.waitAllUiEvents(); + performPaste("NewEClass3", DNodeEditPart.class); + SWTBotUtils.waitAllUiEvents(); + + assertContainerStyle("newPackage2", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(false, false, true, false, BLACK), BLUE, LIGHT_GREY)); + assertNodeStyle("NewEClass3", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, false, true, false, BLACK), BLUE)); + } + + public void testCopyStylishContainerToStylishNode() { + openDiagramComplex(); + + assertContainerStyle("newPackage1", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(true, false, true, false, RED), BLUE, LIGHT_GREY)); + assertNodeStyle("NewEClass3", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, true, false, false, BLACK), GREY)); + + performCopy("newPackage1", DNodeContainerEditPart.class); + SWTBotUtils.waitAllUiEvents(); + performPaste("NewEClass3", DNodeEditPart.class); + SWTBotUtils.waitAllUiEvents(); + + assertContainerStyle("newPackage1", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(true, false, true, false, RED), BLUE, LIGHT_GREY)); + assertNodeStyle("NewEClass3", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, false, true, false, RED), BLUE)); + } + + public void testCopyStylishContainerToDefaultNode() { + openDiagramComplex(); + + assertContainerStyle("newPackage1", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(true, false, true, false, RED), BLUE, LIGHT_GREY)); + assertNodeStyle("NewEClass6", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(false, true, false, false, BLACK), GREY)); + + performCopy("newPackage1", DNodeContainerEditPart.class); + SWTBotUtils.waitAllUiEvents(); + performPaste("NewEClass6", DNodeEditPart.class); + SWTBotUtils.waitAllUiEvents(); + + assertContainerStyle("newPackage1", DNodeContainerEditPart.class, new ExpectedContainerStyle(new ExpectedFontStyle(true, false, true, false, RED), BLUE, LIGHT_GREY)); + assertNodeStyle("NewEClass6", DNodeEditPart.class, new ExpectedNodeStyle(new ExpectedFontStyle(true, false, true, false, RED), BLUE)); + } }