Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Constant2019-03-25 13:53:15 -0400
committerOlivier Constant2019-03-25 13:53:15 -0400
commitfde3db06c16dd8d96f6a1d89fe521c398df3f7ad (patch)
tree4fd37618f1d3e7b0dc235303850b5e93ed7abe42
parent48e593ee092cffac3402deb098153c4fab2fb1b9 (diff)
downloadorg.eclipse.emf.diffmerge.core-fde3db06c16dd8d96f6a1d89fe521c398df3f7ad.tar.gz
org.eclipse.emf.diffmerge.core-fde3db06c16dd8d96f6a1d89fe521c398df3f7ad.tar.xz
org.eclipse.emf.diffmerge.core-fde3db06c16dd8d96f6a1d89fe521c398df3f7ad.zip
Bug 545760 - Editor remains dirty after save on Sirius 6.1 session
Change-Id: I2d8b877b898ece14e6bd86a5cbf6e6019a411a54 Signed-off-by: Olivier Constant <olivier.constant@thalesgroup.com>
-rw-r--r--plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusScope.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusScope.java b/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusScope.java
index 41f77a56..b3e571c7 100644
--- a/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusScope.java
+++ b/plugins/org.eclipse.emf.diffmerge.sirius/src/org/eclipse/emf/diffmerge/sirius/SiriusScope.java
@@ -19,6 +19,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.diffmerge.gmf.GMFScope;
import org.eclipse.emf.diffmerge.structures.common.FArrayList;
@@ -32,6 +33,8 @@ import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.sirius.business.api.helper.SiriusUtil;
import org.eclipse.sirius.business.api.query.DRepresentationQuery;
import org.eclipse.sirius.business.api.resource.ResourceDescriptor;
+import org.eclipse.sirius.business.api.session.Session;
+import org.eclipse.sirius.business.api.session.SessionManager;
import org.eclipse.sirius.diagram.DiagramPackage;
import org.eclipse.sirius.viewpoint.DAnalysis;
import org.eclipse.sirius.viewpoint.DRepresentation;
@@ -244,6 +247,38 @@ public class SiriusScope extends GMFScope {
}
/**
+ * Return a session resource of the scope, if any
+ * @return a potentially null resource
+ */
+ protected Resource getSessionResource() {
+ for (Resource candidate : getResources()) {
+ if (isSessionResource(candidate)) {
+ return candidate;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return the Sirius session of the editing domain of the scope, if any
+ * @return a potentially null session
+ */
+ public Session getSession() {
+ Session result = null;
+ if (getEditingDomain() != null) {
+ Resource sessionResource = getSessionResource();
+ if (sessionResource != null) {
+ Session sessionForURI = SessionManager.INSTANCE.getExistingSession(
+ sessionResource.getURI());
+ if (sessionForURI != null && sessionForURI.getSessionResource() == sessionResource) {
+ result = sessionForURI;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
* @see org.eclipse.emf.diffmerge.impl.scopes.AbstractModelScope#isContainment(org.eclipse.emf.ecore.EReference)
*/
@Override
@@ -254,6 +289,23 @@ public class SiriusScope extends GMFScope {
}
/**
+ * Return whether the given resource is a session resource
+ * @param resource_p a non-null resource
+ */
+ protected boolean isSessionResource(Resource resource_p) {
+ URI uri = resource_p.getURI();
+ return uri != null && isSessionResourceURI(uri);
+ }
+
+ /**
+ * Return whether the given URI is a session resource URI
+ * @param uri_p a non-null URI
+ */
+ protected boolean isSessionResourceURI(URI uri_p) {
+ return SiriusUtil.SESSION_RESOURCE_EXTENSION.equals(uri_p.fileExtension());
+ }
+
+ /**
* Return whether the given element can be included in a Sirius resource
* @param element_p a non-null element
*/
@@ -319,4 +371,20 @@ public class SiriusScope extends GMFScope {
return result;
}
+ /**
+ * @see org.eclipse.emf.diffmerge.impl.scopes.FragmentedModelScope#save()
+ */
+ @Override
+ public boolean save() throws Exception {
+ boolean result;
+ Session session = getSession();
+ if (session != null) {
+ session.save(new NullProgressMonitor());
+ result = true;
+ } else {
+ result = super.save();
+ }
+ return result;
+ }
+
}

Back to the top