Examples of DocumentChangeMessage


Examples of org.eclipse.ecf.sync.doc.DocumentChangeMessage

    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);
View Full Code Here

Examples of org.eclipse.ecf.sync.doc.DocumentChangeMessage

   * transformRemoteChange(org.eclipse.ecf.sync.doc.IModelChangeMessage)
   */
  public IModelChange[] transformRemoteChange(IModelChange remoteChange) {
    if (!(remoteChange instanceof DocumentChangeMessage))
      return new IDocumentChange[0];
    final DocumentChangeMessage m = (DocumentChangeMessage) remoteChange;
    final List l = this.transformIncomingMessage(m);
    return (IDocumentChange[]) l.toArray(new IDocumentChange[] {});
  }
View Full Code Here

Examples of org.eclipse.ecf.sync.doc.DocumentChangeMessage

   * @see org.eclipse.ecf.sync.doc.IDocumentSynchronizationStrategy#registerLocalChange(org.eclipse.ecf.sync.doc.IDocumentChange)
   */
  public IModelChangeMessage[] registerLocalChange(IModelChange localChange) {
    if (localChange instanceof IDocumentChange) {
      IDocumentChange docChange = (IDocumentChange) localChange;
      return new IModelChangeMessage[] {new DocumentChangeMessage(docChange.getOffset(), docChange.getLengthOfReplacedText(), docChange.getText())};
    } else return new IModelChangeMessage[0];
  }
View Full Code Here

Examples of org.eclipse.ecf.sync.doc.DocumentChangeMessage

          remoteTransformedMsg.setOffset(remoteTransformedMsg.getOffset() - localAppliedMsg.getLengthOfReplacedText());
        } else if (remoteTransformedMsg.getOffset() <= (localAppliedMsg.getOffset() + localAppliedMsg.getLengthOfReplacedText())) {

          //TODO test this ^#$%^#$ case
          final DocumentChangeMessage deletionFirstMessage = new DocumentChangeMessage(localAppliedMsg.getOffset(), remoteTransformedMsg.getOffset() - localAppliedMsg.getOffset(), localAppliedMsg.getText());
          final ColaDocumentChangeMessage deletionFirstPart = new ColaDocumentChangeMessage(deletionFirstMessage, localAppliedMsg.getLocalOperationsCount(), localAppliedMsg.getRemoteOperationsCount());
          localAppliedMsg.addToSplitUpRepresentation(deletionFirstPart);

          final DocumentChangeMessage deletionSecondMessage = new DocumentChangeMessage(localAppliedMsg.getOffset() + remoteTransformedMsg.getLengthOfInsertedText(), localAppliedMsg.getLengthOfReplacedText() - deletionFirstPart.getLengthOfReplacedText(), localAppliedMsg.getText());
          final ColaDocumentChangeMessage deletionSecondPart = new ColaDocumentChangeMessage(deletionSecondMessage, localAppliedMsg.getLocalOperationsCount(), localAppliedMsg.getRemoteOperationsCount());
          localAppliedMsg.addToSplitUpRepresentation(deletionSecondPart);

          localAppliedMsg.setSplitUp(true);
View Full Code Here

Examples of org.eclipse.ecf.sync.doc.DocumentChangeMessage

          //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()) { //TODO optimize away, "if" just here for clarity, "else" would be enough
          //remote deletion reaches into local insertion and potentially over it
          //remote deletion needs to be split apart
          final DocumentChangeMessage deletionFirstMsg = new DocumentChangeMessage(remoteTransformedMsg.getOffset(), localAppliedMsg.getOffset() - remoteTransformedMsg.getOffset(), remoteTransformedMsg.getText());
          final ColaDocumentChangeMessage deletionFirstPart = new ColaDocumentChangeMessage(deletionFirstMsg, remoteTransformedMsg.getLocalOperationsCount(), remoteTransformedMsg.getRemoteOperationsCount());
          remoteTransformedMsg.addToSplitUpRepresentation(deletionFirstPart);

          final DocumentChangeMessage deletionSecondMsg = new DocumentChangeMessage(localAppliedMsg.getOffset() + localAppliedMsg.getLengthOfInsertedText(), remoteTransformedMsg.getLengthOfReplacedText() - deletionFirstPart.getLengthOfReplacedText(), remoteTransformedMsg.getText());
          final ColaDocumentChangeMessage deletionSecondPart = new ColaDocumentChangeMessage(deletionSecondMsg, remoteTransformedMsg.getLocalOperationsCount(), remoteTransformedMsg.getRemoteOperationsCount());
          remoteTransformedMsg.addToSplitUpRepresentation(deletionSecondPart);

          remoteTransformedMsg.setSplitUp(true);
View Full Code Here

Examples of org.eclipse.ecf.sync.doc.DocumentChangeMessage

  private IDocumentChange getLocalDocumentChange() {
    final int offset = random.nextInt(document.getLength());
    final int length = random.nextInt(2);
    final String text = (random.nextInt(2) == 0) ? "" : ">";
    return new DocumentChangeMessage(offset, length, text);
  }
View Full Code Here

Examples of org.eclipse.ecf.sync.doc.DocumentChangeMessage

      String text = fDocument.get();
      String newText = ">";
      text = text.concat(newText);

      fDocument.set(text);
      IModelChange change = new DocumentChangeMessage(i + 150, newText.length(),  newText);

      IModelChangeMessage[] changes = initiator.registerLocalChange(change);

      getReceiverQueue().put(changes);
     
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.