Examples of XmlStringBuilder


Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

    }
    doc.deleteRange(xmlStart, xmlEnd);
  }

  public void insert(int pos, Element element) {
    XmlStringBuilder xml = ElementSerializer.apiElementToXml(element);
    int beforeSize = doc.size();
    Pair<Integer, Integer> where = locate(pos);
    int index = where.first;
    if (index == bits.size()) {
      // outside. append.
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

        if (selection == null) {
          errorLabel.setText("Don't know where to insert this");
          return;
        }

        XmlStringBuilder xml;
        try {
           xml = XmlStringBuilder.innerXml(DocProviders.POJO.parse(contentInput.getText()));
        } catch (RuntimeException e) {
          errorLabel.setText("Ill formed XML");
          return;
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

      if (!waveXml.isEmpty()) {
        instrumentor.record(Action.CLIPBOARD_PASTE_FROM_WAVE);

        // initialise the XML:
        Builder builder = at(pos);
        XmlStringBuilder createdFromXmlString =
            XmlStringBuilder.createFromXmlStringWithContraints(waveXml,
                PermittedCharacters.BLIP_TEXT);

        // Strip annotations based on behaviour:
        StringMap<String> modified = annotationLogic.stripKeys(
            destDoc, pos, cursorBias, ContentType.RICH_TEXT, builder);

        double startTime = Duration.currentTimeMillis();
        // apply xml change
        MutableDocumentImpl.appendXmlToBuilder(createdFromXmlString, builder);
        double timeTaken = Duration.currentTimeMillis() - startTime;
        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);
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

        selectionMatcher.getHtmlEnd());

    Point<ContentNode> normalizedStart = normalize(contentSelection.getFirst());
    Point<ContentNode> normalizedEnd = normalize(contentSelection.getSecond());

    final XmlStringBuilder xmlInRange;
    final List<RangedAnnotation<String>> normalizedAnnotations;
    if (useSemanticCopyPaste) {
      String debugString =
          "Start: " + contentSelection.getFirst() + " End: " + contentSelection.getSecond()
              + " docDebug: " + mutableDocument.toDebugString();
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

    N nearestCommonAncestor =
        DocHelper.nearestCommonAncestor(doc, start.getCanonicalNode(), end.getCanonicalNode());

    Range inclusion = new Range(doc.getLocation(start), doc.getLocation(end));

    XmlStringBuilder builder =
      XmlStringBuilder.createEmptyWithCharConstraints(PermittedCharacters.BLIP_TEXT);

    E asElement = doc.asElement(nearestCommonAncestor);
    if (asElement != null) {
      for (N child = doc.getFirstChild(asElement);
           child != null; child = doc.getNextSibling(child)) {
        builder.append(augmentBuilder(child, inclusion));
      }
      if (asElement != doc.getDocumentElement()
          && shouldInclude(inclusion, getNodeRange(asElement))) {
        builder.wrap(doc.getTagName(asElement),
            CollectionUtils.adaptStringMap(doc.getAttributes(asElement)));
      }
    } else {
      T asText = doc.asText(nearestCommonAncestor);
      int tStart = doc.getLocation(asText);
      String substring =
          doc.getData(asText).substring(inclusion.getStart() - tStart, inclusion.getEnd() - tStart);

      builder.appendText(substring);
    }
    return builder;
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

    return builder;
  }

  private XmlStringBuilder augmentBuilder(N node, Range inclusion) {
    Range nodeRange = getNodeRange(node);
    XmlStringBuilder builder = XmlStringBuilder.createEmpty();

    if (!shouldInclude(inclusion, nodeRange)) {
      return builder;
    }

    E asElement = doc.asElement(node);
    if (doc.asElement(node) != null) {
      for (N child = doc.getFirstChild(node); child != null; child = doc.getNextSibling(child)) {
        builder.append(augmentBuilder(child, inclusion));
      }
      builder.wrap(doc.getTagName(asElement),
          CollectionUtils.adaptStringMap(doc.getAttributes(asElement)));
    } else {
      T asText = doc.asText(node);
      int tStart = doc.getLocation(asText);
      String data = doc.getData(asText);
      int start = Math.max(0, inclusion.getStart() - tStart);
      int end = Math.min(data.length(), inclusion.getEnd() - tStart);

      builder.appendText(data.substring(start, end));
    }

    return builder;
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

    int from = -1;
    if (focusedRange != null) {
      from = focusedRange.getFocus();
    }
    if (url != null && !url.isEmpty()) {
      XmlStringBuilder xml = GadgetXmlUtil.constructXml(url, "", user.getAddress());
      CMutableDocument document = editor.getDocument();
      if (document == null) {
        return;
      }
      if (from != -1) {
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

                  } else {
                    // Still no selection.  Oh well, put it at the end.
                    point = doc.locate(doc.size() - 1);
                  }
                }
                XmlStringBuilder content = ImageThumbnail.constructXml(attachmentId, fileName);
                ImageThumbnailWrapper thumbnail = ImageThumbnailWrapper.of(doc.insertXml(point, content));
                thumbnail.setAttachmentId(attachmentId);
              }
            });
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

  public static boolean isNameValuePairElement(ContentNode node) {
    return EditorDocHelper.isNamedElement(node, NAMEVALUEPAIR_TAG);
  }

  public static XmlStringBuilder createXml(String url) {
    XmlStringBuilder builder = XmlStringBuilder.createEmpty();
    builder.wrap(TEMPLATE_TAG, URL_ATTRIBUTE, url);
    return builder;
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

      } else {
        // Still no selection.  Oh well, put it at the end.
        point = doc.locate(doc.size() - 1);
      }
    }
    XmlStringBuilder content = ImageThumbnail.constructXml(null, filename);
    thumbnail = ImageThumbnailWrapper.of(doc.insertXml(point, content));
  }
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.