diff options
| author | Laurent Redor | 2017-09-25 09:01:13 +0000 |
|---|---|---|
| committer | Laurent Redor | 2017-09-27 12:06:32 +0000 |
| commit | 8f273830cab321d372d4e832d212b044896d8178 (patch) | |
| tree | 675f521fdaa9fb42dcb2676d0ea1eb00212b81de | |
| parent | b92f4799c7b2419652470fe643eb3a9e460a412b (diff) | |
| download | org.eclipse.sirius-8f273830cab321d372d4e832d212b044896d8178.tar.gz org.eclipse.sirius-8f273830cab321d372d4e832d212b044896d8178.tar.xz org.eclipse.sirius-8f273830cab321d372d4e832d212b044896d8178.zip | |
[522007] Show/Hide label actions disabled when Note/Text are selected
If the selection contains at least one Note or one Text, the Show/Hide
actions were not visible.
Bug: 522007
Change-Id: I1bdcd0841a1b7e5db63267723569d02a66884eb6
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
5 files changed, 53 insertions, 49 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/plugin.xml b/plugins/org.eclipse.sirius.diagram.ui/plugin.xml index c809c4aebb..97c4ece19f 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/plugin.xml +++ b/plugins/org.eclipse.sirius.diagram.ui/plugin.xml @@ -1178,14 +1178,14 @@ </propertyTester> <propertyTester id="org.eclipse.sirius.diagram.ui.HiddenLabelTester" - type="org.eclipse.sirius.diagram.ui.edit.api.part.IDiagramElementEditPart" + type="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart" namespace="org.eclipse.sirius.diagram.ui" properties="isLabelHidden" class="org.eclipse.sirius.diagram.ui.tools.internal.testers.HiddenLabelTester"> </propertyTester> <propertyTester id="org.eclipse.sirius.diagram.ui.CanHideLabelTester" - type="org.eclipse.sirius.diagram.ui.edit.api.part.IDiagramElementEditPart" + type="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart" namespace="org.eclipse.sirius.diagram.ui" properties="canHideLabel" class="org.eclipse.sirius.diagram.ui.tools.internal.testers.CanHideLabelTester"> @@ -1325,7 +1325,7 @@ variable="selection"> <iterate> <instanceof - value="org.eclipse.sirius.diagram.ui.edit.api.part.ISiriusEditPart"> + value="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart"> </instanceof> <not> <instanceof @@ -1768,23 +1768,13 @@ </definition> <definition id="isLabelHidden"> <iterate operator="or"> - <and> - <reference - definitionId="isInstanceOfIDiagramElementEditPart"> - </reference> - <test property="org.eclipse.sirius.diagram.ui.isLabelHidden" /> - </and> - </iterate> + <test property="org.eclipse.sirius.diagram.ui.isLabelHidden" /> + </iterate> </definition> <definition id="canHideLabel"> <iterate operator="or"> - <and> - <reference - definitionId="isInstanceOfIDiagramElementEditPart"> - </reference> - <test property="org.eclipse.sirius.diagram.ui.canHideLabel" /> - </and> - </iterate> + <test property="org.eclipse.sirius.diagram.ui.canHideLabel" /> + </iterate> </definition> </extension> diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/testers/CanHideLabelTester.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/testers/CanHideLabelTester.java index 98b072f817..d93eac3205 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/testers/CanHideLabelTester.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/testers/CanHideLabelTester.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 THALES GLOBAL SERVICES. + * Copyright (c) 2010, 2017 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 @@ -19,11 +19,9 @@ import org.eclipse.sirius.diagram.business.api.query.DDiagramElementQuery; import org.eclipse.sirius.diagram.ui.edit.api.part.IDiagramElementEditPart; /** - * Tester to know if all selected elements have a label that can be hide and - * that is not hidden. + * Tester to know if at least one element of the selected is kind of IDiagramElementEditPart and has a visible label. * * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> - * */ public class CanHideLabelTester extends PropertyTester { @@ -33,6 +31,7 @@ public class CanHideLabelTester extends PropertyTester { * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, * java.lang.String, java.lang.Object[], java.lang.Object) */ + @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { boolean result = false; @@ -49,7 +48,7 @@ public class CanHideLabelTester extends PropertyTester { /** * @param selectedElement * The current selection - * @return true if all selected element has label hidden. + * @return true if the selected element has a visible label. */ private boolean testDiagramElementEditPart(IDiagramElementEditPart selectedElement) { DDiagramElement diagramElement = selectedElement.resolveDiagramElement(); @@ -63,24 +62,18 @@ public class CanHideLabelTester extends PropertyTester { /** * @param selectedElements * The current selection - * @return true if all selected elements is kind of IDiagramElementEditPart - * and has label hidden. + * @return true if at least one element of the selected is kind of IDiagramElementEditPart and has a visible label . */ private boolean testStructuredSelection(IStructuredSelection selectedElements) { - boolean result = true; + boolean atLeastOneIsOK = false; final Iterator<?> iterator = selectedElements.iterator(); - if (!iterator.hasNext()) { - result = false; - } - while (iterator.hasNext()) { + while (!atLeastOneIsOK && iterator.hasNext()) { final Object next = iterator.next(); if (next instanceof IDiagramElementEditPart) { - result = result && testDiagramElementEditPart((IDiagramElementEditPart) next); - } else { - result = false; + atLeastOneIsOK = testDiagramElementEditPart((IDiagramElementEditPart) next); } } - return result; + return atLeastOneIsOK; } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/testers/HiddenLabelTester.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/testers/HiddenLabelTester.java index 1427d46289..57387f2fed 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/testers/HiddenLabelTester.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/testers/HiddenLabelTester.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 THALES GLOBAL SERVICES. + * Copyright (c) 2010, 2017 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 @@ -19,10 +19,9 @@ import org.eclipse.sirius.diagram.business.api.query.DDiagramElementQuery; import org.eclipse.sirius.diagram.ui.edit.api.part.IDiagramElementEditPart; /** - * Tester to know if all selected elements have a label that is hidden. + * Tester to know if at least one element of the selected is kind of IDiagramElementEditPart and has label hidden. * * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> - * */ public class HiddenLabelTester extends PropertyTester { @@ -32,6 +31,7 @@ public class HiddenLabelTester extends PropertyTester { * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, * java.lang.String, java.lang.Object[], java.lang.Object) */ + @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { boolean result = false; @@ -48,7 +48,7 @@ public class HiddenLabelTester extends PropertyTester { /** * @param selectedElement * The current selection - * @return true if all selected element has label hidden. + * @return true if the selected element has label hidden. */ private boolean testDiagramElementEditPart(IDiagramElementEditPart selectedElement) { DDiagramElement diagramElement = selectedElement.resolveDiagramElement(); @@ -61,24 +61,18 @@ public class HiddenLabelTester extends PropertyTester { /** * @param selectedElements * The current selection - * @return true if all selected elements is kind of IDiagramElementEditPart - * and has label hidden. + * @return true if at least one element of the selected is kind of IDiagramElementEditPart and has label hidden. */ private boolean testStructuredSelection(IStructuredSelection selectedElements) { - boolean result = true; + boolean atLeastOneIsOK = false; final Iterator<?> iterator = selectedElements.iterator(); - if (!iterator.hasNext()) { - result = false; - } - while (iterator.hasNext()) { + while (!atLeastOneIsOK && iterator.hasNext()) { final Object next = iterator.next(); if (next instanceof IDiagramElementEditPart) { - result = result && testDiagramElementEditPart((IDiagramElementEditPart) next); - } else { - result = false; + atLeastOneIsOK = testDiagramElementEditPart((IDiagramElementEditPart) next); } } - return result; + return atLeastOneIsOK; } } diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/tools/hide-reveal/tc-2330/tc2330.aird b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/tools/hide-reveal/tc-2330/tc2330.aird index fdd025a73e..d28590abe0 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/tools/hide-reveal/tc-2330/tc2330.aird +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/tools/hide-reveal/tc-2330/tc2330.aird @@ -182,6 +182,31 @@ <styles xmi:type="notation:ShapeStyle" xmi:id="_uqODwfk3Ed-olLe834UWAw" fontHeight="8"/> <layoutConstraint xmi:type="notation:Bounds" xmi:id="_uqODwvk3Ed-olLe834UWAw" x="555" y="145" width="30" height="30"/> </children> + <children xmi:type="notation:Shape" xmi:id="_2baWEKHUEee_96cZ4T3DeQ" type="Text" fontName="Comic Sans MS" description="Text"> + <children xmi:type="notation:BasicDecorationNode" xmi:id="_2bbkMKHUEee_96cZ4T3DeQ" type="DiagramName"> + <element xsi:nil="true"/> + </children> + <children xmi:type="notation:BasicDecorationNode" xmi:id="_2bbkMaHUEee_96cZ4T3DeQ" type="Description"> + <element xsi:nil="true"/> + </children> + <element xsi:nil="true"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_2baWEaHUEee_96cZ4T3DeQ" x="320" y="340"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_M4IawKHVEee_96cZ4T3DeQ" type="Note" fontName="Comic Sans MS" description="Note" fillColor="13369343" transparency="0" lineColor="6737151" lineWidth="1"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_M4IawaHVEee_96cZ4T3DeQ" source="specificStyles"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_M4IawqHVEee_96cZ4T3DeQ" key="verticalAlignment" value="8"/> + </eAnnotations> + <children xmi:type="notation:BasicDecorationNode" xmi:id="_M4JB0KHVEee_96cZ4T3DeQ" type="DiagramName"> + <element xsi:nil="true"/> + </children> + <children xmi:type="notation:BasicDecorationNode" xmi:id="_M4JB0aHVEee_96cZ4T3DeQ" type="Description"> + <element xsi:nil="true"/> + </children> + <styles xmi:type="notation:TextStyle" xmi:id="_M4Iaw6HVEee_96cZ4T3DeQ" textAlignment="Center"/> + <styles xmi:type="notation:LineTypeStyle" xmi:id="_M4IaxKHVEee_96cZ4T3DeQ"/> + <element xsi:nil="true"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_M4IaxaHVEee_96cZ4T3DeQ" x="320" y="275"/> + </children> <styles xmi:type="notation:DiagramStyle" xmi:id="_iT-ykuzQEd-T-fkKxdk2ZA"/> <edges xmi:type="notation:Edge" xmi:id="_ifv9sOzQEd-T-fkKxdk2ZA" type="4001" element="_7a-3EEg0EeCm95Tq9dtYWA" source="_icxiMOzQEd-T-fkKxdk2ZA" target="_iejq4OzQEd-T-fkKxdk2ZA"> <children xmi:type="notation:Node" xmi:id="_if5usOzQEd-T-fkKxdk2ZA" type="6001"> 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 b38fbe0e6d..bfa483559d 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 @@ -16,6 +16,8 @@ import java.util.List; import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramContainerEditPart; import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramEdgeEditPart; +import org.eclipse.sirius.diagram.ui.internal.edit.parts.SiriusNoteEditPart; +import org.eclipse.sirius.diagram.ui.internal.edit.parts.SiriusTextEditPart; import org.eclipse.sirius.tests.support.api.TestsUtil; import org.eclipse.sirius.tests.swtbot.sequence.condition.CheckTreeItemFontFormat; import org.eclipse.sirius.tests.swtbot.support.api.condition.OperationDoneCondition; @@ -322,7 +324,7 @@ public class HideRevealDiagramElementsLabelsTest extends AbstractHideRevealDiagr SWTBotGefEditPart editPart = editor.getEditPart(BORDERED_NODE_WITH_LABEL_NAME).parent(); checkLabelIsVisible(BORDERED_NODE_WITH_LABEL_NAME); if (selectInvalidElement) { - editor.select(Sets.newHashSet(editPart, getInvalidElement())); + editor.select(Sets.newHashSet(editPart, getInvalidElement(), editor.getEditPart("Text", SiriusTextEditPart.class), editor.getEditPart("Note", SiriusNoteEditPart.class))); } else { editor.select(Sets.newHashSet(editPart)); } |
