diff options
| author | Steve Monnier | 2015-02-20 17:54:33 +0000 |
|---|---|---|
| committer | Steve Monnier | 2015-03-06 11:34:25 +0000 |
| commit | 40283e68d802bcea182a3b022d66fdca596743d6 (patch) | |
| tree | 9470c226820aba7e0b82792d2cfd7d07fcca4517 | |
| parent | 91745f8dc183dd48b47775fe52bc7ad1bb17607f (diff) | |
| download | org.eclipse.sirius-40283e68d802bcea182a3b022d66fdca596743d6.tar.gz org.eclipse.sirius-40283e68d802bcea182a3b022d66fdca596743d6.tar.xz org.eclipse.sirius-40283e68d802bcea182a3b022d66fdca596743d6.zip | |
[461557] Control/Uncontrol updates input of opened controlled
representations
On control/uncontrol action, each opened editors concerning
DRepresentations that will be moved to the controlled aird, have their
input refreshed so the editor remains usable instead of read-only.
+ Addition of a new test class
ControlUncontrolWithOpenedRepresentationTest
Bug: 461557
Change-Id: Iddff479372db2e7323da28f95a0e93ff9e128c2f
Signed-off-by: Steve Monnier <steve.monnier@obeo.fr>
7 files changed, 623 insertions, 4 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java index ebc17830d0..c8f2247ba0 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java @@ -36,6 +36,7 @@ import org.eclipse.emf.common.ui.URIEditorInput; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EValidator; +import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.edit.domain.EditingDomain; import org.eclipse.emf.edit.provider.IDisposable; import org.eclipse.emf.transaction.TransactionalEditingDomain; @@ -102,6 +103,7 @@ import org.eclipse.sirius.diagram.DiagramPlugin; import org.eclipse.sirius.diagram.business.api.query.DDiagramElementQuery; import org.eclipse.sirius.diagram.business.api.refresh.CanonicalSynchronizer; import org.eclipse.sirius.diagram.business.api.refresh.CanonicalSynchronizerFactory; +import org.eclipse.sirius.diagram.business.api.refresh.DiagramCreationUtil; import org.eclipse.sirius.diagram.tools.api.command.DiagramCommandFactoryService; import org.eclipse.sirius.diagram.tools.api.command.IDiagramCommandFactory; import org.eclipse.sirius.diagram.tools.api.command.IDiagramCommandFactoryProvider; @@ -1758,13 +1760,30 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE /** * {@inheritDoc} * - * Overridden to have the title image stable during super.setInput(input) - * because the title image can change depending if the representation is - * locked (CDO). + * Overridden for two reason: <br/> + * - to update the given input in case the URI is a DDiagram instead of a + * GMF Diagram <br/> + * - to have the title image stable during super.setInput(input) because the + * title image can change depending on the representation is editable status + * (permission authority). */ @Override public void setInput(IEditorInput input) { - super.setInput(input); + // In case the input is based on the DDiagram, we need to updated it to + // use the GMF diagram + IEditorInput updatedEditorInput = input; + EObject eObject = session.getTransactionalEditingDomain().getResourceSet().getEObject(((SessionEditorInput) input).getURI(), false); + if (eObject instanceof DDiagram) { + DDiagram dDiagram = (DDiagram) eObject; + final DiagramCreationUtil util = new DiagramCreationUtil(dDiagram); + if (!util.findAssociatedGMFDiagram()) { + DiagramPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, DiagramPlugin.ID, "The gmf diagram is expected to be created before calling setInput() on the editor")); + } + final Diagram gmfDiag = util.getAssociatedGMFDiagram(); + updatedEditorInput = new SessionEditorInput(EcoreUtil.getURI(gmfDiag), dDiagram.getName(), session); + + } + super.setInput(updatedEditorInput); if (getGraphicalViewer() != null) { getGraphicalViewer().setSelection(new StructuredSelection()); } diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/control/tc460351/460351.ecore b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/control/tc460351/460351.ecore new file mode 100644 index 0000000000..f8808be461 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/control/tc460351/460351.ecore @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + name="460351"> + <eSubpackages name="p1"> + <eSubpackages name="p2"> + <eSubpackages name="p3" nsPrefix=""> + <eSubpackages name="p4"/> + </eSubpackages> + </eSubpackages> + </eSubpackages> +</ecore:EPackage> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/control/tc460351/460351.odesign b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/control/tc460351/460351.odesign new file mode 100644 index 0000000000..7b96f713e7 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/control/tc460351/460351.odesign @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:description_2="http://www.eclipse.org/sirius/table/description/1.1.0" xmlns:description_3="http://www.eclipse.org/sirius/tree/description/1.0.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" name="460351" version="8.1.0"> + <ownedViewpoints name="460351" modelFileExtension="ecore"> + <ownedRepresentations xsi:type="description_1:DiagramDescription" name="460351Diagram" domainClass="EPackage"> + <defaultLayer name="Default"> + <containerMappings name="Diagram_EPackage" semanticCandidatesExpression="[eContents(EPackage)/]" domainClass="EPackage" reusedContainerMappings="//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']/@defaultLayer/@containerMappings[name='Diagram_EPackage']"> + <style xsi:type="style:FlatContainerStyleDescription"> + <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='dark_blue']"/> + <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='dark_blue']"/> + <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/> + <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='blue']"/> + </style> + </containerMappings> + </defaultLayer> + </ownedRepresentations> + <ownedRepresentations xsi:type="description_2:EditionTableDescription" name="460351Table" domainClass="EPackage"> + <ownedLineMappings name="Table_EPackage" reusedSubLines="//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Table']/@ownedLineMappings[name='Table_EPackage']" reusedInMappings="//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Table']/@ownedLineMappings[name='Table_EPackage']" domainClass="EPackage" semanticCandidatesExpression="[eContents(EPackage)/]"/> + </ownedRepresentations> + <ownedRepresentations xsi:type="description_3:TreeDescription" name="460351Tree" domainClass="EPackage"> + <subItemMappings name="Tree_EPackage" domainClass="EPackage" semanticCandidatesExpression="[eContents(EPackage)/]" reusedTreeItemMappings="//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Tree']/@subItemMappings[name='Tree_EPackage']"> + <defaultStyle> + <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/> + </defaultStyle> + </subItemMappings> + </ownedRepresentations> + </ownedViewpoints> +</description:Group> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/control/tc460351/representations.aird b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/control/tc460351/representations.aird new file mode 100644 index 0000000000..1400be55e7 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/control/tc460351/representations.aird @@ -0,0 +1,220 @@ +<?xml version="1.0" encoding="UTF-8"?> +<viewpoint:DAnalysis xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:description_2="http://www.eclipse.org/sirius/table/description/1.1.0" xmlns:description_3="http://www.eclipse.org/sirius/tree/description/1.0.0" xmlns:diagram="http://www.eclipse.org/sirius/diagram/1.1.0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:table="http://www.eclipse.org/sirius/table/1.1.0" xmlns:tree="http://www.eclipse.org/sirius/tree/1.0.0" xmlns:viewpoint="http://www.eclipse.org/sirius/1.1.0" xsi:schemaLocation="http://www.eclipse.org/sirius/description/1.1.0 http://www.eclipse.org/sirius/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description http://www.eclipse.org/sirius/table/description/1.1.0 http://www.eclipse.org/sirius/table/1.1.0#//description http://www.eclipse.org/sirius/tree/description/1.0.0 http://www.eclipse.org/sirius/tree/1.0.0#//description http://www.eclipse.org/sirius/diagram/description/style/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description/style" xmi:id="_LM_8QLhQEeSTaN-YyUc7QQ" selectedViews="_Nz-JELhREeSTaN-YyUc7QQ" version="8.1.1"> + <models xmi:type="ecore:EPackage" href="460351.ecore#/"/> + <ownedViews xmi:type="viewpoint:DRepresentationContainer" xmi:id="_Nz-JELhREeSTaN-YyUc7QQ" initialized="true"> + <ownedRepresentations xmi:type="diagram:DSemanticDiagram" xmi:id="_xj7I8LhSEeSTaN-YyUc7QQ" name="460351Diagram1"> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_xj7I_rhSEeSTaN-YyUc7QQ" source="GMF_DIAGRAMS"> + <data xmi:type="notation:Diagram" xmi:id="_xj7I_7hSEeSTaN-YyUc7QQ" type="Sirius" element="_xj7I8LhSEeSTaN-YyUc7QQ" measurementUnit="Pixel"> + <children xmi:type="notation:Node" xmi:id="_xj7JAbhSEeSTaN-YyUc7QQ" type="2002" element="_xj7I8bhSEeSTaN-YyUc7QQ"> + <children xmi:type="notation:Node" xmi:id="_xj7JBLhSEeSTaN-YyUc7QQ" type="5006"/> + <children xmi:type="notation:Node" xmi:id="_xj7JBbhSEeSTaN-YyUc7QQ" type="7001"> + <children xmi:type="notation:Node" xmi:id="_xj7JCLhSEeSTaN-YyUc7QQ" type="3008" element="_xj7I97hSEeSTaN-YyUc7QQ"> + <children xmi:type="notation:Node" xmi:id="_xj7JC7hSEeSTaN-YyUc7QQ" type="5005"/> + <children xmi:type="notation:Node" xmi:id="_xj7JDLhSEeSTaN-YyUc7QQ" type="7002"> + <children xmi:type="notation:Node" xmi:id="_4bv8Z7hSEeSTaN-YyUc7QQ" type="3008" element="_4bp1wLhSEeSTaN-YyUc7QQ"> + <children xmi:type="notation:Node" xmi:id="_4bv8arhSEeSTaN-YyUc7QQ" type="5005"/> + <children xmi:type="notation:Node" xmi:id="_4bv8a7hSEeSTaN-YyUc7QQ" type="7002"> + <styles xmi:type="notation:SortingStyle" xmi:id="_4bv8bLhSEeSTaN-YyUc7QQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_4bv8bbhSEeSTaN-YyUc7QQ"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_4bv8aLhSEeSTaN-YyUc7QQ" fontColor="7490599" fontName="Segoe UI" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_4bv8abhSEeSTaN-YyUc7QQ" x="31" y="30"/> + </children> + <styles xmi:type="notation:SortingStyle" xmi:id="_xj7JDbhSEeSTaN-YyUc7QQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_xj7JDrhSEeSTaN-YyUc7QQ"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_xj7JCbhSEeSTaN-YyUc7QQ" fontColor="7490599" fontName="Segoe UI" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_xj7JCrhSEeSTaN-YyUc7QQ" x="31" y="30"/> + </children> + <styles xmi:type="notation:SortingStyle" xmi:id="_xj7JBrhSEeSTaN-YyUc7QQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_xj7JB7hSEeSTaN-YyUc7QQ"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_xj7JArhSEeSTaN-YyUc7QQ" fontColor="7490599" fontName="Segoe UI" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_xj7JA7hSEeSTaN-YyUc7QQ"/> + </children> + <styles xmi:type="notation:DiagramStyle" xmi:id="_xj7JALhSEeSTaN-YyUc7QQ"/> + </data> + </ownedAnnotationEntries> + <ownedDiagramElements xmi:type="diagram:DNodeContainer" xmi:id="_xj7I8bhSEeSTaN-YyUc7QQ" name="p2"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2"/> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2"/> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_xj7I8rhSEeSTaN-YyUc7QQ"> + <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_xj7I87hSEeSTaN-YyUc7QQ" red="39" green="76" blue="114"/> + <description xmi:type="style:FlatContainerStyleDescription" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']/@defaultLayer/@containerMappings[name='Diagram_EPackage']/@style"/> + <borderColor xmi:type="viewpoint:RGBValues" xmi:id="_xj7I9LhSEeSTaN-YyUc7QQ" red="39" green="76" blue="114"/> + <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_xj7I9bhSEeSTaN-YyUc7QQ" red="255" green="255" blue="255"/> + <foregroundColor xmi:type="viewpoint:RGBValues" xmi:id="_xj7I9rhSEeSTaN-YyUc7QQ" red="114" green="159" blue="207"/> + </ownedStyle> + <actualMapping xmi:type="description_1:ContainerMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']/@defaultLayer/@containerMappings[name='Diagram_EPackage']"/> + <ownedDiagramElements xmi:type="diagram:DNodeContainer" xmi:id="_xj7I97hSEeSTaN-YyUc7QQ" name="p3"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3"/> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3"/> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_xj7I-LhSEeSTaN-YyUc7QQ"> + <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_xj7I-bhSEeSTaN-YyUc7QQ" red="39" green="76" blue="114"/> + <description xmi:type="style:FlatContainerStyleDescription" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']/@defaultLayer/@containerMappings[name='Diagram_EPackage']/@style"/> + <borderColor xmi:type="viewpoint:RGBValues" xmi:id="_xj7I-rhSEeSTaN-YyUc7QQ" red="39" green="76" blue="114"/> + <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_xj7I-7hSEeSTaN-YyUc7QQ" red="255" green="255" blue="255"/> + <foregroundColor xmi:type="viewpoint:RGBValues" xmi:id="_xj7I_LhSEeSTaN-YyUc7QQ" red="114" green="159" blue="207"/> + </ownedStyle> + <actualMapping xmi:type="description_1:ContainerMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']/@defaultLayer/@containerMappings[name='Diagram_EPackage']"/> + <ownedDiagramElements xmi:type="diagram:DNodeContainer" xmi:id="_4bp1wLhSEeSTaN-YyUc7QQ" name="p4"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3/p4"/> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3/p4"/> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_4bp1wbhSEeSTaN-YyUc7QQ"> + <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_4bp1wrhSEeSTaN-YyUc7QQ" red="39" green="76" blue="114"/> + <description xmi:type="style:FlatContainerStyleDescription" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']/@defaultLayer/@containerMappings[name='Diagram_EPackage']/@style"/> + <borderColor xmi:type="viewpoint:RGBValues" xmi:id="_4bp1w7hSEeSTaN-YyUc7QQ" red="39" green="76" blue="114"/> + <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_4bp1xLhSEeSTaN-YyUc7QQ" red="255" green="255" blue="255"/> + <foregroundColor xmi:type="viewpoint:RGBValues" xmi:id="_4bp1xbhSEeSTaN-YyUc7QQ" red="114" green="159" blue="207"/> + </ownedStyle> + <actualMapping xmi:type="description_1:ContainerMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']/@defaultLayer/@containerMappings[name='Diagram_EPackage']"/> + </ownedDiagramElements> + </ownedDiagramElements> + </ownedDiagramElements> + <description xmi:type="description_1:DiagramDescription" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']"/> + <filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="_xj7I_bhSEeSTaN-YyUc7QQ"/> + <activatedLayers xmi:type="description_1:Layer" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']/@defaultLayer"/> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1"/> + </ownedRepresentations> + <ownedRepresentations xmi:type="diagram:DSemanticDiagram" xmi:id="_01fnYLhSEeSTaN-YyUc7QQ" name="460351Diagram2"> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_01fnaLhSEeSTaN-YyUc7QQ" source="GMF_DIAGRAMS"> + <data xmi:type="notation:Diagram" xmi:id="_01fnabhSEeSTaN-YyUc7QQ" type="Sirius" element="_01fnYLhSEeSTaN-YyUc7QQ" measurementUnit="Pixel"> + <children xmi:type="notation:Node" xmi:id="_01fna7hSEeSTaN-YyUc7QQ" type="2002" element="_01fnYbhSEeSTaN-YyUc7QQ"> + <children xmi:type="notation:Node" xmi:id="_01fnbrhSEeSTaN-YyUc7QQ" type="5006"/> + <children xmi:type="notation:Node" xmi:id="_01fnb7hSEeSTaN-YyUc7QQ" type="7001"> + <children xmi:type="notation:Node" xmi:id="_4bv8brhSEeSTaN-YyUc7QQ" type="3008" element="_4bv8YLhSEeSTaN-YyUc7QQ"> + <children xmi:type="notation:Node" xmi:id="_4bv8cbhSEeSTaN-YyUc7QQ" type="5005"/> + <children xmi:type="notation:Node" xmi:id="_4bv8crhSEeSTaN-YyUc7QQ" type="7002"> + <styles xmi:type="notation:SortingStyle" xmi:id="_4bv8c7hSEeSTaN-YyUc7QQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_4bv8dLhSEeSTaN-YyUc7QQ"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_4bv8b7hSEeSTaN-YyUc7QQ" fontColor="7490599" fontName="Segoe UI" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_4bv8cLhSEeSTaN-YyUc7QQ" x="31" y="30"/> + </children> + <styles xmi:type="notation:SortingStyle" xmi:id="_01fncLhSEeSTaN-YyUc7QQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_01fncbhSEeSTaN-YyUc7QQ"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_01fnbLhSEeSTaN-YyUc7QQ" fontColor="7490599" fontName="Segoe UI" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_01fnbbhSEeSTaN-YyUc7QQ"/> + </children> + <styles xmi:type="notation:DiagramStyle" xmi:id="_01fnarhSEeSTaN-YyUc7QQ"/> + </data> + </ownedAnnotationEntries> + <ownedDiagramElements xmi:type="diagram:DNodeContainer" xmi:id="_01fnYbhSEeSTaN-YyUc7QQ" name="p3"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3"/> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3"/> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_01fnYrhSEeSTaN-YyUc7QQ"> + <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_01fnY7hSEeSTaN-YyUc7QQ" red="39" green="76" blue="114"/> + <description xmi:type="style:FlatContainerStyleDescription" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']/@defaultLayer/@containerMappings[name='Diagram_EPackage']/@style"/> + <borderColor xmi:type="viewpoint:RGBValues" xmi:id="_01fnZLhSEeSTaN-YyUc7QQ" red="39" green="76" blue="114"/> + <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_01fnZbhSEeSTaN-YyUc7QQ" red="255" green="255" blue="255"/> + <foregroundColor xmi:type="viewpoint:RGBValues" xmi:id="_01fnZrhSEeSTaN-YyUc7QQ" red="114" green="159" blue="207"/> + </ownedStyle> + <actualMapping xmi:type="description_1:ContainerMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']/@defaultLayer/@containerMappings[name='Diagram_EPackage']"/> + <ownedDiagramElements xmi:type="diagram:DNodeContainer" xmi:id="_4bv8YLhSEeSTaN-YyUc7QQ" name="p4"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3/p4"/> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3/p4"/> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_4bv8YbhSEeSTaN-YyUc7QQ"> + <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_4bv8YrhSEeSTaN-YyUc7QQ" red="39" green="76" blue="114"/> + <description xmi:type="style:FlatContainerStyleDescription" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']/@defaultLayer/@containerMappings[name='Diagram_EPackage']/@style"/> + <borderColor xmi:type="viewpoint:RGBValues" xmi:id="_4bv8Y7hSEeSTaN-YyUc7QQ" red="39" green="76" blue="114"/> + <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_4bv8ZLhSEeSTaN-YyUc7QQ" red="255" green="255" blue="255"/> + <foregroundColor xmi:type="viewpoint:RGBValues" xmi:id="_4bv8ZbhSEeSTaN-YyUc7QQ" red="114" green="159" blue="207"/> + </ownedStyle> + <actualMapping xmi:type="description_1:ContainerMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']/@defaultLayer/@containerMappings[name='Diagram_EPackage']"/> + </ownedDiagramElements> + </ownedDiagramElements> + <description xmi:type="description_1:DiagramDescription" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']"/> + <filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="_01fnZ7hSEeSTaN-YyUc7QQ"/> + <activatedLayers xmi:type="description_1:Layer" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Diagram']/@defaultLayer"/> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2"/> + </ownedRepresentations> + <ownedRepresentations xmi:type="table:DTable" xmi:id="_2PTS8LhSEeSTaN-YyUc7QQ" name="460351Table1" headerColumnWidth="112"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1"/> + <lines xmi:type="table:DLine" xmi:id="_2PTS8bhSEeSTaN-YyUc7QQ" label="p2"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2"/> + <lines xmi:type="table:DLine" xmi:id="_2PTS8rhSEeSTaN-YyUc7QQ" label="p3"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3"/> + <lines xmi:type="table:DLine" xmi:id="_4bv8ZrhSEeSTaN-YyUc7QQ" label="p4"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3/p4"/> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3/p4"/> + <originMapping xmi:type="description_2:LineMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Table']/@ownedLineMappings[name='Table_EPackage']"/> + </lines> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3"/> + <originMapping xmi:type="description_2:LineMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Table']/@ownedLineMappings[name='Table_EPackage']"/> + </lines> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2"/> + <originMapping xmi:type="description_2:LineMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Table']/@ownedLineMappings[name='Table_EPackage']"/> + </lines> + <description xmi:type="description_2:EditionTableDescription" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Table']"/> + </ownedRepresentations> + <ownedRepresentations xmi:type="table:DTable" xmi:id="_7ewaYLhSEeSTaN-YyUc7QQ" name="460351Table2" headerColumnWidth="81"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2"/> + <lines xmi:type="table:DLine" xmi:id="_7ewaYbhSEeSTaN-YyUc7QQ" label="p3"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3"/> + <lines xmi:type="table:DLine" xmi:id="_7ewaYrhSEeSTaN-YyUc7QQ" label="p4"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3/p4"/> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3/p4"/> + <originMapping xmi:type="description_2:LineMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Table']/@ownedLineMappings[name='Table_EPackage']"/> + </lines> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3"/> + <originMapping xmi:type="description_2:LineMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Table']/@ownedLineMappings[name='Table_EPackage']"/> + </lines> + <description xmi:type="description_2:EditionTableDescription" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Table']"/> + </ownedRepresentations> + <ownedRepresentations xmi:type="tree:DTree" xmi:id="_81MB0LhSEeSTaN-YyUc7QQ" name="460351Tree1"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1"/> + <ownedTreeItems xmi:type="tree:DTreeItem" xmi:id="_81MB0bhSEeSTaN-YyUc7QQ" name="p2" expanded="true"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2"/> + <ownedTreeItems xmi:type="tree:DTreeItem" xmi:id="_81MB0rhSEeSTaN-YyUc7QQ" name="p3" expanded="true"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3"/> + <ownedTreeItems xmi:type="tree:DTreeItem" xmi:id="_9QhS8LhSEeSTaN-YyUc7QQ" name="p4"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3/p4"/> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3/p4"/> + <ownedStyle xmi:type="tree:TreeItemStyle" xmi:id="_9QhS8bhSEeSTaN-YyUc7QQ"> + <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_9bB50bhSEeSTaN-YyUc7QQ"/> + <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_9bB50LhSEeSTaN-YyUc7QQ" red="255" green="255" blue="255"/> + </ownedStyle> + <actualMapping xmi:type="description_3:TreeItemMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Tree']/@subItemMappings[name='Tree_EPackage']"/> + </ownedTreeItems> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3"/> + <ownedStyle xmi:type="tree:TreeItemStyle" xmi:id="_81MB07hSEeSTaN-YyUc7QQ"> + <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_9QhS9bhSEeSTaN-YyUc7QQ"/> + <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_9QhS9LhSEeSTaN-YyUc7QQ" red="255" green="255" blue="255"/> + </ownedStyle> + <actualMapping xmi:type="description_3:TreeItemMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Tree']/@subItemMappings[name='Tree_EPackage']"/> + </ownedTreeItems> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2"/> + <ownedStyle xmi:type="tree:TreeItemStyle" xmi:id="_81MB1rhSEeSTaN-YyUc7QQ"> + <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_81MB17hSEeSTaN-YyUc7QQ"/> + <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_81MB2LhSEeSTaN-YyUc7QQ" red="255" green="255" blue="255"/> + </ownedStyle> + <actualMapping xmi:type="description_3:TreeItemMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Tree']/@subItemMappings[name='Tree_EPackage']"/> + </ownedTreeItems> + <description xmi:type="description_3:TreeDescription" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Tree']"/> + </ownedRepresentations> + <ownedRepresentations xmi:type="tree:DTree" xmi:id="_-0HMoLhSEeSTaN-YyUc7QQ" name="460351Tree2"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2"/> + <ownedTreeItems xmi:type="tree:DTreeItem" xmi:id="_-0HMobhSEeSTaN-YyUc7QQ" name="p3" expanded="true"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3"/> + <ownedTreeItems xmi:type="tree:DTreeItem" xmi:id="_-0HMorhSEeSTaN-YyUc7QQ" name="p4"> + <target xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3/p4"/> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3/p4"/> + <ownedStyle xmi:type="tree:TreeItemStyle" xmi:id="_-0HMo7hSEeSTaN-YyUc7QQ"> + <labelColor xmi:type="viewpoint:RGBValues" xmi:id="__IorIbhSEeSTaN-YyUc7QQ"/> + <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="__IorILhSEeSTaN-YyUc7QQ" red="255" green="255" blue="255"/> + </ownedStyle> + <actualMapping xmi:type="description_3:TreeItemMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Tree']/@subItemMappings[name='Tree_EPackage']"/> + </ownedTreeItems> + <semanticElements xmi:type="ecore:EPackage" href="460351.ecore#//p1/p2/p3"/> + <ownedStyle xmi:type="tree:TreeItemStyle" xmi:id="_-0HMprhSEeSTaN-YyUc7QQ"> + <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_-0HMp7hSEeSTaN-YyUc7QQ"/> + <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_-0HMqLhSEeSTaN-YyUc7QQ" red="255" green="255" blue="255"/> + </ownedStyle> + <actualMapping xmi:type="description_3:TreeItemMapping" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Tree']/@subItemMappings[name='Tree_EPackage']"/> + </ownedTreeItems> + <description xmi:type="description_3:TreeDescription" href="460351.odesign#//@ownedViewpoints[name='460351']/@ownedRepresentations[name='460351Tree']"/> + </ownedRepresentations> + <viewpoint xmi:type="description:Viewpoint" href="460351.odesign#//@ownedViewpoints[name='460351']"/> + </ownedViews> +</viewpoint:DAnalysis> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/ControlUncontrolWithOpenedRepresentationTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/ControlUncontrolWithOpenedRepresentationTest.java new file mode 100644 index 0000000000..6370cef0d3 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/ControlUncontrolWithOpenedRepresentationTest.java @@ -0,0 +1,302 @@ +/******************************************************************************* + * 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.tests.swtbot; + +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.sirius.business.api.session.SessionStatus; +import org.eclipse.sirius.diagram.DDiagram; +import org.eclipse.sirius.table.metamodel.table.DLine; +import org.eclipse.sirius.table.metamodel.table.DTable; +import org.eclipse.sirius.table.ui.tools.api.editor.DTableEditor; +import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase; +import org.eclipse.sirius.tests.swtbot.support.api.business.UILocalSession; +import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource; +import org.eclipse.sirius.tests.swtbot.support.api.condition.CheckEditPartMoved; +import org.eclipse.sirius.tests.swtbot.support.api.condition.ItemEnabledCondition; +import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor; +import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils; +import org.eclipse.sirius.tests.swtbot.support.utils.tree.TreeUtils; +import org.eclipse.sirius.tree.DTree; +import org.eclipse.sirius.tree.DTreeItem; +import org.eclipse.sirius.tree.ui.tools.api.editor.DTreeEditor; +import org.eclipse.swtbot.eclipse.finder.waits.Conditions; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; +import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.junit.Assert; + +/** + * All tests for control/uncontrol + * + * @author <a href="steve.monnier@obeo.fr">Steve Monnier</a> + */ +public class ControlUncontrolWithOpenedRepresentationTest extends AbstractSiriusSwtBotGefTestCase { + + private static final String CONTROL_SHELL_NAME = "Control"; + + private static final String MODEL = "460351.ecore"; + + private static final String SESSION_FILE = "representations.aird"; + + private static final String VSM_FILE = "460351.odesign"; + + private static final String DATA_UNIT_DIR = "data/unit/control/tc460351/"; + + private static final String FILE_DIR = "/"; + + private UIResource sessionAirdResource; + + private UILocalSession localSession; + + /** + * {@inheritDoc} + */ + @Override + protected void onSetUpBeforeClosingWelcomePage() throws Exception { + copyFileToTestProject(Activator.PLUGIN_ID, DATA_UNIT_DIR, MODEL, SESSION_FILE, VSM_FILE); + } + + /** + * {@inheritDoc} + */ + @Override + protected void onSetUpAfterOpeningDesignerPerspective() throws Exception { + sessionAirdResource = new UIResource(designerProject, FILE_DIR, SESSION_FILE); + localSession = designerPerspective.openSessionFromFile(sessionAirdResource); + designerProject.convertToModelingProject(); + } + + /** + * Open a diagram located under a semantic element to control. Once + * controlled, we validate that the diagram is still editable. Next the + * semantic element is uncontrolled and we validate again that the diagram + * is still editable. + * + * @throws Exception + * Test error. + */ + public void testCheckOpenedDiagramBehaviourOnControlUncontrol() throws Exception { + processCheckOpenedDiagramBehaviourOnControlUncontrol("460351Diagram1", "p2"); + } + + /** + * Open a diagram located under a sub element of a semantic element to + * control. Once controlled, we validate that the diagram is still editable. + * Next the semantic element is uncontrolled and we validate again that the + * diagram is still editable. + * + * @throws Exception + * Test error. + */ + public void testCheckOpenedSubDiagramBehaviourOnControlUncontrol() throws Exception { + processCheckOpenedDiagramBehaviourOnControlUncontrol("460351Diagram2", "p3"); + } + + /** + * Open a table located under a semantic element to control. Once + * controlled, we validate that the table is still editable. Next the + * semantic element is uncontrolled and we validate again that the table is + * still editable. + * + * @throws Exception + * Test error. + */ + public void testCheckOpenedTableBehaviourOnControlUncontrol() throws Exception { + processCheckOpenedTableBehaviourOnControlUncontrol("460351Table1"); + } + + /** + * Open a table located under a sub element of a semantic element to + * control. Once controlled, we validate that the table is still editable. + * Next the semantic element is uncontrolled and we validate again that the + * table is still editable. + * + * @throws Exception + * Test error. + */ + public void testCheckOpenedSubTableBehaviourOnControlUncontrol() throws Exception { + processCheckOpenedTableBehaviourOnControlUncontrol("460351Table2"); + } + + /** + * Open a tree located under a semantic element to control. Once controlled, + * we validate that the tree is still editable. Next the semantic element is + * uncontrolled and we validate again that the tree is still editable. + * + * @throws Exception + * Test error. + */ + public void testCheckOpenedTreeBehaviourOnControlUncontrol() throws Exception { + processCheckOpenedTreeBehaviourOnControlUncontrol("460351Tree1"); + } + + /** + * Open a tree located under a sub element of a semantic element to control. + * Once controlled, we validate that the tree is still editable. Next the + * semantic element is uncontrolled and we validate again that the tree is + * still editable. + * + * @throws Exception + * Test error. + */ + public void testCheckOpenedSubTreeBehaviourOnControlUncontrol() throws Exception { + processCheckOpenedTreeBehaviourOnControlUncontrol("460351Tree2"); + } + + private void processCheckOpenedDiagramBehaviourOnControlUncontrol(String diagramName, String packageName) { + final SWTBotSiriusDiagramEditor editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), "460351Diagram", diagramName, DDiagram.class); + + SWTBotTreeItem packageNodeToControl = localSession.getRootSessionTreeItem().expandNode(MODEL).expandNode("460351").expandNode("p1").select(); + + // Execute control + SWTBotUtils.clickContextMenu(packageNodeToControl, "Control..."); + checkDiagramIsEditable(editor, true, packageName); + + // Save session to be sync again + localSession.getOpenedSession().save(new NullProgressMonitor()); + + // Execute uncontrol + packageNodeToControl = localSession.getRootSessionTreeItem().expandNode(MODEL).expandNode("460351").expandNode("p1").select(); + SWTBotUtils.clickContextMenu(packageNodeToControl, "Uncontrol"); + checkDiagramIsEditable(editor, false, packageName); + + // Save session to be sync again + localSession.getOpenedSession().save(new NullProgressMonitor()); + } + + private void processCheckOpenedTableBehaviourOnControlUncontrol(String tableName) { + final SWTBotEditor tableEditorBot = openRepresentation(localSession.getOpenedSession(), "460351Table", tableName, DTable.class); + + SWTBotTreeItem packageNodeToControl = localSession.getRootSessionTreeItem().expandNode(MODEL).expandNode("460351").expandNode("p1").select(); + + // Execute control + SWTBotUtils.clickContextMenu(packageNodeToControl, "Control..."); + checkTableIsEditable(tableEditorBot, true); + + // Save session to be sync again + localSession.getOpenedSession().save(new NullProgressMonitor()); + + // Execute uncontrol + packageNodeToControl = localSession.getRootSessionTreeItem().expandNode(MODEL).expandNode("460351").expandNode("p1").select(); + SWTBotUtils.clickContextMenu(packageNodeToControl, "Uncontrol"); + checkTableIsEditable(tableEditorBot, false); + + // Save session to be sync again + localSession.getOpenedSession().save(new NullProgressMonitor()); + } + + private void processCheckOpenedTreeBehaviourOnControlUncontrol(String treeName) { + final SWTBotEditor treeEditorBot = openRepresentation(localSession.getOpenedSession(), "460351Tree", treeName, DTree.class); + + SWTBotTreeItem packageNodeToControl = localSession.getRootSessionTreeItem().expandNode(MODEL).expandNode("460351").expandNode("p1").select(); + + // Execute control + SWTBotUtils.clickContextMenu(packageNodeToControl, "Control..."); + checkTreeIsEditable(treeEditorBot, true); + + // Save session to be sync again + localSession.getOpenedSession().save(new NullProgressMonitor()); + + // Execute uncontrol + packageNodeToControl = localSession.getRootSessionTreeItem().expandNode(MODEL).expandNode("460351").expandNode("p1").select(); + SWTBotUtils.clickContextMenu(packageNodeToControl, "Uncontrol"); + checkTreeIsEditable(treeEditorBot, false); + + // Save session to be sync again + localSession.getOpenedSession().save(new NullProgressMonitor()); + } + + private void checkDiagramIsEditable(final SWTBotSiriusDiagramEditor editor, boolean isControlling, String elementToMoveName) { + executeControlUncontrol(isControlling); + + // Move an element to validate that the diagram is not read only + SWTBotGefEditPart elementToMove = editor.getEditPart(elementToMoveName); + Point modifiedLocation = editor.getBounds(elementToMove).getTranslated(50, 50).getLocation(); + CheckEditPartMoved checkEditPartMoved = new CheckEditPartMoved(elementToMove); + editor.drag(elementToMove, modifiedLocation.x, modifiedLocation.y); + bot.waitUntil(checkEditPartMoved); + + elementToMove = editor.getEditPart(elementToMoveName); + Point newLocation = editor.getBounds(elementToMove).getLocation(); + + // Validation that the session is dirty and the element has been moved + Assert.assertEquals("The session is expected to be dirty", SessionStatus.DIRTY, localSession.getOpenedSession().getStatus()); + // There is a strange delta but this is irrelevant to the current test, + // we just need to validate that the diagram can be edited + Assert.assertEquals(elementToMoveName + " is not at the expected horizontal position", modifiedLocation.x, newLocation.x, 2); + Assert.assertEquals(elementToMoveName + " is not at the expected vertical position", modifiedLocation.y, newLocation.y, 2); + } + + private void checkTableIsEditable(final SWTBotEditor tableEditorBot, boolean isControlling) { + executeControlUncontrol(isControlling); + + DTableEditor dTableEditor = (DTableEditor) tableEditorBot.getReference().getEditor(false); + DTable dTable = (DTable) dTableEditor.getRepresentation(); + + DLine firstDLine = dTable.getLines().get(0); + if (isControlling) { + TreeUtils.collapseTreeItem(tableEditorBot, firstDLine); + } else { + TreeUtils.expandTreeItem(tableEditorBot, firstDLine); + } + + // Validation that the session is dirty and the element has been moved + Assert.assertEquals("The session is expected to be dirty", SessionStatus.DIRTY, localSession.getOpenedSession().getStatus()); + } + + private void checkTreeIsEditable(final SWTBotEditor treeEditorBot, boolean isControlling) { + executeControlUncontrol(isControlling); + + DTreeEditor dTreeEditor = (DTreeEditor) treeEditorBot.getReference().getEditor(false); + DTree dTree = (DTree) dTreeEditor.getRepresentation(); + + DTreeItem firstTreeItem = dTree.getOwnedTreeItems().get(0); + if (isControlling) { + TreeUtils.collapseTreeItem(treeEditorBot, firstTreeItem); + } else { + TreeUtils.expandTreeItem(treeEditorBot, firstTreeItem); + } + + // Validation that the session is dirty and the element has been moved + Assert.assertEquals("The session is expected to be dirty", SessionStatus.DIRTY, localSession.getOpenedSession().getStatus()); + } + + private void executeControlUncontrol(boolean isControlling) { + if (isControlling) { + bot.waitUntilWidgetAppears(Conditions.shellIsActive(CONTROL_SHELL_NAME)); + final SWTBotShell controlShell = bot.shell(CONTROL_SHELL_NAME); + controlShell.activate(); + + final SWTBotButton ok = bot.button("OK"); + bot.waitUntilWidgetAppears(new ItemEnabledCondition(ok)); + ok.click(); + + bot.waitUntilWidgetAppears(Conditions.shellIsActive("Wizard of representations selection")); + final SWTBotShell wizardShell = bot.shell("Wizard of representations selection"); + wizardShell.activate(); + + final SWTBotButton finish = bot.button("Finish"); + bot.waitUntilWidgetAppears(new ItemEnabledCondition(finish)); + finish.click(); + } else { + bot.waitUntilWidgetAppears(Conditions.shellIsActive("Uncontrol representations?")); + final SWTBotShell wizardShell = bot.shell("Uncontrol representations?"); + wizardShell.activate(); + + final SWTBotButton yes = bot.button("Yes"); + bot.waitUntilWidgetAppears(new ItemEnabledCondition(yes)); + yes.click(); + } + } +} diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/control/SiriusControlHandler.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/control/SiriusControlHandler.java index b3d138aa8d..f3aa2f7fe2 100644 --- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/control/SiriusControlHandler.java +++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/control/SiriusControlHandler.java @@ -43,6 +43,10 @@ import org.eclipse.sirius.business.api.dialect.DialectManager; import org.eclipse.sirius.business.api.helper.SiriusUtil; import org.eclipse.sirius.business.api.session.Session; import org.eclipse.sirius.business.api.session.SessionManager; +import org.eclipse.sirius.ui.business.api.dialect.DialectEditor; +import org.eclipse.sirius.ui.business.api.session.IEditingSession; +import org.eclipse.sirius.ui.business.api.session.SessionEditorInput; +import org.eclipse.sirius.ui.business.api.session.SessionUIManager; import org.eclipse.sirius.ui.tools.internal.util.EMFCoreUtil; import org.eclipse.sirius.ui.tools.internal.wizards.SelectRepresentationsWizard; import org.eclipse.sirius.viewpoint.DRepresentation; @@ -51,6 +55,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IReusableEditor; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.eclipse.ui.handlers.HandlerUtil; @@ -121,6 +126,19 @@ public class SiriusControlHandler extends AbstractHandler { Command vcc = new SiriusControlCommand(semanticRoot, semanticDest, representations, representationDest, false, new SubProgressMonitor(monitor, 1)); TransactionUtil.getEditingDomain(semanticRoot).getCommandStack().execute(vcc); session.save(new SubProgressMonitor(monitor, 1)); + + // Opened editors of uncontrolled representations need an + // update of the editor input with the new DRepresentation + // location + IEditingSession uiSession = SessionUIManager.INSTANCE.getUISession(session); + for (DRepresentation dRepresentation : representations) { + DialectEditor editor = uiSession.getEditor(dRepresentation); + if (editor instanceof IReusableEditor) { + IReusableEditor iReusableEditor = (IReusableEditor) editor; + SessionEditorInput updatedEditorInput = new SessionEditorInput(EcoreUtil.getURI(dRepresentation), dRepresentation.getName(), session); + iReusableEditor.setInput(updatedEditorInput); + } + } } catch (InterruptedException e) { // cancel done : no command to execute } diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/control/SiriusUncontrolHandler.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/control/SiriusUncontrolHandler.java index 45b363deb8..1d6a9c4aee 100644 --- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/control/SiriusUncontrolHandler.java +++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/control/SiriusUncontrolHandler.java @@ -22,6 +22,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.emf.common.command.Command; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.transaction.util.TransactionUtil; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; @@ -30,8 +31,14 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.sirius.business.api.control.SiriusUncontrolCommand; import org.eclipse.sirius.business.api.session.Session; import org.eclipse.sirius.business.api.session.SessionManager; +import org.eclipse.sirius.ui.business.api.dialect.DialectEditor; +import org.eclipse.sirius.ui.business.api.session.IEditingSession; +import org.eclipse.sirius.ui.business.api.session.SessionEditorInput; +import org.eclipse.sirius.ui.business.api.session.SessionUIManager; +import org.eclipse.sirius.viewpoint.DRepresentation; import org.eclipse.sirius.viewpoint.provider.SiriusEditPlugin; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IReusableEditor; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.eclipse.ui.handlers.HandlerUtil; @@ -93,6 +100,20 @@ public class SiriusUncontrolHandler extends AbstractHandler { Command vuc = new SiriusUncontrolCommand(semanticRoot, uncontrolRepresentations, false, new SubProgressMonitor(monitor, 1)); TransactionUtil.getEditingDomain(semanticRoot).getCommandStack().execute(vuc); session.save(new SubProgressMonitor(monitor, 1)); + + // Opened editors of uncontrolled representations need an update of + // the editor input with the new DRepresentation location + if (uncontrolRepresentations) { + IEditingSession uiSession = SessionUIManager.INSTANCE.getUISession(session); + for (DialectEditor dialectEditor : uiSession.getEditors()) { + if (dialectEditor instanceof IReusableEditor) { + IReusableEditor iReusableEditor = (IReusableEditor) dialectEditor; + DRepresentation representation = dialectEditor.getRepresentation(); + SessionEditorInput updatedEditorInput = new SessionEditorInput(EcoreUtil.getURI(representation), representation.getName(), session); + iReusableEditor.setInput(updatedEditorInput); + } + } + } } } |
