Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-06-11 20:21:34 +0000
committerChristian W. Damus2014-07-21 14:58:30 +0000
commit5ab06e3232056fdea6708b153e2c22d4b99eaa14 (patch)
treeb60e5e91a8d531f81b62bcdf538afb98ca906fbe /extraplugins/cdo
parent029e4b677bf9ad7a919565c55d1c4ed3128e5cb4 (diff)
downloadorg.eclipse.papyrus-5ab06e3232056fdea6708b153e2c22d4b99eaa14.tar.gz
org.eclipse.papyrus-5ab06e3232056fdea6708b153e2c22d4b99eaa14.tar.xz
org.eclipse.papyrus-5ab06e3232056fdea6708b153e2c22d4b99eaa14.zip
437052: [CDO] Support resource modification tracking for non-CDO
resources https://bugs.eclipse.org/bugs/show_bug.cgi?id=437052 Restore the resource modification-tracking-based strategy in the ModelSet's save logic. IModel implementations delegate the question of whether a resource needs to be saved to the ModelSet via a new "shouldSave(Resource) : boolean" API. The ModelSet, in turn, delegates the question of whether a resource needs to be saved to its ProxyModificationTrackingAdapter, which latter is now specialized by the CDOAwareModelSet to take into account the save semantics of CDOResources. For a ModelSet that is not tracking resource modifications, and therefore does not have this adapter, it simply assumes that any resource that can be saved needs to be saved. Change-Id: Ia651b38f09d7dade435a8738b8a4a7f25e50af1b
Diffstat (limited to 'extraplugins/cdo')
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java9
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareProxyModificationTrackingAdapter.java64
2 files changed, 70 insertions, 3 deletions
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java
index bee114137cd..cfc43f96173 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java
@@ -10,6 +10,7 @@
* CEA LIST - Initial API and implementation
* Christian W. Damus (CEA) - bug 429242
* Christian W. Damus (CEA) - bug 422257
+ * Christian W. Damus (CEA) - bug 437052
*
*****************************************************************************/
package org.eclipse.papyrus.cdo.core.resource;
@@ -77,13 +78,15 @@ public class CDOAwareModelSet extends OnDemandLoadingModelSet {
super();
this.resources = new SafeResourceList();
-
- setTrackingModification(false);
-
this.repositoryManager = repositoryManager;
}
@Override
+ protected Adapter createModificationTrackingAdapter() {
+ return new CDOAwareProxyModificationTrackingAdapter();
+ }
+
+ @Override
public EObject getEObject(URI uri, boolean loadOnDemand) {
return CDOUtils.isCDOURI(uri) ? getCDOObject(uri, loadOnDemand) : super.getEObject(uri, loadOnDemand);
}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareProxyModificationTrackingAdapter.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareProxyModificationTrackingAdapter.java
new file mode 100644
index 00000000000..2f449b3403b
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareProxyModificationTrackingAdapter.java
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.resource;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.papyrus.infra.core.resource.ProxyModificationTrackingAdapter;
+
+
+/**
+ * A specialization of the {@link ProxyModificationTrackingAdapter} that knows how to deal with
+ * CDO resources. In particular, that their dirty/save semantics is completely different from
+ * that of workspace resources.
+ */
+public class CDOAwareProxyModificationTrackingAdapter extends ProxyModificationTrackingAdapter {
+
+ public CDOAwareProxyModificationTrackingAdapter() {
+ super();
+ }
+
+ @Override
+ public boolean shouldSave(Resource resource) {
+ boolean result;
+
+ if(resource instanceof CDOResource) {
+ CDOView view = ((CDOResource)resource).cdoView();
+ if(view instanceof CDOTransaction) {
+ // Saving CDO resources is done by committing the transaction
+ result = ((CDOTransaction)view).isDirty();
+ } else {
+ // If there's no view or it's not a transaction, then saving is a non-starter
+ result = false;
+ }
+ } else {
+ result = super.shouldSave(resource);
+ }
+
+ return result;
+ }
+
+ @Override
+ public void notifyChanged(Notification msg) {
+ Object notifier = msg.getNotifier();
+
+ // Only for non-CDO resources do we care if the URI has changed or contents been added, because
+ // references within the repository use OIDs and are, therefore, not susceptible to URI changes
+ if(!(notifier instanceof CDOResource)) {
+ super.notifyChanged(msg);
+ }
+ }
+
+}

Back to the top