Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Porhel2015-06-12 12:44:19 +0000
committerMaxime Porhel2015-06-12 12:52:42 +0000
commiteac75d2ba2fb6204f5439d09c86dce3f4d969a2a (patch)
treeda963f6643c49878e8ad619d74906d0109f5f0bd
parent4992506b51757b8c640e04b9a2edc908812be74e (diff)
downloadorg.eclipse.sirius-eac75d2ba2fb6204f5439d09c86dce3f4d969a2a.tar.gz
org.eclipse.sirius-eac75d2ba2fb6204f5439d09c86dce3f4d969a2a.tar.xz
org.eclipse.sirius-eac75d2ba2fb6204f5439d09c86dce3f4d969a2a.zip
[466566] Add adapters on new referenced analysis after reloadv2.0.6
Add adapters on new referenced analysis after reload. Control the order of the workspace impacting notifications to place the representation files changes after the semantic files changes. The previous order was the folder/project children resources order (by name), it used to forbid the controlled resource detection after an external control. Bug: 466566 Change-Id: Ic3e078e3b73029cb0378111f5829300badaea13d Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisRefresher.java48
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java20
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/ReloadRepresentationsFileCmd.java3
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/RepresentationsChangeAdapter.java10
4 files changed, 63 insertions, 18 deletions
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisRefresher.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisRefresher.java
index 170387a7c2..a668df64d2 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisRefresher.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisRefresher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2014 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2012, 2015 THALES GLOBAL SERVICES and others.
* 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
@@ -25,6 +25,7 @@ import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.transaction.NotificationFilter;
import org.eclipse.emf.transaction.RecordingCommand;
@@ -35,6 +36,7 @@ import org.eclipse.emf.transaction.RollbackException;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.sirius.business.api.query.URIQuery;
import org.eclipse.sirius.business.api.session.Session;
+import org.eclipse.sirius.business.api.session.danalysis.DAnalysisSession;
import org.eclipse.sirius.ecore.extender.tool.api.ModelUtils;
import org.eclipse.sirius.ext.emf.EReferencePredicate;
import org.eclipse.sirius.viewpoint.DAnalysis;
@@ -43,6 +45,7 @@ import org.eclipse.sirius.viewpoint.DView;
import org.eclipse.sirius.viewpoint.ViewpointPackage;
import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
@@ -120,8 +123,9 @@ public class DAnalysisRefresher extends ResourceSetListenerImpl implements Resou
}
/**
- * Check the resources in the resourceSet and add all new resources as
- * semantic resources of this session. New resources are :
+ * Check the resources in the resourceSet. Detect new resources and add them
+ * to the session as new semantic resources or referenced session resources.<BR><BR>
+ * New semantic resources are :
* <UL>
* <LI>Resources that are not in the <code>knownResources</code> list</LI>
* <LI>Resources that are not in the semantic resources of this session</LI>
@@ -129,20 +133,45 @@ public class DAnalysisRefresher extends ResourceSetListenerImpl implements Resou
* resources of this session</LI>
* <LI>Resources that are not the Sirius environment resource</LI>
* </UL>
+ * <BR>
+ * New referenced session resources are :
+ * <UL>
+ * <LI>Resources that are not in the <code>knownResources</code> list</LI>
+ * <LI>Resources that are in the referenced representations files resources
+ * of this session (the list is computed from the allAnalyses() result)</LI>
+ * </UL>
*
* @param knownResources
* List of resources that is already loaded before the resolveAll
* of the representations file load.
*/
- public void addAutomaticallyLoadedResourcesToSemanticResources(List<Resource> knownResources) {
+ public void manageAutomaticallyLoadedResources(List<Resource> knownResources) {
TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
List<Resource> resourcesAfterLoadOfSession = Lists.newArrayList(domain.getResourceSet().getResources());
// Remove the known resources
Iterators.removeAll(resourcesAfterLoadOfSession.iterator(), knownResources);
+
+ if (resourcesAfterLoadOfSession.isEmpty()) {
+ return;
+ }
+
+ Set<Resource> referencedSessionResources = session.getReferencedSessionResources();
+ Collection<Resource> newReferencedSessionResources = Lists.newArrayList(Iterables.filter(resourcesAfterLoadOfSession, Predicates.in(referencedSessionResources)));
+ if (!newReferencedSessionResources.isEmpty() && session instanceof DAnalysisSession) {
+ for (Resource newReferencedSessionResource : newReferencedSessionResources) {
+ // session.registerResourceInCrossReferencer(newReferencedSessionResource);
+ // private method in DAnalysisSessionImpl
+ registerResourceInCrossReferencer(newReferencedSessionResource);
+ for (DAnalysis refAnalysis : Iterables.filter(newReferencedSessionResource.getContents(), DAnalysis.class)) {
+ ((DAnalysisSession) session).addAdaptersOnAnalysis(refAnalysis);
+ }
+ }
+ }
+
// Remove the known semantic resources
Iterators.removeAll(resourcesAfterLoadOfSession.iterator(), session.getSemanticResources());
// Remove the known referenced representations file resources
- Iterators.removeAll(resourcesAfterLoadOfSession.iterator(), session.getReferencedSessionResources());
+ Iterators.removeAll(resourcesAfterLoadOfSession.iterator(), referencedSessionResources);
// Remove the Sirius Environment resource
final Iterable<Resource> newSemanticResourcesIterator = Iterables.filter(resourcesAfterLoadOfSession, new Predicate<Resource>() {
public boolean apply(Resource resource) {
@@ -254,4 +283,13 @@ public class DAnalysisRefresher extends ResourceSetListenerImpl implements Resou
session = null;
}
+ private void registerResourceInCrossReferencer(final Resource newResource) {
+ ECrossReferenceAdapter crossReferencer = session.getSemanticCrossReferencer();
+ if (crossReferencer != null) {
+ if (!newResource.eAdapters().contains(crossReferencer)) {
+ newResource.eAdapters().add(crossReferencer);
+ }
+ }
+ }
+
}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java
index ec435f993e..f8991588e6 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java
@@ -544,9 +544,8 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements
dAnalysisRefresher.forceLoadingOfEveryLinkedResource();
monitor.worked(10);
- // Add the unknown resources to the semantic resources of this
- // session.
- dAnalysisRefresher.addAutomaticallyLoadedResourcesToSemanticResources(resourcesBeforeLoadOfSession);
+ // Manage the unknown resources.
+ dAnalysisRefresher.manageAutomaticallyLoadedResources(resourcesBeforeLoadOfSession);
monitor.worked(1);
setSynchronizeStatusofEveryResource();
monitor.worked(1);
@@ -1732,12 +1731,18 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements
private Multimap<ResourceStatus, Resource> getImpactingNewStatuses(Collection<ResourceStatusChange> changes) {
Multimap<ResourceStatus, Resource> impactingNewStatuses = LinkedHashMultimap.create();
- Iterable<Resource> resources = Iterables.concat(getSemanticResources(), getAllSessionResources(), getControlledResources());
+ Multimap<ResourceStatus, Resource> sessionResourcesNewStatuses = LinkedHashMultimap.create();
+ Iterable<Resource> semanticOrControlledresources = Iterables.concat(getSemanticResources(), getControlledResources());
+ Set<Resource> allSessionResources = getAllSessionResources();
for (ResourceStatusChange change : changes) {
- if (isResourceOfSession(change.getResource(), resources)) {
+ if (isResourceOfSession(change.getResource(), semanticOrControlledresources)) {
impactingNewStatuses.put(change.getNewStatus(), change.getResource());
+ } else if (isResourceOfSession(change.getResource(), allSessionResources)) {
+ sessionResourcesNewStatuses.put(change.getNewStatus(), change.getResource());
}
}
+ // Add session resource impacting status after semantic ones.
+ impactingNewStatuses.putAll(sessionResourcesNewStatuses);
return impactingNewStatuses;
}
@@ -1854,10 +1859,9 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements
mainDAnalysis = (DAnalysis) sessionResource.getContents().get(0);
}
}
- // Add the unknown resources to the semantic resources of this
- // session.
+ // Manage the unknown resources.
if (dAnalysisRefresher != null) {
- dAnalysisRefresher.addAutomaticallyLoadedResourcesToSemanticResources(resourcesBeforeReload);
+ dAnalysisRefresher.manageAutomaticallyLoadedResources(resourcesBeforeReload);
}
notifyListeners(SessionListener.REPLACED);
}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/ReloadRepresentationsFileCmd.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/ReloadRepresentationsFileCmd.java
index d58d8682bb..4e264e606d 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/ReloadRepresentationsFileCmd.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/ReloadRepresentationsFileCmd.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 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
@@ -100,7 +100,6 @@ public class ReloadRepresentationsFileCmd extends RecordingCommand {
Adapter existingAirDCrossReferenceAdapter = EcoreUtil.getExistingAdapter(resource.getResourceSet(), AirDCrossReferenceAdapter.class);
if (existingAirDCrossReferenceAdapter instanceof AirDCrossReferenceAdapter) {
resource.eAdapters().add(existingAirDCrossReferenceAdapter);
- System.out.println("Add airDCrossReferenceAdapter on resource " + resource.getURI().toString());
}
}
}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/RepresentationsChangeAdapter.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/RepresentationsChangeAdapter.java
index d6ae272830..31c4e7ecfe 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/RepresentationsChangeAdapter.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/RepresentationsChangeAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 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
@@ -102,7 +102,9 @@ public class RepresentationsChangeAdapter extends AdapterImpl {
* the analysis
*/
public void registerAnalysis(final DAnalysis analysis) {
- analysis.eAdapters().add(this);
+ if (!analysis.eAdapters().contains(this)) {
+ analysis.eAdapters().add(this);
+ }
for (final DView view : analysis.getOwnedViews()) {
registerView(view);
}
@@ -135,7 +137,9 @@ public class RepresentationsChangeAdapter extends AdapterImpl {
* the editor
*/
private void registerView(final DView view) {
- view.eAdapters().add(this);
+ if (!view.eAdapters().contains(this)) {
+ view.eAdapters().add(this);
+ }
}
/**

Back to the top