Package org.waveprotocol.wave.model.document

Examples of org.waveprotocol.wave.model.document.Document


    String resultXml = ElementSerializer.apiElementToXml(element).getXmlString();
    assertEquals(xml, resultXml);
  }

  private static Element createApiElementFromXml(String xml, Wavelet wavelet) {
    Document document = BasicFactories.documentProvider().parse(
        LineContainers.debugContainerWrap(xml));
    Map<Integer, Element> elements = ElementSerializer.serialize(document, wavelet);
    assertEquals(2, elements.size());
    return elements.get(1);
  }
View Full Code Here


class Util {
  private static final Logger log = Logger.getLogger(Util.class.getName());

  static String extractTitle(WaveletDataImpl conv) {
    checkNotNull(conv, "Null conv");
    Document manifest = getDoc(conv, IdConstants.MANIFEST_DOCUMENT_ID);
    if (manifest == null) {
      return "";
    }
    E blipElem = DocHelper.getElementWithTagName(manifest, "blip");
    if (blipElem == null) {
      return "";
    }
    String rootBlipId = manifest.getAttribute(blipElem, "id");

    Document rootDoc = getDoc(conv, rootBlipId);
    if (rootDoc == null) {
      return "";
    }

    String title = TitleHelper.extractTitle(rootDoc).trim();
View Full Code Here

   * @param sourceWavelet the source wavelet
   * @param destWavelet the destination wavelet
   * @param docId the id of the document to copy
   */
  public static void copyDocument(Wavelet sourceWavelet, Wavelet destWavelet, String docId) {
    Document document = sourceWavelet.getDocument(docId);
    DocInitialization docInit = document.toInitialization();
    // TODO(user): add a createDocument method to Wavelet so that we can push this ugliness
    // down the stack.
    ObservableDocument destDoc = destWavelet.getDocument(docId);
    destDoc.hackConsume(Nindo.fromDocOp(docInit, false /* don't remove skip */));
  }
View Full Code Here

   *
   * @param wavelet the wavelet containing the document to erase
   * @param documentId the id of the document to erase
   */
  public static void clearDocument(Wavelet wavelet, String documentId) {
    Document document = wavelet.getDocument(documentId);
    if (document.size() != 0) {
      document.emptyElement(document.getDocumentElement());
    }
  }
View Full Code Here

  public ObservableDocument getDocument(String docId) {
    Blip blip = getBlip(docId);
    if (blip == null) {
      blip = createBlip(docId);
    }
    Document doc = blip.getContent();
    if (!(doc instanceof ObservableDocument)) {
      Preconditions.illegalArgument("Document \"" + docId + "\" is not observable");
    }
    return (ObservableDocument) doc;
  }
View Full Code Here

        && rootConversation.getRootThread().getFirstBlip() != null) {
      firstBlip = rootConversation.getRootThread().getFirstBlip();
    }
    String title;
    if (firstBlip != null) {
      Document firstBlipContents = firstBlip.getContent();
      title = TitleHelper.extractTitle(firstBlipContents).trim();
    } else {
      title = EMPTY_WAVELET_TITLE;
    }
View Full Code Here

    BlipData blipData = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_DATA);
    String parentBlipId = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_ID);
    ConversationBlip parentBlip = context.getBlip(conversation, parentBlipId);

    // Append a new, empty line to the doc for the inline anchor.
    Document doc = parentBlip.getContent();
    Doc.E line = LineContainers.appendLine(doc, XmlStringBuilder.createEmpty());

    // Insert new inline thread with the blip at the empty sentence.
    int location = doc.getLocation(Point.after(doc, line));
    ConversationBlip newBlip = parentBlip.addReplyThread(location).appendBlip();
    context.putBlip(blipData.getBlipId(), newBlip);

    putContentForNewBlip(newBlip, blipData.getContent());
    processBlipCreatedEvent(operation, context, participant, conversation, newBlip);
View Full Code Here

    // Create builder from xml content.
    XmlStringBuilder markupBuilder = XmlStringBuilder.createFromXmlString(content);

    // Append the new markup to the blip doc.
    Document doc = convBlip.getContent();
    LineContainers.appendLine(doc, markupBuilder);

    // Report success.
    context.constructResponse(operation, Maps.<ParamsProperty, Object> newHashMap());
  }
View Full Code Here

    String title =
        OperationUtil.getRequiredParameter(operation, ParamsProperty.WAVELET_TITLE);
    ObservableConversation conversation =
        context.openConversation(operation, participant).getRoot();
    String blipId = conversation.getRootThread().getFirstBlip().getId();
    Document doc = context.getBlip(conversation, blipId).getContent();
    TitleHelper.setExplicitTitle(doc, title);
  }
View Full Code Here

        OperationUtil.getRequiredParameter(operation, ParamsProperty.MODIFY_ACTION);

    OpBasedWavelet wavelet = context.openWavelet(operation, participant);
    ObservableConversation conversation =
        context.openConversation(operation, participant).getRoot();
    Document doc = context.getBlip(conversation, blipId).getContent();

    ApiView view = new ApiView(doc, wavelet);
    DocumentHitIterator hitIterator = getDocumentHitIterator(operation, view);

    switch (modifyAction.getModifyHow()) {
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.Document

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.