Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorisikm2008-06-15 22:22:53 +0000
committerisikm2008-06-15 22:22:53 +0000
commit4cc72542d31e14b8493bfdd8d25b9076b73f2f73 (patch)
treee54e0831b1ca1fab9bc221dfa25c06674aebc70a
parent42f103f7e29b1129225ddb84f00af698f07d2c0d (diff)
downloadorg.eclipse.ecf-4cc72542d31e14b8493bfdd8d25b9076b73f2f73.tar.gz
org.eclipse.ecf-4cc72542d31e14b8493bfdd8d25b9076b73f2f73.tar.xz
org.eclipse.ecf-4cc72542d31e14b8493bfdd8d25b9076b73f2f73.zip
remote deletion handles conflict with locally applied insertion when deletion starts at a lower index/offset and extends into/over the insertion, by splitting the deletion up - ensures deletion of correct parts before and after the inserted, conflicting text - next up is adapting ColaSynchronizer to deal with this
-rw-r--r--framework/bundles/org.eclipse.ecf.docshare/src/org/eclipse/ecf/docshare/cola/ColaDeletion.java19
1 files changed, 15 insertions, 4 deletions
diff --git a/framework/bundles/org.eclipse.ecf.docshare/src/org/eclipse/ecf/docshare/cola/ColaDeletion.java b/framework/bundles/org.eclipse.ecf.docshare/src/org/eclipse/ecf/docshare/cola/ColaDeletion.java
index 6e7377353..fe5d11c4d 100644
--- a/framework/bundles/org.eclipse.ecf.docshare/src/org/eclipse/ecf/docshare/cola/ColaDeletion.java
+++ b/framework/bundles/org.eclipse.ecf.docshare/src/org/eclipse/ecf/docshare/cola/ColaDeletion.java
@@ -12,6 +12,7 @@
package org.eclipse.ecf.docshare.cola;
import org.eclipse.ecf.core.util.Trace;
+import org.eclipse.ecf.docshare.messages.UpdateMessage;
import org.eclipse.ecf.internal.docshare.Activator;
import org.eclipse.ecf.internal.docshare.DocshareDebugOptions;
@@ -116,12 +117,22 @@ public class ColaDeletion implements TransformationStrategy {
//remote remains unchanged, deletion happens fully before local insertion
//local insertion needs to be moved left by full length of deletion
localAppliedMsg.setOffset(localAppliedMsg.getOffset() - remoteTransformedMsg.getLengthOfReplacedText());
- } else if ((remoteTransformedMsg.getOffset() + remoteTransformedMsg.getLengthOfReplacedText()) >= localAppliedMsg.getOffset()) {
+ } else if ((remoteTransformedMsg.getOffset() + remoteTransformedMsg.getLengthOfReplacedText()) >= localAppliedMsg.getOffset()) { //TODO optimize away, "if" just here for clarity, "else" would be enough
//remote deletion reaches into local insertion and potentially over it
- //local insertion needs to be moved left by overlap
//remote deletion needs to be split apart
- //TODO needs to be implemented and requires appropriate modification in ColaSynchronizer
- throw new IllegalArgumentException("NOT IMPLEMENTED OPERATIONAL TRANSFORM");
+ UpdateMessage deletionFirstMsg = new UpdateMessage(remoteTransformedMsg.getOffset(), localAppliedMsg.getOffset() - remoteTransformedMsg.getOffset(), remoteTransformedMsg.getText());
+ ColaUpdateMessage deletionFirstPart = new ColaUpdateMessage(deletionFirstMsg, remoteTransformedMsg.getLocalOperationsCount(), remoteTransformedMsg.getRemoteOperationsCount());
+ remoteTransformedMsg.addToSplitUpRepresentation(deletionFirstPart);
+
+ UpdateMessage deletionSecondMsg = new UpdateMessage(localAppliedMsg.getOffset() + localAppliedMsg.getLengthOfInsertedText(), remoteTransformedMsg.getLengthOfReplacedText() - deletionFirstPart.getLengthOfReplacedText(), remoteTransformedMsg.getText());
+ ColaUpdateMessage deletionSecondPart = new ColaUpdateMessage(deletionSecondMsg, remoteTransformedMsg.getLocalOperationsCount(), remoteTransformedMsg.getRemoteOperationsCount());
+ remoteTransformedMsg.addToSplitUpRepresentation(deletionSecondPart);
+
+ remoteTransformedMsg.setSplitUp(true);
+
+ //local insertion needs to be moved left by overlap
+ localAppliedMsg.setOffset(remoteTransformedMsg.getOffset());
+
}
} else if (remoteTransformedMsg.getOffset() >= localAppliedMsg.getOffset()) {
//remote del needs to be moved right by full length of insertion

Back to the top