Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2013-08-23 02:44:04 +0000
committerChristian W. Damus2013-09-16 20:02:43 +0000
commit923b809f40b9e65d6ac44cba43ad8b978b0900a2 (patch)
treed689c64ebd8306a7e13c9f19a7a5d779c6054cf2 /extraplugins
parentee019cc6f47126d1a08e2c4b21d047c64fa068c1 (diff)
downloadorg.eclipse.papyrus-923b809f40b9e65d6ac44cba43ad8b978b0900a2.tar.gz
org.eclipse.papyrus-923b809f40b9e65d6ac44cba43ad8b978b0900a2.tar.xz
org.eclipse.papyrus-923b809f40b9e65d6ac44cba43ad8b978b0900a2.zip
415369: [CDO] Support controlled resources and lazy loading
https://bugs.eclipse.org/bugs/show_bug.cgi?id=415369 Initial implementation of re-integration of controlled resources in the CDO repository.
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF3
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java97
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/controlmode/CDOControlModeParticipant.java325
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/controlmode/CDOProxyManager.java6
4 files changed, 374 insertions, 57 deletions
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF
index 99515fda954..601eaf4d7d2 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF
@@ -36,7 +36,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)",
com.google.guava;bundle-version="[11.0.2,12.0.0)",
org.eclipse.papyrus.infra.services.controlmode;bundle-version="0.10.1",
- org.eclipse.gmf.runtime.emf.commands.core;bundle-version="[1.7.0,2.0.0)"
+ org.eclipse.gmf.runtime.emf.commands.core;bundle-version="[1.7.0,2.0.0)",
+ org.eclipse.gmf.runtime.emf.type.core;bundle-version="[1.7.0,2.0.0)"
Bundle-Vendor: %providerName
Bundle-Version: 0.10.1.qualifier
Bundle-ManifestVersion: 2
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 4f5f74ede8b..bfc23c63f3e 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
@@ -13,9 +13,15 @@ package org.eclipse.papyrus.cdo.core.resource;
import java.io.IOException;
import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Set;
+import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
import org.eclipse.emf.cdo.view.CDOViewSet;
@@ -32,6 +38,7 @@ import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager;
import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
import org.eclipse.papyrus.cdo.internal.core.controlmode.CDOProxyManager;
+import org.eclipse.papyrus.infra.core.Activator;
import org.eclipse.papyrus.infra.core.resource.ModelMultiException;
import org.eclipse.papyrus.infra.services.resourceloading.OnDemandLoadingModelSet;
@@ -43,6 +50,8 @@ import com.google.common.collect.Iterables;
*/
public class CDOAwareModelSet extends OnDemandLoadingModelSet {
+ private static final Set<CDOState> DIRTY_STATES = EnumSet.of(CDOState.NEW, CDOState.DIRTY, CDOState.CONFLICT, CDOState.INVALID_CONFLICT);
+
private final ThreadLocal<Boolean> inGetResource = new ThreadLocal<Boolean>();
private final CDOProxyManager proxyManager = new CDOProxyManager(this);
@@ -55,6 +64,9 @@ public class CDOAwareModelSet extends OnDemandLoadingModelSet {
public CDOAwareModelSet(IPapyrusRepositoryManager repositoryManager) {
super();
+
+ this.resources = new SafeResourceList();
+
setTrackingModification(false);
this.repositoryManager = repositoryManager;
@@ -256,4 +268,89 @@ public class CDOAwareModelSet extends OnDemandLoadingModelSet {
CDOView view = getCDOView();
return ((view == null) || view.isClosed()) && getResources().isEmpty();
}
+
+ boolean isDirty(Resource resource) {
+ return (resource instanceof CDOResource) && DIRTY_STATES.contains(((CDOResource)resource).cdoState());
+ }
+
+ @Override
+ protected void handleResourcesToDelete() {
+ final int initialCount = getResourcesToDeleteOnSave().size();
+
+ super.handleResourcesToDelete();
+
+ // any changes made by resource deletions?
+ CDOView view = getCDOView();
+ if((view instanceof CDOTransaction) && (getResourcesToDeleteOnSave().size() < initialCount)) {
+ try {
+ ((CDOTransaction)view).commit();
+ } catch (CommitException e) {
+ Activator.log.error("Failed to commit resource deletions.", e);
+ }
+ }
+ }
+
+ @Override
+ protected boolean validateDeleteResource(URI uri) {
+ boolean result = true;
+
+ Resource resource = getResource(uri, false);
+
+ // if it was meant to be deleted, an attempt would have been made to remove it. That may
+ // have been prevented if it was dirty. If it isn't now, then delete it. Otherwise,
+ // block again
+ if((resource != null) && isDirty(resource)) {
+ result = false;
+ Activator.log.warn("Attempt to delete a dirty CDO resource: " + uri);
+ }
+
+ return result;
+ }
+
+ @Override
+ protected boolean deleteResource(URI uri) {
+ Resource res = getResource(uri, false);
+ boolean result = res instanceof CDOResource;
+
+ if(!result) {
+ // not a CDO resource. Default behaviour
+ result = super.deleteResource(uri);
+ } else {
+ try {
+ res.delete(null);
+ if(res.getResourceSet() != null) {
+ res.unload();
+ res.getResourceSet().getResources().remove(res);
+ }
+ } catch (IOException e) {
+ Activator.log.error(e);
+ }
+ }
+
+ return result;
+ }
+
+ //
+ // Nested types
+ //
+
+ /**
+ * CDO doesn't permit resources to be removed from the resource set if they are {@linkplain CDOState#DIRTY dirty}, so this specialized list
+ * prevents that.
+ */
+ private class SafeResourceList extends ResourcesEList<Resource> {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public boolean remove(Object object) {
+ boolean result = !(object instanceof CDOResource) || !isDirty((CDOResource)object);
+
+ if(result) {
+ result = super.remove(object);
+ }
+
+ return result;
+ }
+ }
}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/controlmode/CDOControlModeParticipant.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/controlmode/CDOControlModeParticipant.java
index 8b8ba4b65ae..6ae93e2faad 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/controlmode/CDOControlModeParticipant.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/controlmode/CDOControlModeParticipant.java
@@ -32,6 +32,8 @@ import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -49,21 +51,27 @@ import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
import org.eclipse.papyrus.infra.services.controlmode.commands.AbstractControlCommand;
import org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandParticipant;
import org.eclipse.papyrus.infra.services.controlmode.participants.IControlModeParticipant;
+import org.eclipse.papyrus.infra.services.controlmode.participants.IUncontrolCommandParticipant;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableCollection;
+import com.google.common.collect.ImmutableCollection.Builder;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
/**
* A {@link IControlModeParticipant} for CDO resources that handles replacing references to controlled
* elements with proxies that, even in a CDO view, must be resolved by the usual EMF mechanism.
*/
-public class CDOControlModeParticipant implements IControlCommandParticipant {
+public class CDOControlModeParticipant implements IControlCommandParticipant, IUncontrolCommandParticipant {
private static final Set<CDOState> TEMPORARY_ID_STATES = EnumSet.of(CDOState.TRANSIENT, CDOState.NEW);
+ private List<EObject> objectsToClearResource;
+
public CDOControlModeParticipant() {
super();
}
@@ -77,72 +85,94 @@ public class CDOControlModeParticipant implements IControlCommandParticipant {
}
public boolean provideControlCommand(ControlModeRequest request) {
+ return isCDOResource(request);
+ }
+
+ private boolean isCDOResource(ControlModeRequest request) {
return CDOUtils.isCDOURI(request.getSourceURI());
}
+ public boolean provideUnControlCommand(ControlModeRequest request) {
+ return isCDOResource(request);
+ }
+
public ICommand getPreControlCommand(ControlModeRequest request) {
return IdentityCommand.INSTANCE;
}
public ICommand getPostControlCommand(ControlModeRequest request) {
- return new AbstractControlCommand("CDO aspects", Collections.emptyList(), request) {
-
- private List<Update> updates;
+ return new AbstractCDOControlCommand(request) {
@Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- final ImmutableList.Builder<Update> updates = ImmutableList.builder();
-
- for(final EObject object : getAllPersistentSubunitContents(getRequest())) {
- if(isPersistentObject(object)) {
- // replace references to the element by a proxy
- final CDOID proxy = CDOIDUtil.createExternal(CDOProxyManager.createPapyrusCDOURI(object).toString());
- for(EStructuralFeature.Setting next : getExternalCrossReferences(object)) {
- updates.add(new Update(next, object, proxy));
- }
+ protected void buildUpdates(ControlModeRequest request, Builder<? super Update> updates) {
+ for(final EObject object : getAllPersistentSubunitContents(getRequest(), true)) {
+ // replace references to the element by a proxy
+ final CDOID proxy = CDOIDUtil.createExternal(CDOProxyManager.createPapyrusCDOURI(object));
+ for(EStructuralFeature.Setting next : getExternalCrossReferences(object)) {
+ updates.add(new ControlUpdate(next, object, proxy));
}
}
+ }
+ };
+ }
- this.updates = updates.build();
+ public ICommand getPreUncontrolCommand(ControlModeRequest request) {
+ return new AbstractCDOControlCommand(request) {
- applyUpdates();
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ objectsToClearResource = Lists.newArrayList();
- return CommandResult.newOKCommandResult();
+ return super.doExecuteWithResult(monitor, info);
}
@Override
- protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- IStatus result = super.doUndo(monitor, info);
+ protected void buildUpdates(ControlModeRequest request, Builder<? super Update> updates) {
+ for(final EObject object : getAllPersistentSubunitContents(getRequest(), false)) {
+ // replace proxy references to the element by the element or an updated proxy
+ // which will be located in the destination resource
+ Resource sourceResource = object.eResource();
+ final CDOID sourceProxy = CDOIDUtil.createExternal(CDOProxyManager.createPapyrusCDOURI(object));
+
+ Resource destinationResource = request.getTargetResource(sourceResource.getURI().fileExtension());
+ String proxyURI = CDOProxyManager.createPapyrusCDOURI(destinationResource.getURI(), object);
+ final CDOID proxy = CDOIDUtil.createExternal(proxyURI);
+
+ // internal cross-references within the unit won't be affected, as they are all moving
+ for(EStructuralFeature.Setting next : getExternalCrossReferences(object)) {
+ updates.add(new UncontrolUpdate(next, object, sourceProxy, destinationResource.getURI(), proxy));
+ }
- if(result.isOK()) {
- // setting proxies in the way we did is not recorded by EMF, so we have to undo it ourselves
- revertUpdates();
+ // upon removal from their resources, root elements will nonetheless retain a
+ // reference to the resource that formerly contained them. We need to force
+ // clearing of this reference in the CDO store
+ if(((InternalEObject)object).eDirectResource() != null) {
+ objectsToClearResource.add(object);
+ }
}
-
- return result;
}
+ };
+ }
+
+ public ICommand getPostUncontrolCommand(ControlModeRequest request) {
+ return new AbstractCDOControlCommand(request) {
@Override
- protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- IStatus result = super.doRedo(monitor, info);
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ CommandResult result = super.doExecuteWithResult(monitor, info);
- if(result.isOK()) {
- // setting proxies in the way we did is not recorded by EMF, so we have to redo it ourselves
- applyUpdates();
- }
+ objectsToClearResource = null;
return result;
}
- private void applyUpdates() {
- for(Update next : updates) {
- next.apply();
- }
- }
-
- private void revertUpdates() {
- for(ListIterator<Update> iter = updates.listIterator(updates.size()); iter.hasPrevious();) {
- iter.previous().revert();
+ @Override
+ protected void buildUpdates(ControlModeRequest request, Builder<? super Update> updates) {
+ for(EObject next : objectsToClearResource) {
+ // some former resource roots may not be reattached (e.g., SashWindowsMgr)
+ if(CDOUtil.getCDOObject(next).cdoState() != CDOState.TRANSIENT) {
+ updates.add(new ClearResourceUpdate(next));
+ }
}
}
};
@@ -173,20 +203,31 @@ public class CDOControlModeParticipant implements IControlCommandParticipant {
}
static boolean isPersistentObject(EObject object) {
- CDOObject cdo = CDOUtils.getCDOObject(object);
- return (cdo != null) && !TEMPORARY_ID_STATES.contains(cdo.cdoState());
+ boolean result = !object.eIsProxy();
+
+ if(result) {
+ CDOObject cdo = CDOUtils.getCDOObject(object);
+ result = (cdo != null) && !TEMPORARY_ID_STATES.contains(cdo.cdoState());
+ }
+
+ return result;
}
static boolean inSameUnit(EObject object, EObject other) {
+ // is the one object in the other's unit?
+ return inUnit(object, other.eResource().getURI());
+ }
+
+ static boolean inUnit(EObject object, URI unit) {
// get the extension-less model URIs
URI uri = object.eResource().getURI().trimFileExtension();
- URI otherURI = other.eResource().getURI().trimFileExtension();
+ URI otherURI = unit.trimFileExtension();
return uri.equals(otherURI);
}
- static Iterable<EObject> getAllPersistentSubunitContents(final ControlModeRequest request) {
- final URI base = request.getNewURI().trimFileExtension();
+ static Iterable<EObject> getAllPersistentSubunitContents(final ControlModeRequest request, boolean isControl) {
+ final URI base = isControl ? request.getNewURI().trimFileExtension() : request.getSourceURI().trimFileExtension();
Iterable<Resource> resources = filter(request.getModelSet().getResources(), new Predicate<Resource>() {
public boolean apply(Resource input) {
@@ -220,40 +261,64 @@ public class CDOControlModeParticipant implements IControlCommandParticipant {
// Nested types
//
- private static final class Update {
+ private static abstract class Update {
final EStructuralFeature.Setting setting;
+ final CDOStore store;
+
+ Update(EStructuralFeature.Setting setting) {
+ this.setting = setting;
+
+ InternalEObject owner = (InternalEObject)setting.getEObject();
+ CDOObject cdoOwner = CDOUtil.getCDOObject(owner);
+
+ InternalCDOView view = (InternalCDOView)cdoOwner.cdoView();
+ store = view.getStore();
+ }
+
+ Update(EObject object) {
+ this.setting = null;
+
+ CDOObject cdo = CDOUtil.getCDOObject(object);
+ CDOView view = cdo.cdoView();
+ this.store = (view instanceof InternalCDOView) ? ((InternalCDOView)view).getStore() : null;
+ }
+
+ abstract void apply();
+
+ abstract void revert();
+ }
+
+ private static final class ControlUpdate extends Update {
+
final EObject originalObject;
final CDOID proxy;
- final CDOStore store;
-
final int index;
- Update(EStructuralFeature.Setting setting, EObject originalObject, CDOID proxy) {
- this.setting = setting;
+ ControlUpdate(EStructuralFeature.Setting setting, EObject originalObject, CDOID proxy) {
+ super(setting);
this.originalObject = originalObject;
this.proxy = proxy;
EStructuralFeature feature = setting.getEStructuralFeature();
InternalEObject owner = (InternalEObject)setting.getEObject();
- CDOObject cdoOwner = CDOUtil.getCDOObject(owner);
-
- InternalCDOView view = (InternalCDOView)cdoOwner.cdoView();
- store = view.getStore();
if(!feature.isMany()) {
index = CDOStore.NO_INDEX;
} else {
- index = store.indexOf(owner, feature, originalObject);
+ // don't go directly to the store because it may have proxies.
+ // Use the resolved view in the EObject, instead
+ index = ((EList<?>)owner.eGet(feature)).indexOf(originalObject);
if(index < 0) {
Activator.log.error("Setting does not include the object being replaced by a proxy.", null);
}
}
}
+ @Override
void apply() {
EStructuralFeature feature = setting.getEStructuralFeature();
@@ -263,13 +328,163 @@ public class CDOControlModeParticipant implements IControlCommandParticipant {
}
}
+ @Override
+ void revert() {
+ EStructuralFeature feature = setting.getEStructuralFeature();
+
+ if(index >= 0 || !feature.isMany()) {
+ InternalEObject owner = (InternalEObject)setting.getEObject();
+ store.set(owner, feature, index, CDOUtils.getCDOID(originalObject));
+ }
+ }
+ }
+
+ private static final class UncontrolUpdate extends Update {
+
+ final EObject originalObject;
+
+ final CDOID originalProxy;
+
+ final URI destinationURI;
+
+ final CDOID destinationProxy;
+
+ final int index;
+
+ UncontrolUpdate(EStructuralFeature.Setting setting, EObject originalObject, CDOID originalProxy, URI destinationURI, CDOID destinationProxy) {
+ super(setting);
+ this.originalObject = originalObject;
+ this.originalProxy = originalProxy;
+ this.destinationURI = destinationURI;
+ this.destinationProxy = destinationProxy;
+
+ EStructuralFeature feature = setting.getEStructuralFeature();
+ InternalEObject owner = (InternalEObject)setting.getEObject();
+
+ if(!feature.isMany()) {
+ index = CDOStore.NO_INDEX;
+ } else {
+ // don't go directly to the store because it may have proxies.
+ // Use the resolved view in the EObject, instead
+ index = ((EList<?>)owner.eGet(feature)).indexOf(originalObject);
+ if(index < 0) {
+ Activator.log.error("Setting does not include the object being replaced by a proxy.", null);
+ }
+ }
+ }
+
+ @Override
+ void apply() {
+ EStructuralFeature feature = setting.getEStructuralFeature();
+
+ if((index >= 0) || !feature.isMany()) {
+ InternalEObject owner = (InternalEObject)setting.getEObject();
+
+ if(inUnit(owner, destinationURI)) {
+ // direct reference
+ store.set(owner, feature, index, CDOUtils.getCDOID(originalObject));
+ } else {
+ // proxy reference for cross-unit
+ store.set(owner, feature, index, destinationProxy);
+ }
+ }
+ }
+
+ @Override
void revert() {
EStructuralFeature feature = setting.getEStructuralFeature();
if(index >= 0 || !feature.isMany()) {
InternalEObject owner = (InternalEObject)setting.getEObject();
- store.set(owner, feature, index, originalObject);
+
+ // on reversion, we are processing only references that were external
+ // to the unit that was to be re-integrated, so necessarily all
+ // references must be set to the original proxies
+ store.set(owner, feature, index, originalProxy);
}
}
}
+
+ private static final class ClearResourceUpdate extends Update {
+
+ private CDOObject object;
+
+ ClearResourceUpdate(EObject object) {
+ super(object);
+
+ this.object = CDOUtil.getCDOObject(object);
+ }
+
+ @Override
+ void apply() {
+ InternalEObject object = (InternalEObject)CDOUtil.getEObject(this.object);
+ store.setContainer(object, null, object.eInternalContainer(), object.eContainerFeatureID());
+ }
+
+ @Override
+ void revert() {
+ // there is no need to revert clearing the resource reference; it will be
+ // reestablished naturally by undo of the base command
+ }
+ }
+
+ private static abstract class AbstractCDOControlCommand extends AbstractControlCommand {
+
+ AbstractCDOControlCommand(ControlModeRequest request) {
+ super("CDO aspects", Collections.emptyList(), request);
+ }
+
+ private List<Update> updates;
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ final ImmutableList.Builder<Update> updates = ImmutableList.builder();
+
+ buildUpdates(getRequest(), updates);
+
+ this.updates = updates.build();
+
+ applyUpdates();
+
+ return CommandResult.newOKCommandResult();
+ }
+
+ protected abstract void buildUpdates(ControlModeRequest request, ImmutableCollection.Builder<? super Update> updates);
+
+ @Override
+ protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ IStatus result = super.doUndo(monitor, info);
+
+ if(result.isOK()) {
+ // setting proxies in the way we did is not recorded by EMF, so we have to undo it ourselves
+ revertUpdates();
+ }
+
+ return result;
+ }
+
+ @Override
+ protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ IStatus result = super.doRedo(monitor, info);
+
+ if(result.isOK()) {
+ // setting proxies in the way we did is not recorded by EMF, so we have to redo it ourselves
+ applyUpdates();
+ }
+
+ return result;
+ }
+
+ private void applyUpdates() {
+ for(Update next : updates) {
+ next.apply();
+ }
+ }
+
+ private void revertUpdates() {
+ for(ListIterator<Update> iter = updates.listIterator(updates.size()); iter.hasPrevious();) {
+ iter.previous().revert();
+ }
+ }
+ };
}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/controlmode/CDOProxyManager.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/controlmode/CDOProxyManager.java
index 23d4ce3e150..7a424697ed0 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/controlmode/CDOProxyManager.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/controlmode/CDOProxyManager.java
@@ -79,12 +79,16 @@ public class CDOProxyManager {
}
public static String createPapyrusCDOURI(EObject object) {
+ return createPapyrusCDOURI(object.eResource().getURI(), object);
+ }
+
+ public static String createPapyrusCDOURI(URI resourceURI, EObject object) {
long oid = CDOIDUtil.getLong(CDOUtils.getCDOID(object));
CDOClassifierRef typeRef = new CDOClassifierRef(object.eClass());
CDOID oidWithTypeRef = CDOIDUtil.createLongWithClassifier(oid, typeRef);
StringBuilder result = new StringBuilder();
- result.append(object.eResource().getURI());
+ result.append(resourceURI);
result.append('#');
CDOIDUtil.write(result, oidWithTypeRef);

Back to the top