diff options
| author | Steve Monnier | 2015-03-25 09:02:28 +0000 |
|---|---|---|
| committer | Steve Monnier | 2015-03-25 14:14:24 +0000 |
| commit | 23e88de105eb0e65627b369794407be9df3c24c1 (patch) | |
| tree | 2f07844d27d5843cce8f315da8f7d25b6effe0ae | |
| parent | cbba085ccdd7ee74b09ad739dafa8a9b28790f35 (diff) | |
| download | org.eclipse.sirius-23e88de105eb0e65627b369794407be9df3c24c1.tar.gz org.eclipse.sirius-23e88de105eb0e65627b369794407be9df3c24c1.tar.xz org.eclipse.sirius-23e88de105eb0e65627b369794407be9df3c24c1.zip | |
[462336] Allow (un)control on semantic models other than the first
This is a follow up of the previous commit that causes regression in
SiriusControlTest on scenario with several control action in the
opposite order of the model hierarchy.
Bug: 462336
Change-Id: Ie4c94eea367c6a01e7c21c882028442b49a9adb5
Signed-off-by: Steve Monnier <steve.monnier@obeo.fr>
5 files changed, 42 insertions, 3 deletions
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html index 227a8f945e..23d538b8fd 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html @@ -60,6 +60,10 @@ <code>doExecute</code> implementation has changed. The constructor parameter <code>removeFromControlledResources</code> is not taken into account anymore because a fix allows a better resource management whatever controlled or not the resource is. </li> + <li>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> <h2 id="sirius2.0.4">Changes in Sirius 2.0.4 (from Sirius 2.0.3)</h2> <h3 id="APIChanges2">API Changes</h3> @@ -2037,4 +2041,4 @@ void removeSelectedView(DView view); <li>The ability to print table representations has been disabled for the 0.9 release due to an external dependency issue (see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=422223" target="_blank">bug #422223</a>: for the details). It should be re-introduced in 1.0.</li> </ul> </body> -</html> +</html>
\ No newline at end of file diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile index 9175765b39..4e989e8975 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile @@ -11,6 +11,7 @@ h3. API Changes h4. Changes in @org.eclipse.sirius@ * A new constructor has been added in @org.eclipse.sirius.tools.api.command.semantic.RemoveSemanticResourceCommand@ allowing giving the boolean value @removeReferencingResources@ to indicate if the referencing resources are also to remove. Note that, in @doExecute@ method, a cast is done on @DAnalysisSessionImpl@ to avoid API break. Moreover, the @doExecute@ implementation has changed. The constructor parameter @removeFromControlledResources@ is not taken into account anymore because a fix allows a better resource management whatever controlled or not the resource is. +* 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. h2(#sirius2.0.4). Changes in Sirius 2.0.4 (from Sirius 2.0.3) 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 40f0ce547c..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 @@ -250,7 +250,8 @@ public class SiriusControlCommand extends ControlCommand { for (Resource aird : session.getAllSessionResources()) { DAnalysis currentAnalysis = getDAnalysis(aird); - if (Iterables.contains(currentAnalysis.getModels(), 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 905a4a1501..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,12 +13,14 @@ 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; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.sirius.business.api.query.DAnalysisQuery; import org.eclipse.sirius.business.api.query.EObjectQuery; import org.eclipse.sirius.business.api.session.Session; import org.eclipse.sirius.business.api.session.SessionManager; @@ -194,7 +196,8 @@ public class SiriusUncontrolCommand extends UncontrolCommand { for (final Resource anResource : session.getAllSessionResources()) { for (final DAnalysis analysis : getAnalyses(anResource)) { - if (Iterables.contains(analysis.getModels(), 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} |
