Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 121326 Details for
Bug 234142
[modelsync] DocShare plug-in should be split into core/ui
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
fix for replacement message handling
234142.patch (text/plain), 8.75 KB, created by
Scott Lewis
on 2008-12-30 00:25:43 EST
(
hide
)
Description:
fix for replacement message handling
Filename:
MIME Type:
Creator:
Scott Lewis
Created:
2008-12-30 00:25:43 EST
Size:
8.75 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ecf.sync >Index: src/org/eclipse/ecf/internal/sync/doc/cola/ColaDocumentChangeMessage.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.sync/src/org/eclipse/ecf/internal/sync/doc/cola/ColaDocumentChangeMessage.java,v >retrieving revision 1.3 >diff -u -r1.3 ColaDocumentChangeMessage.java >--- src/org/eclipse/ecf/internal/sync/doc/cola/ColaDocumentChangeMessage.java 16 Oct 2008 08:32:39 -0000 1.3 >+++ src/org/eclipse/ecf/internal/sync/doc/cola/ColaDocumentChangeMessage.java 30 Dec 2008 05:22:52 -0000 >@@ -91,8 +91,17 @@ > > public String toString() { > final StringBuffer buf = new StringBuffer("ColaDocumentChangeMessage["); //$NON-NLS-1$ >- buf.append("text=").append(getText()).append(";offset=").append(getOffset()); //$NON-NLS-1$ //$NON-NLS-2$ >- buf.append(";length=").append(getLengthOfReplacedText()).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ >+ String tType = "undefined"; >+ if (transformType == 0) { >+ tType = "insert"; >+ } else if (transformType == 1) { >+ tType = "delete"; >+ } else if (transformType == 2) { >+ tType = "replace"; >+ } >+ buf.append("transformType="+tType); >+ buf.append(";offset=").append(getOffset()); //$NON-NLS-1$ //$NON-NLS-2$ >+ buf.append(";length=").append(getLengthOfReplacedText()).append(";text=").append(getText()).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ > buf.append(";operationsCount[local=").append(getLocalOperationsCount()); //$NON-NLS-1$ > buf.append(";remote=").append(getRemoteOperationsCount()).append("]]"); //$NON-NLS-1$//$NON-NLS-2$ > return buf.toString(); >Index: src/org/eclipse/ecf/internal/sync/doc/cola/ColaSynchronizationStrategy.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.sync/src/org/eclipse/ecf/internal/sync/doc/cola/ColaSynchronizationStrategy.java,v >retrieving revision 1.5 >diff -u -r1.5 ColaSynchronizationStrategy.java >--- src/org/eclipse/ecf/internal/sync/doc/cola/ColaSynchronizationStrategy.java 21 Oct 2008 23:09:08 -0000 1.5 >+++ src/org/eclipse/ecf/internal/sync/doc/cola/ColaSynchronizationStrategy.java 30 Dec 2008 05:22:52 -0000 >@@ -11,6 +11,7 @@ > > package org.eclipse.ecf.internal.sync.doc.cola; > >+import java.util.ArrayList; > import java.util.HashMap; > import java.util.Iterator; > import java.util.LinkedList; >@@ -35,7 +36,7 @@ > public class ColaSynchronizationStrategy implements IModelSynchronizationStrategy { > > // <ColaDocumentChangeMessage> >- private final LinkedList unacknowledgedLocalOperations; >+ private final List unacknowledgedLocalOperations; > private final boolean isInitiator; > private long localOperationsCount; > private long remoteOperationsCount; >@@ -51,10 +52,16 @@ > } > > public static ColaSynchronizationStrategy getInstanceFor(ID client, boolean isInitiator) { >- if (sessionStrategies.get(client) == null) { >- sessionStrategies.put(client, new ColaSynchronizationStrategy(isInitiator)); >+ ColaSynchronizationStrategy existingStrategy = (ColaSynchronizationStrategy) sessionStrategies.get(client); >+ if (existingStrategy != null) { >+ Boolean existingStrategyIsInitiator = new Boolean(existingStrategy.isInitiator); >+ if (existingStrategyIsInitiator.equals(new Boolean(isInitiator))) { >+ return existingStrategy; >+ } > } >- return (ColaSynchronizationStrategy) sessionStrategies.get(client); >+ existingStrategy = new ColaSynchronizationStrategy(isInitiator); >+ sessionStrategies.put(client, existingStrategy); >+ return existingStrategy; > } > > public static void cleanUpFor(ID client) { >@@ -64,18 +71,6 @@ > public static void dispose() { > sessionStrategies.clear(); > } >- >- public DocumentChangeMessage registerOutgoingMessage(DocumentChangeMessage localMsg) { >- Trace.entering(Activator.PLUGIN_ID, SyncDebugOptions.METHODS_ENTERING, this.getClass(), "registerOutgoingMessage", localMsg); //$NON-NLS-1$ >- final ColaDocumentChangeMessage colaMsg = new ColaDocumentChangeMessage(localMsg, localOperationsCount, remoteOperationsCount); >- if (!colaMsg.isReplacement()) { >- unacknowledgedLocalOperations.add(colaMsg); >- localOperationsCount++; >- } >- Trace.exiting(Activator.PLUGIN_ID, SyncDebugOptions.METHODS_EXITING, this.getClass(), "registerOutgoingMessage", colaMsg); //$NON-NLS-1$ >- return colaMsg; >- } >- > /** > * Handles proper transformation of incoming <code>ColaDocumentChangeMessage</code>s. > * Returned <code>DocumentChangeMessage</code>s can be applied directly to the >@@ -95,6 +90,7 @@ > transformedRemotes.add(transformedRemote); > > remoteOperationsCount++; >+ Trace.trace(Activator.PLUGIN_ID, "unacknowledgedLocalOperations="+unacknowledgedLocalOperations); > //this is where the concurrency algorithm is executed > if (!unacknowledgedLocalOperations.isEmpty()) {//Do not remove this. It is necessary. The following iterator does not suffice. > // remove operations from queue that have been implicitly >@@ -123,7 +119,7 @@ > // don't require to be transformed against > > if (!unacknowledgedLocalOperations.isEmpty()) { >- ColaDocumentChangeMessage localOp = (ColaDocumentChangeMessage) unacknowledgedLocalOperations.getFirst(); >+ ColaDocumentChangeMessage localOp = (ColaDocumentChangeMessage) unacknowledgedLocalOperations.get(0); > Assert.isTrue(transformedRemote.getRemoteOperationsCount() == localOp.getLocalOperationsCount()); > > for (final ListIterator unackOpsListIt = unacknowledgedLocalOperations.listIterator(); unackOpsListIt.hasNext();) { >@@ -196,17 +192,33 @@ > * @see org.eclipse.ecf.sync.doc.IDocumentSynchronizationStrategy#registerLocalChange(org.eclipse.ecf.sync.doc.IModelChange) > */ > public IModelChangeMessage[] registerLocalChange(IModelChange localChange) { >+ List results = new ArrayList(); > Trace.entering(Activator.PLUGIN_ID, SyncDebugOptions.METHODS_ENTERING, this.getClass(), "registerLocalChange", localChange); //$NON-NLS-1$ > if (localChange instanceof IDocumentChange) { > final IDocumentChange docChange = (IDocumentChange) localChange; > final ColaDocumentChangeMessage colaMsg = new ColaDocumentChangeMessage(new DocumentChangeMessage(docChange.getOffset(), docChange.getLengthOfReplacedText(), docChange.getText()), localOperationsCount, remoteOperationsCount); >+ // If not replacement, we simply add to unacknowledgedLocalOperations and add message >+ // to results > if (!colaMsg.isReplacement()) { > unacknowledgedLocalOperations.add(colaMsg); > localOperationsCount++; >+ results.add(colaMsg); >+ } else { >+ // It *is a replacement message, so we add both a delete and an insert message >+ // First create/add a delete message (text set to "")... >+ ColaDocumentChangeMessage delMsg = new ColaDocumentChangeMessage(new DocumentChangeMessage(docChange.getOffset(),docChange.getLengthOfReplacedText(),""), localOperationsCount, remoteOperationsCount); >+ unacknowledgedLocalOperations.add(delMsg); >+ localOperationsCount++; >+ results.add(delMsg); >+ // Then create/add the insert message (length set to 0) >+ ColaDocumentChangeMessage insMsg = new ColaDocumentChangeMessage(new DocumentChangeMessage(docChange.getOffset(),0,docChange.getText()), localOperationsCount, remoteOperationsCount); >+ unacknowledgedLocalOperations.add(insMsg); >+ localOperationsCount++; >+ results.add(insMsg); > } > Trace.exiting(Activator.PLUGIN_ID, SyncDebugOptions.METHODS_EXITING, this.getClass(), "registerLocalChange", colaMsg); //$NON-NLS-1$ >- return new IModelChangeMessage[] {colaMsg}; >- } else return new IModelChangeMessage[0]; >+ } >+ return (IModelChangeMessage[]) results.toArray(new IModelChangeMessage[] {}); > } > > /* (non-Javadoc) >Index: src/org/eclipse/ecf/sync/doc/DocumentChangeMessage.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.sync/src/org/eclipse/ecf/sync/doc/DocumentChangeMessage.java,v >retrieving revision 1.6 >diff -u -r1.6 DocumentChangeMessage.java >--- src/org/eclipse/ecf/sync/doc/DocumentChangeMessage.java 27 Nov 2008 18:16:26 -0000 1.6 >+++ src/org/eclipse/ecf/sync/doc/DocumentChangeMessage.java 30 Dec 2008 05:22:52 -0000 >@@ -108,8 +108,8 @@ > > public String toString() { > final StringBuffer buf = new StringBuffer("DocumentChangeMessage["); //$NON-NLS-1$ >- buf.append("text=").append(text).append(";offset=").append(offset); //$NON-NLS-1$ //$NON-NLS-2$ >- buf.append(";length=").append(length).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ >+ buf.append("offset=").append(offset); //$NON-NLS-1$ //$NON-NLS-2$ >+ buf.append(";length=").append(length).append(";text=").append(text).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ > return buf.toString(); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 234142
:
113329
|
113383
|
113394
| 121326