Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorisikm2008-06-15 12:39:10 +0000
committerisikm2008-06-15 12:39:10 +0000
commit334959402c95e159868cda435a30716d3c4d36b4 (patch)
treea7d74df8c030298b5899f993d2cd0bc53f6095e0
parent0fb6f45c50f7a46baa425ec430efc1410c8cb25c (diff)
downloadorg.eclipse.ecf-334959402c95e159868cda435a30716d3c4d36b4.tar.gz
org.eclipse.ecf-334959402c95e159868cda435a30716d3c4d36b4.tar.xz
org.eclipse.ecf-334959402c95e159868cda435a30716d3c4d36b4.zip
fixed deletions to properly apply algorithm on deletion vs. deletion transformations - next up are changes to ColaDeletion and ColaInsertion to deal with transformations involving one operation from each class
-rw-r--r--framework/bundles/org.eclipse.ecf.docshare/src/org/eclipse/ecf/docshare/cola/ColaDeletion.java62
1 files changed, 60 insertions, 2 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 56ee0a059..b3fed71d6 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
@@ -39,18 +39,76 @@ public class ColaDeletion implements TransformationStrategy {
ColaUpdateMessage remoteTransformedMsg = remoteIncomingMsg;
if (remoteTransformedMsg.isDeletion()) {
+ final int noOpLength = 0;
if (remoteTransformedMsg.getOffset() < localAppliedMsg.getOffset()) {
+
if ((remoteTransformedMsg.getOffset() + remoteTransformedMsg.getLengthOfReplacedText()) < localAppliedMsg.getOffset()) {
+
//no overlap - remote OK as is, local needs modification
localAppliedMsg.setOffset(localAppliedMsg.getOffset() - remoteTransformedMsg.getLengthOfReplacedText());
+
} else if ((remoteTransformedMsg.getOffset() + remoteTransformedMsg.getLengthOfReplacedText()) < (localAppliedMsg.getOffset() + localAppliedMsg.getLengthOfReplacedText())) {
+
//remote del at lower index reaches into locally applied del, local del reaches further out
- //shorten remote del appropriately, move and shorten local del left
+ //--> shorten remote del appropriately, move and shorten local del left
remoteTransformedMsg.setLengthOfReplacedText((remoteTransformedMsg.getOffset() + remoteTransformedMsg.getLengthOfReplacedText()) - localAppliedMsg.getOffset());
localAppliedMsg.setLengthOfReplacedText((remoteTransformedMsg.getOffset() + remoteTransformedMsg.getLengthOfReplacedText()) - localAppliedMsg.getOffset());
+ localAppliedMsg.setOffset(remoteTransformedMsg.getOffset());//TODO verify!
+
+ } else if ((remoteTransformedMsg.getOffset() + remoteTransformedMsg.getLengthOfReplacedText()) >= (localAppliedMsg.getOffset() + localAppliedMsg.getLengthOfReplacedText())) {
+
+ //remote del at lower index, remote del fully extends over local del
+ //--> shorten remote by local.lengthOfReplacedText, make local no-op
+ remoteTransformedMsg.setLengthOfReplacedText(remoteTransformedMsg.getLengthOfReplacedText() - localAppliedMsg.getLengthOfReplacedText());
+ //TODO verify whether this is equivalent to setting no-op, otherwise declare a noop boolean field for ColaDeletions
localAppliedMsg.setOffset(remoteTransformedMsg.getOffset());
- }//TODO remove this comment : too tired to continue 2008-06-15 00:42h
+ localAppliedMsg.setLengthOfReplacedText(noOpLength);
+ }
+ } else if (remoteTransformedMsg.getOffset() == localAppliedMsg.getOffset()) {
+
+ if ((remoteTransformedMsg.getOffset() + remoteTransformedMsg.getLengthOfReplacedText()) < (localAppliedMsg.getOffset() + localAppliedMsg.getLengthOfReplacedText())) {
+ //start indices are equal, remote is shorter --> make remote no-op
+ remoteTransformedMsg.setLengthOfReplacedText(noOpLength);
+ //--> shorten localOp to only delete non-overlapping region
+ localAppliedMsg.setLengthOfReplacedText(localAppliedMsg.getLengthOfReplacedText() - remoteTransformedMsg.getLengthOfReplacedText());
+ } else if ((remoteTransformedMsg.getOffset() + remoteTransformedMsg.getLengthOfReplacedText()) == (localAppliedMsg.getOffset() + localAppliedMsg.getLengthOfReplacedText())) {
+ //same endIndex, i.e. same deletion
+ //--> make remote op be no-op
+ remoteTransformedMsg.setLengthOfReplacedText(noOpLength);
+ //--> make local op appear as no-op
+ localAppliedMsg.setLengthOfReplacedText(noOpLength);
+ } else if ((remoteTransformedMsg.getOffset() + remoteTransformedMsg.getLengthOfReplacedText()) > (localAppliedMsg.getOffset() + localAppliedMsg.getLengthOfReplacedText())) {
+ //remote del extends over local del
+ //-->shorten remote del by length of local del, index/offset does not need to be updated
+ remoteTransformedMsg.setLengthOfReplacedText(remoteTransformedMsg.getLengthOfReplacedText() - localAppliedMsg.getLengthOfReplacedText());
+ //-->make local del appear as no-op
+ localAppliedMsg.setLengthOfReplacedText(noOpLength);
+ }
+ } else if (remoteTransformedMsg.getOffset() > localAppliedMsg.getOffset()) {
+
+ if (remoteTransformedMsg.getOffset() > (localAppliedMsg.getOffset() + localAppliedMsg.getLengthOfReplacedText())) {
+
+ //move remote deletion left by length of local deletion
+ remoteTransformedMsg.setOffset(remoteTransformedMsg.getOffset() - localAppliedMsg.getLengthOfReplacedText());
+
+ } else if ((remoteTransformedMsg.getOffset() + remoteTransformedMsg.getLengthOfReplacedText()) < (localAppliedMsg.getOffset() + localAppliedMsg.getLengthOfReplacedText())) {
+
+ //remote is fully contained in/overlapping with local del
+ //--> remote is no-op
+ remoteTransformedMsg.setLengthOfReplacedText(noOpLength);
+ //-->local needs to be shortened by length of remote
+ localAppliedMsg.setLengthOfReplacedText(localAppliedMsg.getLengthOfReplacedText() - remoteTransformedMsg.getLengthOfReplacedText());
+
+ } else if (remoteTransformedMsg.getOffset() < (localAppliedMsg.getOffset() + localAppliedMsg.getLengthOfReplacedText())) {
+
+ //remote del starts within local del, but extends further
+ //-->shorten remote by overlap and move left to index of local del
+ remoteTransformedMsg.setLengthOfReplacedText(remoteTransformedMsg.getLengthOfReplacedText() - (localAppliedMsg.getOffset() + localAppliedMsg.getLengthOfReplacedText()) - remoteTransformedMsg.getOffset());
+ remoteTransformedMsg.setOffset(localAppliedMsg.getOffset());
+ //-->shorten local applied message
+ localAppliedMsg.setLengthOfReplacedText(localAppliedMsg.getLengthOfReplacedText() - (localAppliedMsg.getOffset() + localAppliedMsg.getLengthOfReplacedText()) - remoteTransformedMsg.getOffset());
+ }
}
}
//--------------------------

Back to the top