Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorisikm2008-06-15 07:43:07 +0000
committerisikm2008-06-15 07:43:07 +0000
commitf402159d5f62a0af93cee9e5a94ff528a487736b (patch)
tree3c78b23dff07601ddbca20e43f5270ff50c3989b
parentb124858ef2a33abaa75dab81bf2998d4a1d425f7 (diff)
downloadorg.eclipse.ecf-f402159d5f62a0af93cee9e5a94ff528a487736b.tar.gz
org.eclipse.ecf-f402159d5f62a0af93cee9e5a94ff528a487736b.tar.xz
org.eclipse.ecf-f402159d5f62a0af93cee9e5a94ff528a487736b.zip
renamed UpdateMessage getLength() to read getLengthOfReplacedText() - ColaInsertion relies on/uses this method and is affected of the renaming - working on fixind deletions to implement correct algorithm, previous implementation missed out on an important detail - this is WIP
-rw-r--r--framework/bundles/org.eclipse.ecf.docshare/src/org/eclipse/ecf/docshare/cola/ColaDeletion.java25
1 files changed, 20 insertions, 5 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 bd331b880..56ee0a059 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
@@ -36,11 +36,26 @@ public class ColaDeletion implements TransformationStrategy {
Trace.entering(Activator.PLUGIN_ID, DocshareDebugOptions.METHODS_ENTERING, this.getClass(), "getOperationalTransform", new Object[] {remoteIncomingMsg, localAppliedMsg, new Boolean(localMsgHighPrio)}); //$NON-NLS-1$
- // this transformation handles an incoming remote deletion that has to
- // be transformed against a locally operation
ColaUpdateMessage remoteTransformedMsg = remoteIncomingMsg;
- if (localAppliedMsg.isInsertion()) {
+ if (remoteTransformedMsg.isDeletion()) {
+
+ 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
+ remoteTransformedMsg.setLengthOfReplacedText((remoteTransformedMsg.getOffset() + remoteTransformedMsg.getLengthOfReplacedText()) - localAppliedMsg.getOffset());
+ localAppliedMsg.setLengthOfReplacedText((remoteTransformedMsg.getOffset() + remoteTransformedMsg.getLengthOfReplacedText()) - localAppliedMsg.getOffset());
+ localAppliedMsg.setOffset(remoteTransformedMsg.getOffset());
+ }//TODO remove this comment : too tired to continue 2008-06-15 00:42h
+ }
+ }
+ //--------------------------
+
+ /*if (localAppliedMsg.isInsertion()) {
// something has been inserted at a lower or same index --> move
// deletion right
if (localAppliedMsg.getOffset() <= remoteTransformedMsg.getOffset()) {
@@ -104,10 +119,10 @@ public class ColaDeletion implements TransformationStrategy {
}
remoteTransformedMsg.remoteOperationsCount += 1;
- localAppliedMsg.remoteOperationsCount += 1;
+ localAppliedMsg.remoteOperationsCount += 1;*/
Trace.exiting(Activator.PLUGIN_ID, DocshareDebugOptions.METHODS_EXITING, this.getClass(), "getOperationalTransform", null); //$NON-NLS-1$
- return null;
+ return remoteTransformedMsg;
}
}

Back to the top