Package org.waveprotocol.wave.model.document.util

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


      // While the client libraries force a newline to be sent as the first
      // character we'll remove it here since the new blip we created already
      // contains a newline.
      content = content.substring(1);
    }
    XmlStringBuilder builder = XmlStringBuilder.createText(content);
    LineContainers.appendToLastLine(newBlip.getContent(), builder);
  }
View Full Code Here


   */
  private void assertManifestXml(final String expected) {
    manifestDoc.with(new Action() {
      @Override
      public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) {
        XmlStringBuilder exp = XmlStringBuilder.createFromXmlString(expected);
        assertStructureEquivalent(exp.wrap("conversation"), doc);
      }
    });
  }
View Full Code Here

   * @param i The index at which to insert the tag.
   */
  public void addTag(String tagName, int i) {
    E node = getNthTagNode(i);
    El<N> point = Point.<N>inElement(doc.getDocumentElement(), node);
    XmlStringBuilder xml = getXmlFor(tagName);
    doc.insertXml(point, xml);
  }
View Full Code Here

    } else {
      Element element = modifyAction.getElement(valueIndex);
      if (element != null) {
        if (element.isGadget()) {
          Gadget gadget = (Gadget) element;
          XmlStringBuilder xml =
              GadgetXmlUtil.constructXml(gadget.getUrl(), "", gadget.getAuthor(), null,
                  gadget.getProperties());
          // TODO (Yuri Z.) Make it possible to specify a location to insert the
          // gadget and implement insertion at the specified location.
          LineContainers.appendLine(doc, xml);
View Full Code Here

            doc.emptyElement(child);
            Point<Doc.N> point = Point.<Doc.N> inElement(child, null);
            doc.insertText(point, val);
          }
        } else {
          XmlStringBuilder xml = GadgetXmlUtil.constructStateXml(property.getKey(), val);
          doc.insertXml(Point.<Doc.N> inElement(existingElement, null), xml);
        }
      }
    }
  }
View Full Code Here

        CollectionUtils.newArrayList(topBlip.getReplyThreads()));
  }

  public void testDeleteInlineReplyDeletesAnchor() {
    ConversationBlip blip = target.getRootThread().appendBlip();
    XmlStringBuilder xmlBefore = XmlStringBuilder.innerXml(blip.getContent());
    ConversationThread inlineReply = blip.addReplyThread(locateAfterLineElement(
        blip.getContent()));
    ConversationBlip inlineReplyBlip = inlineReply.appendBlip();

    inlineReplyBlip.delete();
View Full Code Here

   * @param state the initial gadget state.
   * @return content XML string for the gadget.
   */
  public static XmlStringBuilder constructXml(String url, String prefs, String author,
      @Nullable String[] categories, @Nullable Map<String, String> state) {
    final XmlStringBuilder builder = XmlStringBuilder.createEmpty();
    if (categories != null) {
      for (int i = 0; i < categories.length; ++i) {
        builder.append(
            XmlStringBuilder.createText("").wrap(
                CATEGORY_TAGNAME, KEY_ATTRIBUTE, categories[i]));
      }
    }
    if (state != null) {
      for (Map.Entry<String, String> entry : state.entrySet()) {
        builder.append(
            GadgetXmlUtil.constructStateXml(entry.getKey(), entry.getValue()));
      }
    }
    builder.wrap(
        TAGNAME,
        URL_ATTRIBUTE, url,
        TITLE_ATTRIBUTE, "",
        PREFS_ATTRIBUTE, prefs != null ? prefs : "",
        STATE_ATTRIBUTE, "",
View Full Code Here

    }
    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

        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

      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

TOP

Related Classes of org.waveprotocol.wave.model.document.util.XmlStringBuilder

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.