Package org.waveprotocol.wave.model.document.operation

Examples of org.waveprotocol.wave.model.document.operation.Nindo$DeleteElementStart


  private WaveletOperation makeBlipContentOp(String id, long timestamp) throws OperationException {
    if (!docs.containsKey(id)) {
      docs.put(id, DocProviders.POJO.parse("<x></x>"));
    }
    Nindo nindo = Nindo.insertCharacters(1, "hi");
    DocOp op = docs.get(id).consumeAndReturnInvertible(nindo);
    return new WaveletBlipOperation(id, new BlipContentOperation(getContext(timestamp), op));
  }
View Full Code Here


  /**
   * Applies an insertion to the document.
   */
  public void doInsert(int offset, String chars) throws OperationException {
    Nindo nindo = Nindo.insertCharacters(offset, chars);
    DocOp op = doc.consumeAndReturnInvertible(nindo);

    BlipContentOperation blipOp = new BlipContentOperation(
        new WaveletOperationContext(participantId, 0L, 1), op);
    WaveletBlipOperation wop = new WaveletBlipOperation("blip id", blipOp);
View Full Code Here

      DocOp op = RandomDocOpGenerator.generate(random, params,
          // FIXME(ohler): Add back schema constraints
          // DocumentOperationValidator.DEFAULT_BLIP_SCHEMA_CONSTRAINTS,
          autoDoc);

      Nindo nindo = null;
      String finalXml = null;
      DocOp docOpCopy = null;
      DocInitialization docAsOp = null;

      try {
View Full Code Here

    IsDocOp[] docs = new IsDocOp[NUM_OPS];

    for (int i = 0; i < NUM_OPS; i++) {
      System.out.print(".");
      if (testAsOperation) {
        Nindo nindo = RandomNindoGenerator.generate(random, params, constraints, doc);
        DocOp docOp = doc.consumeAndReturnInvertible(nindo);
        docs[i] = DocProviders.POJO.build(doc.asOperation(), constraints);
      } else if (testNindos) {
        Nindo nindo = RandomNindoGenerator.generate(random, params, constraints, doc);
        DocOp docOp = doc.consumeAndReturnInvertible(nindo);
        nindos[i] = nindo;
        nindos[NUM_OPS * 2 - i - 1] = Nindo.fromDocOp(DocOpInverter.invert(docOp), true);
      } else {
        DocOp docOp = RandomDocOpGenerator.generate(random, params, //constraints,
View Full Code Here

      IndexedDocument<Node, Element, Text> copy = DocProviders.POJO.build(indexedDoc.asOperation(),
          DocumentSchema.NO_SCHEMA_CONSTRAINTS);
      copy.consume(indexedDoc.asOperation());

      for (int i = 0; i < testConfiguration.numInitialMutations; i++) {
        Nindo nindo = RandomNindoGenerator.generate(random, STRUCT_PARAMS,
            ConversationSchemas.BLIP_SCHEMA_CONSTRAINTS, copy);
        DocOp op = indexedDoc.consumeAndReturnInvertible(nindo);
        copy.consume(op);
      }

      for (int i = 0; i < testConfiguration.numAnnotationMutations; i++) {
        try {
          Nindo nindo = RandomNindoGenerator.generate(random, ANNO_PARAMS,
              ConversationSchemas.BLIP_SCHEMA_CONSTRAINTS, copy);
          DocOp op = indexedDoc.consumeAndReturnInvertible(nindo);
//          System.out.println("\n\n");
//          System.out.println(nindo);
//          System.out.println(op);
//          System.out.println(copy);
//          System.out.println(CollectionUtils.join('\n', "INLINE: ",
//              DocOpUtil.visualiseOpWithDocument(copy.asOperation(), op)));
          copy.consume(op);
          checkRender(cxt);
        } catch (RuntimeException e) {
          System.out.println("During annotation mutations: " + i + " " + e);
          throw e;
        }
      }

      for (int i = 0; i < testConfiguration.numGeneralMutations; i++) {
        try {
          Nindo nindo = RandomNindoGenerator.generate(random, GENERAL_PARAMS,
              ConversationSchemas.BLIP_SCHEMA_CONSTRAINTS, copy);
          DocOp op = indexedDoc.consumeAndReturnInvertible(nindo);
          copy.consume(op);
          checkRender(cxt);
        } catch (RuntimeException e) {
View Full Code Here

    Nindo.Builder builder = new Nindo.Builder();
    builder.skip(3);
    new RichTextMutationBuilder().applyMutations(tokens, builder, doc, insertAt.getContainer());

    Nindo nindo = builder.build();
    try {
      doc.consumeAndReturnInvertible(nindo);
    } catch (OperationException e) {
      fail("Operation Exception " + e);
    }
View Full Code Here

            token(end)));
  }

  private void verifyMutationsLC(String opString, RichTextTokenizer tokens) {
    Pair<Nindo, IndexedDocument<Node, Element, Text>> result = applyTokensToEmptyDoc(tokens);
    Nindo nindo = Nindo.shift(-3, result.first);
    if (!opString.equals(nindo.toString())) {
      System.out.println("ACTUAL: " + nindo);
      System.out.println("EXPECT: " + opString);
      throw new AssertionError(opString + ", " + nindo);
    }
    assertEquals(opString, nindo.toString());
  }
View Full Code Here

   * Returns a randomly-generated document mutation based on the given document,
   * parameters, and schema.
   */
  public static Nindo generate(RandomProvider r, Parameters p,
      DocumentSchema s, IndexedDocument<Node, Element, Text> doc) {
    Nindo m = new Generator(r, p, s, doc).generate();
    ViolationCollector v = NindoValidator.validate(doc, m, s);
    assert !v.isIllFormed();
    assert p.getValidity() == v.isValid();
    return m;
  }
View Full Code Here

        LOG.trace().log("time taken: " + timeTaken);

        // handle the end of annotations
        annotationLogic.unstripKeys(builder, modified.keySet(), CollectionUtils.createStringSet());
        builder.finish();
        Nindo nindo = builder.build();

        try {
          validator.maybeThrowOperationExceptionFor(nindo);

          int locationAfter = destDoc.getLocation(insertAt) + createdFromXmlString.getLength();
          destOperationSequencer.begin();
          destOperationSequencer.consume(nindo);
          destOperationSequencer.end();
          aggressiveSelectionHelper.setCaret(locationAfter);

          LOG.trace().log("annotations: " + String.valueOf(annotations));
          if (annotations != null && !annotations.isEmpty()) {
            List<RangedAnnotation<String>> deserialize =
                AnnotationSerializer.deserialize(annotations);
            for (RangedAnnotation<String> ann : deserialize) {
              destDoc.setAnnotation(pos + ann.start(), pos + ann.end(), ann.key(), ann.value());
              LOG.trace().log(
                  "pos: " + pos + "start: " + (pos + ann.start()) + " end: " + (pos + ann.end())
                      + " key: " + ann.key() + " value: " + ann.value());
            }
          }
        } catch (OperationException e) {
          LOG.error().log("Semantic paste failed");
          // Restore caret
          aggressiveSelectionHelper.setCaret(insertAt);
        }
      }
    } else {
      instrumentor.record(Action.CLIPBOARD_PASTE_FROM_OUTSIDE);

      // initialize tokenizer and builder
      RichTextTokenizer tokenizer = createTokenizer(srcContainer);
      Builder builder = at(pos);

      // handle annotation starts
      StringMap<String> modified = annotationLogic.stripKeys(
          destDoc, pos, cursorBias, ContentType.RICH_TEXT, builder);

      // parse the tokens and apply ops
      RichTextMutationBuilder mutationBuilder = new RichTextMutationBuilder(modified);
      ReadableStringSet affectedKeys =
          mutationBuilder.applyMutations(tokenizer, builder, destDoc, insertAt.getContainer());

      // close annotations and finish
      annotationLogic.unstripKeys(builder, modified.keySet(), affectedKeys);
      builder.finish();
      Nindo nindo = builder.build();

      try {
        validator.maybeThrowOperationExceptionFor(nindo);

        destOperationSequencer.begin();
View Full Code Here

        LOG.trace().log("time taken: " + timeTaken);

        // handle the end of annotations
        annotationLogic.unstripKeys(builder, modified.keySet(), CollectionUtils.createStringSet());
        builder.finish();
        Nindo nindo = builder.build();

        try {
          validator.maybeThrowOperationExceptionFor(nindo);

          int locationAfter = destDoc.getLocation(insertAt) + createdFromXmlString.getLength();
          destOperationSequencer.begin();
          destOperationSequencer.consume(nindo);
          destOperationSequencer.end();
          aggressiveSelectionHelper.setCaret(locationAfter);

          LOG.trace().log("annotations: " + String.valueOf(annotations));
          if (annotations != null && !annotations.isEmpty()) {
            List<RangedAnnotation<String>> deserialize =
                AnnotationSerializer.deserialize(annotations);
            for (RangedAnnotation<String> ann : deserialize) {
              destDoc.setAnnotation(pos + ann.start(), pos + ann.end(), ann.key(), ann.value());
              LOG.trace().log(
                  "pos: " + pos + "start: " + (pos + ann.start()) + " end: " + (pos + ann.end())
                      + " key: " + ann.key() + " value: " + ann.value());
            }
          }
        } catch (OperationException e) {
          LOG.error().log("Semantic paste failed");
          // Restore caret
          aggressiveSelectionHelper.setCaret(insertAt);
        }
      }
    } else {
      instrumentor.record(Action.CLIPBOARD_PASTE_FROM_OUTSIDE);

      // initialize tokenizer and builder
      RichTextTokenizer tokenizer = createTokenizer(srcContainer);
      Builder builder = at(pos);

      // handle annotation starts
      StringMap<String> modified = annotationLogic.stripKeys(
          destDoc, pos, cursorBias, ContentType.RICH_TEXT, builder);

      // parse the tokens and apply ops
      RichTextMutationBuilder mutationBuilder = new RichTextMutationBuilder(modified);
      ReadableStringSet affectedKeys =
          mutationBuilder.applyMutations(tokenizer, builder, destDoc, insertAt.getContainer());

      // close annotations and finish
      annotationLogic.unstripKeys(builder, modified.keySet(), affectedKeys);
      builder.finish();
      Nindo nindo = builder.build();

      try {
        validator.maybeThrowOperationExceptionFor(nindo);

        destOperationSequencer.begin();
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.operation.Nindo$DeleteElementStart

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.