Package com.google.collide.dto

Examples of com.google.collide.dto.DocOp


    }
  }

  public static DocOp createFromTextChange(DocOpFactory factory, TextChange textChange) {

    DocOp docOp = factory.createDocOp();
    JsonArray<DocOpComponent> components = docOp.getComponents();

    int lineNumber = textChange.getLineNumber();
    if (lineNumber > 0) {
      components.add(factory.createRetainLine(lineNumber));
    }
View Full Code Here


   * @return composed doc op, or {@code null} if text changes array is empty
   * @throws Composer.ComposeException if error happens during composal
   */
  public static DocOp createFromTextChanges(DocOpFactory factory,
      JsonArray<TextChange> textChanges) throws Composer.ComposeException {
    DocOp result = null;
    for (int i = 0, n = textChanges.size(); i < n; i++) {
      TextChange textChange = textChanges.get(i);
      DocOp curOp = DocOpUtils.createFromTextChange(factory, textChange);
      result = result != null ? Composer.compose(factory, result, curOp) : curOp;
    }
    return result;
  }
View Full Code Here

  public static String toString(
      List<? extends DocOp> docOps, int firstIndex, int lastIndex, boolean verbose) {
    StringBuilder sb = new StringBuilder("[");
    for (int i = firstIndex; i <= lastIndex; i++) {
      DocOp docOp = docOps.get(i);
      if (docOp == null) {
        sb.append("<null doc op>,");
      } else {
        sb.append(toString(docOp, verbose)).append(',');
      }
View Full Code Here

  /**
   * Builds and returns the document operation, and prepares the builder for
   * another building sequence.
   */
  public DocOp build() {
    DocOp op = capturer.getDocOp();
    createCapturer.run();
    return op;
  }
View Full Code Here

  /**
   * Inverts the given document operation.
   */
  public static DocOp invert(DocOpFactory factory, DocOp docOp) {
    DocOp invertedDocOp = factory.createDocOp();
    JsonArray<DocOpComponent> invertedDocOpComponents = invertedDocOp.getComponents();

    JsonArray<DocOpComponent> components = docOp.getComponents();
    for (int i = 0, n = components.size(); i < n; i++) {
      invertedDocOpComponents.add(invertComponent(factory, components.get(i)));
    }
View Full Code Here

  /**
   * @param bypassPaused whether to process the doc op immediately even if
   *        {@link #pause()} has been called
   */
  void simulateOrderedDocOpReceived(ServerToClientDocOpImpl message, boolean bypassPaused) {
    DocOp docOp = message.getDocOp2();   
    onReceivedOrderedDocOp(message, docOp, bypassPaused);
  }
View Full Code Here

  boolean isMutatingDocument() {
    return isMutatingDocument;
  }

  void undo() {
    DocOp undoDocOp = undoManager.undo();
    if (undoDocOp == null) {
      return;
    }

    applyToDocument(undoDocOp);
View Full Code Here

  }

  void ensureQueuedDocOp() {
    if (fileConcurrencyController.getQueuedClientOpCount() == 0) {
      // There aren't any queued doc ops, create and send a noop doc op
      DocOp noopDocOp = new DocOpBuilder(ClientDocOpFactory.INSTANCE, false).retainLine(
          document.getLineCount()).build();
      fileConcurrencyController.consumeLocalDocOp(noopDocOp);
    }
  }
View Full Code Here

    applyToDocument(undoDocOp);
  }

  void redo() {
    DocOp redoDocOp = undoManager.redo();
    if (redoDocOp == null) {
      return;
    }

    applyToDocument(redoDocOp);
View Full Code Here

    /*
     * First step, build the bridge from the intended revision to the latest revision by composing
     * all of the doc ops between these ranges. This bridge will be used to update a client doc op
     * that's intended to be applied to a document in the past.
     */
    DocOp bridgeDocOp = null;
    int bridgeBeginIndex = intendedCcRevision + 1;
    int bridgeEndIndexInclusive = ccRevision;
    for (int i = bridgeBeginIndex; i <= bridgeEndIndexInclusive; i++) {
      DocOp curDocOp = docOpHistory.get(i).docOp;
      try {
        bridgeDocOp = bridgeDocOp == null ? curDocOp : Composer.compose(
            ServerDocOpFactory.INSTANCE, bridgeDocOp, curDocOp);
      } catch (ComposeException e) {
        throw newExceptionForConsumeWithoutLocking("Could not build bridge",
            e,
            intendedCcRevision,
            bridgeBeginIndex,
            bridgeEndIndexInclusive,
            docOps);
      }
    }

    /*
     * Second step, iterate through doc ops from the client and transform each against the bridge.
     * Take the server op result of the transformation and make that the new bridge. Record each
     * into our map that will be returned to the caller of this method.
     */
    SortedMap<Integer, AppliedDocOp> appliedDocOps = new TreeMap<Integer, AppliedDocOp>();
    for (int i = 0, n = docOps.size(); i < n; i++) {
      DocOp clientDocOp = docOps.get(i);

      if (bridgeDocOp != null) {
        try {
          OperationPair transformedPair =
              Transformer.transform(ServerDocOpFactory.INSTANCE, clientDocOp, bridgeDocOp);
View Full Code Here

TOP

Related Classes of com.google.collide.dto.DocOp

Copyright © 2018 www.massapicom. 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.