diff options
| author | Steve Monnier | 2015-03-17 17:26:28 +0000 |
|---|---|---|
| committer | Steve Monnier | 2015-03-30 15:08:55 +0000 |
| commit | 0b10df793d2eb41ae2b61a2d44d5a9500c2b28d6 (patch) | |
| tree | 3af4eeae87715de3cbba87e67ea73f088354dff1 | |
| parent | a79e30ca75dba8aee052f5c2e45170ca443d6d1a (diff) | |
| download | org.eclipse.sirius-0b10df793d2eb41ae2b61a2d44d5a9500c2b28d6.tar.gz org.eclipse.sirius-0b10df793d2eb41ae2b61a2d44d5a9500c2b28d6.tar.xz org.eclipse.sirius-0b10df793d2eb41ae2b61a2d44d5a9500c2b28d6.zip | |
[462538] Allow (un)control on semantic models other than the first
Fix analysis and aird resource are processed during control and
uncontrol to allow these function on other semantic models than the
first one.
Bug: 462538
Change-Id: I36ebbf3c008c8d3913a57e47fb40a65056c6f280
Signed-off-by: Steve Monnier <steve.monnier@obeo.fr>
9 files changed, 200 insertions, 7 deletions
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html index 4e89b5a94a..e13514d989 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html @@ -142,7 +142,9 @@ </li> <li>There is a new capability on Dialect. This capability is to refresh only impacted elements concerned by a list of notifications. It is used, for example, to refresh the opened representations when the user chooses manual refresh mode. Each dialect that want to offer this capability must implement <code>org.eclipse.sirius.business.api.dialect.DialectServices.refreshImpactedElements(DRepresentation, Collection<Notification>, IProgressMonitor)</code>. A default implementation that does nothing is done in - <code>org.eclipse.sirius.business.api.dialect.AbstractRepresentationDialectServices</code>. + <code>org.eclipse.sirius.business.api.dialect.AbstractRepresentationDialectServices</code>.* A new method has been added in the query + <code>org.eclipse.sirius.business.api.query.DAnalysisQuery</code> named + <code>getMainModels()</code>. This method returns a Set of the main model and the other non controlled models. </li> </ul> <h4 id="Changesinorg.eclipse.sirius.ui">Changes in diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile index 36f49a487a..54ca191e73 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile @@ -40,7 +40,8 @@ h4. Changes in @org.eclipse.sirius@ ** The boolean value @removeFromControlledResources@ has been removed because controlled resources are managed internally. * The boolean value @removeReferencingResources@ has been added in @org.eclipse.sirius.business.api.session.Session.removeSemanticResource@ method to indicate if the referencing resources are also to remove. * The query @org.eclipse.sirius.business.api.query.EObjectQuery@ has now a new constructor with an additional parameter, ECrossReferenceAdapter. This can be usefull if there is many calls to inverse references methods for the same Session. This avoids to get the semantic cross referencer from the EObject each time. This query also proposes a new method @getInverseReferences(Set<EReference>)@. -* There is a new capability on Dialect. This capability is to refresh only impacted elements concerned by a list of notifications. It is used, for example, to refresh the opened representations when the user chooses manual refresh mode. Each dialect that want to offer this capability must implement @org.eclipse.sirius.business.api.dialect.DialectServices.refreshImpactedElements(DRepresentation, Collection<Notification>, IProgressMonitor)@. A default implementation that does nothing is done in @org.eclipse.sirius.business.api.dialect.AbstractRepresentationDialectServices@. +* There is a new capability on Dialect. This capability is to refresh only impacted elements concerned by a list of notifications. It is used, for example, to refresh the opened representations when the user chooses manual refresh mode. Each dialect that want to offer this capability must implement @org.eclipse.sirius.business.api.dialect.DialectServices.refreshImpactedElements(DRepresentation, Collection<Notification>, IProgressMonitor)@. A default implementation that does nothing is done in @org.eclipse.sirius.business.api.dialect.AbstractRepresentationDialectServices@.* A new method has been added in the query @org.eclipse.sirius.business.api.query.DAnalysisQuery@ named @getMainModels()@. This method returns a Set of the main model and the other non controlled models. + h4. Changes in @org.eclipse.sirius.ui@ diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/control/448373/448373.ecore b/plugins/org.eclipse.sirius.tests.junit/data/unit/control/448373/448373.ecore new file mode 100644 index 0000000000..435c35d1b3 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/control/448373/448373.ecore @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="p0"> + <eSubpackages name="p1"> + <eClassifiers xsi:type="ecore:EClass" name="c1"/> + </eSubpackages> +</ecore:EPackage> diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/control/448373/448373b.ecore b/plugins/org.eclipse.sirius.tests.junit/data/unit/control/448373/448373b.ecore new file mode 100644 index 0000000000..435c35d1b3 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/control/448373/448373b.ecore @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="p0"> + <eSubpackages name="p1"> + <eClassifiers xsi:type="ecore:EClass" name="c1"/> + </eSubpackages> +</ecore:EPackage> diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/control/448373/representations.aird b/plugins/org.eclipse.sirius.tests.junit/data/unit/control/448373/representations.aird new file mode 100644 index 0000000000..bd477ef285 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/control/448373/representations.aird @@ -0,0 +1,65 @@ +<?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: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: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/diagram/description/style/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description/style" xmi:id="_8JNJ8Mv4EeSbcMzHkaYyAg" selectedViews="_94AOEMv4EeSbcMzHkaYyAg" version="8.1.1"> + <models xmi:type="ecore:EPackage" href="448373.ecore#/"/> + <models xmi:type="ecore:EPackage" href="448373b.ecore#/"/> + <ownedViews xmi:type="viewpoint:DRepresentationContainer" xmi:id="_94AOEMv4EeSbcMzHkaYyAg" initialized="true"> + <ownedRepresentations xmi:type="diagram:DSemanticDiagram" xmi:id="_CoLYgMv5EeSbcMzHkaYyAg" name="p0 package entities"> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_CoL_kMv5EeSbcMzHkaYyAg" source="GMF_DIAGRAMS"> + <data xmi:type="notation:Diagram" xmi:id="_CoL_kcv5EeSbcMzHkaYyAg" type="Sirius" element="_CoLYgMv5EeSbcMzHkaYyAg" measurementUnit="Pixel"> + <children xmi:type="notation:Node" xmi:id="_CoMmoMv5EeSbcMzHkaYyAg" type="2002" element="_CoLYgcv5EeSbcMzHkaYyAg"> + <children xmi:type="notation:Node" xmi:id="_CoMmo8v5EeSbcMzHkaYyAg" type="5006"/> + <children xmi:type="notation:Node" xmi:id="_CoMmpMv5EeSbcMzHkaYyAg" type="7001"> + <children xmi:type="notation:Node" xmi:id="_CoNNsMv5EeSbcMzHkaYyAg" type="3009" element="_CoLYh8v5EeSbcMzHkaYyAg"> + <children xmi:type="notation:Node" xmi:id="_CoNNs8v5EeSbcMzHkaYyAg" type="5004"/> + <children xmi:type="notation:Node" xmi:id="_CoN0wMv5EeSbcMzHkaYyAg" type="7003"> + <styles xmi:type="notation:SortingStyle" xmi:id="_CoN0wcv5EeSbcMzHkaYyAg"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_CoN0wsv5EeSbcMzHkaYyAg"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_CoNNscv5EeSbcMzHkaYyAg" fontName="Segoe UI" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_CoNNssv5EeSbcMzHkaYyAg" x="45" y="44"/> + </children> + <styles xmi:type="notation:SortingStyle" xmi:id="_CoMmpcv5EeSbcMzHkaYyAg"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_CoMmpsv5EeSbcMzHkaYyAg"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_CoMmocv5EeSbcMzHkaYyAg" fontName="Segoe UI" fontHeight="10"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_CoMmosv5EeSbcMzHkaYyAg" x="200" y="100"/> + </children> + <styles xmi:type="notation:DiagramStyle" xmi:id="_CoL_ksv5EeSbcMzHkaYyAg"/> + </data> + </ownedAnnotationEntries> + <ownedDiagramElements xmi:type="diagram:DNodeContainer" xmi:id="_CoLYgcv5EeSbcMzHkaYyAg" name="p1"> + <target xmi:type="ecore:EPackage" href="448373b.ecore#//p1"/> + <semanticElements xmi:type="ecore:EPackage" href="448373b.ecore#//p1"/> + <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> + <arrangeConstraints>KEEP_SIZE</arrangeConstraints> + <arrangeConstraints>KEEP_RATIO</arrangeConstraints> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_CoLYgsv5EeSbcMzHkaYyAg" labelSize="10" backgroundStyle="GradientTopToBottom"> + <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_CoLYg8v5EeSbcMzHkaYyAg"/> + <description xmi:type="style:FlatContainerStyleDescription" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@additionalLayers[name='Package']/@containerMappings[name='Design%20Package']/@style"/> + <borderColor xmi:type="viewpoint:RGBValues" xmi:id="_CoLYhMv5EeSbcMzHkaYyAg"/> + <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_CoLYhcv5EeSbcMzHkaYyAg" red="255" green="245" blue="181"/> + <foregroundColor xmi:type="viewpoint:RGBValues" xmi:id="_CoLYhsv5EeSbcMzHkaYyAg" red="255" green="255" blue="255"/> + </ownedStyle> + <actualMapping xmi:type="description_1:ContainerMapping" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@additionalLayers[name='Package']/@containerMappings[name='Design%20Package']"/> + <ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_CoLYh8v5EeSbcMzHkaYyAg" name="c1" tooltipText="p1.c1"> + <target xmi:type="ecore:EClass" href="448373b.ecore#//p1/c1"/> + <semanticElements xmi:type="ecore:EClass" href="448373b.ecore#//p1/c1"/> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_CoLYiMv5EeSbcMzHkaYyAg" backgroundStyle="GradientTopToBottom"> + <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_CoLYicv5EeSbcMzHkaYyAg"/> + <description xmi:type="style:FlatContainerStyleDescription" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@style"/> + <borderColor xmi:type="viewpoint:RGBValues" xmi:id="_CoLYisv5EeSbcMzHkaYyAg"/> + <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_CoLYi8v5EeSbcMzHkaYyAg" red="255" green="255" blue="255"/> + <foregroundColor xmi:type="viewpoint:RGBValues" xmi:id="_CoLYjMv5EeSbcMzHkaYyAg" red="209" green="209" blue="209"/> + </ownedStyle> + <actualMapping xmi:type="description_1:ContainerMapping" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']"/> + </ownedDiagramElements> + </ownedDiagramElements> + <description xmi:type="description_1:DiagramDescription" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']"/> + <filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="_CoLYjcv5EeSbcMzHkaYyAg"/> + <activatedLayers xmi:type="description_1:Layer" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer"/> + <activatedLayers xmi:type="description_1:AdditionalLayer" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@additionalLayers[name='Package']"/> + <target xmi:type="ecore:EPackage" href="448373b.ecore#/"/> + </ownedRepresentations> + <viewpoint xmi:type="description:Viewpoint" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']"/> + </ownedViews> +</viewpoint:DAnalysis> diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/tools/SiriusControlTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/tools/SiriusControlTest.java index 594f38ec71..4db0f8dcdb 100644 --- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/tools/SiriusControlTest.java +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/tools/SiriusControlTest.java @@ -11,8 +11,10 @@ package org.eclipse.sirius.tests.unit.api.tools; import java.io.File; +import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; +import java.util.Iterator; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; @@ -41,6 +43,9 @@ import org.eclipse.sirius.viewpoint.DAnalysis; import org.eclipse.sirius.viewpoint.DRepresentation; import org.eclipse.sirius.viewpoint.DView; import org.eclipse.sirius.viewpoint.provider.SiriusEditPlugin; +import org.junit.Assert; + +import com.google.common.collect.Lists; public class SiriusControlTest extends AbstractControlTest { @@ -66,6 +71,10 @@ public class SiriusControlTest extends AbstractControlTest { private static final String SEMANTIC_MODEL_FILENAME_7 = "VP-2818/tc.ecore"; + private static final String SEMANTIC_MODEL_FILENAME_8 = "448373/448373.ecore"; + + private static final String SEMANTIC_MODEL_FILENAME_8_1 = "448373/448373b.ecore"; + private static final String SESSION_MODEL_FILENAME_1 = "base/chain.aird"; private static final String SESSION_MODEL_FILENAME_2 = "controlled/chain.aird"; @@ -86,6 +95,8 @@ public class SiriusControlTest extends AbstractControlTest { private static final String SESSION_MODEL_FILENAME_7 = "VP-2818/tc.aird"; + private static final String SESSION_MODEL_FILENAME_8 = "448373/representations.aird"; + @Override protected void setUp() throws Exception { super.setUp(); @@ -100,6 +111,8 @@ public class SiriusControlTest extends AbstractControlTest { EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SEMANTIC_MODEL_FILENAME_6_1, "/" + TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_MODEL_FILENAME_6_1); EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SEMANTIC_MODEL_FILENAME_6_2, "/" + TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_MODEL_FILENAME_6_2); EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SEMANTIC_MODEL_FILENAME_7, "/" + TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_MODEL_FILENAME_7); + EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SEMANTIC_MODEL_FILENAME_8, "/" + TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_MODEL_FILENAME_8); + EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SEMANTIC_MODEL_FILENAME_8_1, "/" + TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_MODEL_FILENAME_8_1); EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SESSION_MODEL_FILENAME_1, "/" + TEMPORARY_PROJECT_NAME + "/" + SESSION_MODEL_FILENAME_1); EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SESSION_MODEL_FILENAME_2, "/" + TEMPORARY_PROJECT_NAME + "/" + SESSION_MODEL_FILENAME_2); @@ -111,6 +124,7 @@ public class SiriusControlTest extends AbstractControlTest { EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SESSION_MODEL_FILENAME_6_1, "/" + TEMPORARY_PROJECT_NAME + "/" + SESSION_MODEL_FILENAME_6_1); EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SESSION_MODEL_FILENAME_6_2, "/" + TEMPORARY_PROJECT_NAME + "/" + SESSION_MODEL_FILENAME_6_2); EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SESSION_MODEL_FILENAME_7, "/" + TEMPORARY_PROJECT_NAME + "/" + SESSION_MODEL_FILENAME_7); + EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SESSION_MODEL_FILENAME_8, "/" + TEMPORARY_PROJECT_NAME + "/" + SESSION_MODEL_FILENAME_8); } public void testControl() throws Exception { @@ -152,6 +166,71 @@ public class SiriusControlTest extends AbstractControlTest { } /** + * Test validating that it is possible to control/uncontrol the second + * semantic model of a modeling project. + * + * @throws Exception + */ + public void testControlUncontrolSecondModel() throws Exception { + // Addition of 2 models as semantic resources + ArrayList<String> semanticModelPaths = Lists.<String> newArrayList(); + semanticModelPaths.add(TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_MODEL_FILENAME_8); + semanticModelPaths.add(TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_MODEL_FILENAME_8_1); + genericSetUp(semanticModelPaths, Collections.<String> emptyList(), TEMPORARY_PROJECT_NAME + "/" + SESSION_MODEL_FILENAME_8); + ResourceSet rs = session.getTransactionalEditingDomain().getResourceSet(); + // Disabling ui callback + SiriusEditPlugin.getPlugin().setUiCallback(new NoUICallback()); + IDiagramCommandFactory commandFactory = DiagramCommandFactoryService.getInstance().getNewProvider().getCommandFactory(session.getTransactionalEditingDomain()); + commandFactory.setUserInterfaceCallBack(new NoUICallback()); + + // The control will be done on a element of the second semantic resource + Iterator<Resource> semanticResourceIterator = session.getSemanticResources().iterator(); + Resource semanticResource = semanticResourceIterator.next(); + Assert.assertEquals("The path of the first semantic resource is unexpected", "/resource/" + TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_MODEL_FILENAME_8, semanticResource.getURI().path()); + semanticResource = semanticResourceIterator.next(); + Assert.assertEquals("The path of the second semantic resource is unexpected", "/resource/" + TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_MODEL_FILENAME_8_1, semanticResource.getURI().path()); + + EObject semanticElt = semanticResource.getContents().get(0); + try { + assertFilesExist("/" + SEMANTIC_MODEL_FILENAME_8, "/" + SEMANTIC_MODEL_FILENAME_8_1, "/" + SESSION_MODEL_FILENAME_8); + String semantic_model_filename_8_1_controlled = ("/" + SEMANTIC_MODEL_FILENAME_8_1).replace(".ecore", "_controlled.ecore"); + String session_model_filename_8_1_controlled = ("/" + SESSION_MODEL_FILENAME_8).replace(".aird", "_controlled.aird"); + assertFilesDoNotExist(semantic_model_filename_8_1_controlled, session_model_filename_8_1_controlled); + assertEquals("The resourceSet should be contains only 3 resources typed Aird and Ecore", 3, getResourceTypeAirdOrEcore(rs).size()); + + final EObject root = findPackageNamed("p1", semanticElt); + final DRepresentation representation = session.getOwnedViews().iterator().next().getOwnedRepresentations().get(0); + final URI controlledModelUri = URI.createPlatformResourceURI(TEMPORARY_PROJECT_NAME + semantic_model_filename_8_1_controlled, true); + final URI controlledAirdUri = URI.createPlatformResourceURI(TEMPORARY_PROJECT_NAME + session_model_filename_8_1_controlled, true); + siriusControl(root, controlledModelUri, Collections.singleton(representation), controlledAirdUri); + + final EObject root2 = findPackageNamed("p1", semanticElt); + assertNotNull(root2); + assertSame(root, root2); + assertEquals(controlledModelUri, root2.eResource().getURI()); + assertEquals(controlledAirdUri, representation.eResource().getURI()); + + // Check that the created aird does not need migration (version tag + // must be initialized) + checkRepresentationFileMigrationStatus(controlledAirdUri, false); + + assertFilesExist("/" + SEMANTIC_MODEL_FILENAME_8, "/" + SEMANTIC_MODEL_FILENAME_8_1, "/" + SESSION_MODEL_FILENAME_8, semantic_model_filename_8_1_controlled, + session_model_filename_8_1_controlled); + assertEquals("The resourceSet should be contains only 5 resources typed Aird and Ecore", 5, getResourceTypeAirdOrEcore(rs).size()); + + // Uncontrol the controlled element + Command vuc = new SiriusUncontrolCommand(root2, true, true, new NullProgressMonitor()); + session.getTransactionalEditingDomain().getCommandStack().execute(vuc); + + assertFilesExist("/" + SEMANTIC_MODEL_FILENAME_8, "/" + SEMANTIC_MODEL_FILENAME_8_1, "/" + SESSION_MODEL_FILENAME_8); + assertEquals("The resourceSet should be contains only 3 resources typed Aird and Ecore", 3, getResourceTypeAirdOrEcore(rs).size()); + assertFilesDoNotExist(semantic_model_filename_8_1_controlled, session_model_filename_8_1_controlled); + } finally { + session.close(new NullProgressMonitor()); + } + } + + /** * The control command must add a models if an element of the controlled * representations point outside the semantic model. * diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/control/SiriusControlCommand.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/control/SiriusControlCommand.java index a0fbe57247..206f7748d3 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/control/SiriusControlCommand.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/control/SiriusControlCommand.java @@ -38,6 +38,7 @@ import org.eclipse.sirius.viewpoint.SiriusPlugin; import org.eclipse.sirius.viewpoint.ViewpointFactory; import org.eclipse.sirius.viewpoint.description.Viewpoint; +import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; import com.google.common.collect.Sets; @@ -249,8 +250,8 @@ public class SiriusControlCommand extends ControlCommand { for (Resource aird : session.getAllSessionResources()) { DAnalysis currentAnalysis = getDAnalysis(aird); - Option<EObject> optionalMainModel = new DAnalysisQuery(currentAnalysis).getMainModel(); - if (optionalMainModel.some() && optionalMainModel.get().equals(semanticParentRoot)) { + Set<EObject> releventModels = new DAnalysisQuery(currentAnalysis).getMainModels(); + if (Iterables.contains(releventModels, semanticParentRoot)) { List<DAnalysis> referencedAnalysis = new ArrayList<DAnalysis>(currentAnalysis.getReferencedAnalysis()); for (DAnalysis childrenAnalysis : referencedAnalysis) { Option<EObject> optionalChildrenMainModel = new DAnalysisQuery(childrenAnalysis).getMainModel(); diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/control/SiriusUncontrolCommand.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/control/SiriusUncontrolCommand.java index c075333391..03e7528774 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/control/SiriusUncontrolCommand.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/control/SiriusUncontrolCommand.java @@ -13,6 +13,7 @@ package org.eclipse.sirius.business.api.control; import java.io.IOException; import java.util.Collection; import java.util.Collections; +import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor; @@ -25,11 +26,11 @@ import org.eclipse.sirius.business.api.session.Session; import org.eclipse.sirius.business.api.session.SessionManager; import org.eclipse.sirius.business.api.session.danalysis.DAnalysisSession; import org.eclipse.sirius.business.internal.command.control.UncontrolCommand; -import org.eclipse.sirius.ext.base.Option; import org.eclipse.sirius.viewpoint.DAnalysis; import org.eclipse.sirius.viewpoint.DRepresentation; import org.eclipse.sirius.viewpoint.SiriusPlugin; +import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -195,8 +196,8 @@ public class SiriusUncontrolCommand extends UncontrolCommand { for (final Resource anResource : session.getAllSessionResources()) { for (final DAnalysis analysis : getAnalyses(anResource)) { - Option<EObject> optionalMainModel = new DAnalysisQuery(analysis).getMainModel(); - if (optionalMainModel.some() && optionalMainModel.get().equals(object)) { + Set<EObject> releventModels = new DAnalysisQuery(analysis).getMainModels(); + if (Iterables.contains(releventModels, object)) { return anResource; } } diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/query/DAnalysisQuery.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/query/DAnalysisQuery.java index d718ad7738..67cfb96f93 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/query/DAnalysisQuery.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/query/DAnalysisQuery.java @@ -12,8 +12,10 @@ package org.eclipse.sirius.business.api.query; import java.util.ArrayList; import java.util.Collection; +import java.util.Set; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; import org.eclipse.sirius.ext.base.Option; import org.eclipse.sirius.ext.base.Options; import org.eclipse.sirius.viewpoint.DAnalysis; @@ -114,6 +116,34 @@ public class DAnalysisQuery { } /** + * Build a list of main models. <br/> + * First, get the first model of this analysis if it contains at least one + * model. The first model is the model used to create the representations + * file. <br/> + * Then add each non controlled models that is not a parent of the main + * model (which can be a model fragment if the current DAnalysis is a + * referenced analysis and has been created during a previous control). + * + * @return an {@link Set} of EObject representing the root of the main + * semantic models. + */ + public Set<EObject> getMainModels() { + Option<EObject> optionalMainModel = getMainModel(); + // We need a list with the "main model" and other root models to allow + // control on project with many models + Set<EObject> releventModels = Sets.newLinkedHashSet(); + if (optionalMainModel.some()) { + releventModels.add(optionalMainModel.get()); + for (EObject model : analysis.getModels()) { + if (!AdapterFactoryEditingDomain.isControlled(model) && !(new EObjectQuery(optionalMainModel.get()).isContainedIn(model))) { + releventModels.add(model); + } + } + } + return releventModels; + } + + /** * Get selected {@link Viewpoint}s for the current {@link DAnalysis}. * * @return selected {@link Viewpoint}s for the current {@link DAnalysis} |
