当前位置: 首页>>代码示例>>Java>>正文


Java CMutableDocument类代码示例

本文整理汇总了Java中org.waveprotocol.wave.client.editor.content.CMutableDocument的典型用法代码示例。如果您正苦于以下问题:Java CMutableDocument类的具体用法?Java CMutableDocument怎么用?Java CMutableDocument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CMutableDocument类属于org.waveprotocol.wave.client.editor.content包,在下文中一共展示了CMutableDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAnnotations

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
/**
 * Builds a string representation of the annotations in the current document.
 *
 * @return formatted string of all the annotations in the document
 */
private String getAnnotations() {
  CMutableDocument doc = editorImpl.mutable();
  int end = doc.size();
  // Grab a cursor over the whole document for our known keys
  Iterable<RangedAnnotation<Object>> rangedAnnotations =
      editorImpl.getContent().getLocalAnnotations().rangedAnnotations(0, end, null);
  StringBuilder retval = new StringBuilder();
  for (RangedAnnotation<Object> ann : rangedAnnotations) {
    if (ann.value() != null) {
      retval.append("(").append(ann.start()).append(",").append(ann.end())
          .append(") : ").append(ann.key()).append("=").append(ann.value())
          .append("\n");
    }
  }

  return retval.toString();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:23,代码来源:DebugDialog.java

示例2: PasteExtractor

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param deferredCommands
 * @param aggressiveSelectionHelper
 * @param mutableDocument
 * @param operationSequencer
 */
public PasteExtractor(CommandQueue deferredCommands,
    SelectionHelper aggressiveSelectionHelper,
    CMutableDocument mutableDocument,
    ReadableDocumentView<ContentNode, ContentElement, ContentTextNode> renderedContent,
    ReadableDocumentView<ContentNode, ContentElement, ContentTextNode> persistentContent,
    AnnotationRegistry annotationRegistry,
    OperationSequencer<Nindo> operationSequencer,
    Validator validator,
    EditorInstrumentor instrumentor,
    boolean useSemanticCopyPaste) {
  this.deferredCommands = deferredCommands;
  this.aggressiveSelectionHelper = aggressiveSelectionHelper;
  this.mutableDocument = mutableDocument;
  this.operationSequencer = operationSequencer;
  this.renderedContent = renderedContent;
  this.persistentContent = persistentContent;
  this.validator = validator;
  this.subtreeRenderer =
      new SubTreeXmlRenderer<ContentNode, ContentElement, ContentTextNode>(mutableDocument);
  this.annotationLogic =
      new PasteAnnotationLogic<ContentNode, ContentElement, ContentTextNode>(
          mutableDocument, annotationRegistry);
  this.instrumentor = instrumentor;
  this.useSemanticCopyPaste = useSemanticCopyPaste;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:34,代码来源:PasteExtractor.java

示例3: insertGadget

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
private void insertGadget(String url) {
  int from = -1;
  FocusedRange focusedRange = editor.getSelectionHelper().getSelectionRange();
  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) {
      Point<ContentNode> point = document.locate(from);
      document.insertXml(point, xml);
    } else {
      LineContainers.appendLine(document, xml);
    }
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:21,代码来源:EditToolbar.java

示例4: getSelectionPoint

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
private Point<ContentNode> getSelectionPoint() {
  Point<ContentNode> point;
  FocusedContentRange selection = editor.getSelectionHelper().getSelectionPoints();
  if (selection != null) {
    point = selection.getFocus();
  } else {
    // Focus was probably lost.  Bring it back.
    editor.focus(false);
    selection = editor.getSelectionHelper().getSelectionPoints();
    if (selection != null) {
      point = selection.getFocus();
    } else {
      // Still no selection.  Oh well, put it at the end.
      CMutableDocument doc = editor.getDocument();            
      point = doc.locate(doc.size() - 1);
    }
  }
  return point;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:20,代码来源:EditToolbar.java

示例5: getAnnotations

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
/**
 * Builds a string representation of the annotations in the current document.
 *
 * @return formatted string of all the annotations in the document
 */
private String getAnnotations() {
  CMutableDocument doc = editorImpl.mutable();
  int end = doc.size();
  // Grab a cursor over the whole document for our known keys
  Iterable<RangedAnnotation<Object>> rangedAnnotations =
      editorImpl.getContent().getLocalAnnotations().rangedAnnotations(0, end, null);
  StringBuilder retval = new StringBuilder();
  for (RangedAnnotation<Object> ann : rangedAnnotations) {
    if (ann.value() != null) {
      retval.append("(" + ann.start() + "," + ann.end() + ") : " + ann.key() + "=" + ann.value()
          + "\n");
    }
  }

  return retval.toString();
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:22,代码来源:DebugDialog.java

示例6: insertGadget

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
private void insertGadget(String url, FocusedRange focusedRange) {
  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) {
      Point<ContentNode> point = document.locate(from);
      document.insertXml(point, xml);
    } else {
      LineContainers.appendLine(document, xml);
    }
  }
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:20,代码来源:EditToolbar.java

示例7: onUploadStarted

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
@Override
public void onUploadStarted(String filename) {
  if (!edit.isEditing()) {
    // A concurrent editor may have deleted the context blip while this user
    // was filling out the upload form.  That was probably the cause of why
    // the edit session has terminated.
    // It may make sense to create a new blip somewhere and resume an edit
    // session, just in order to put the thumbnail somewhere, but that logic
    // would need to avoid making a bad choice of where that new blip goes
    // (e.g., in an unrelated thread, or in a different private reply, etc).
    // The simpler approach is to do nothing, and let the user upload the
    // file again if it still makes sense (the blip in which they intended it
    // to go has been deleted, so they may not want to upload it anymore).
    return;
  }
  EditorContext context = edit.getEditor();
  CMutableDocument doc = context.getDocument();
  FocusedContentRange selection = context.getSelectionHelper().getSelectionPoints();
  Point<ContentNode> point;
  if (selection != null) {
    point = selection.getFocus();
  } else {
    // Focus was probably lost.  Bring it back.
    context.focus(false);
    selection = context.getSelectionHelper().getSelectionPoints();
    if (selection != null) {
      point = selection.getFocus();
    } 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));
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:36,代码来源:UploadToolbarAction.java

示例8: setCaptionText

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
/**
 * Sets the caption text of this doodad.
 */
public void setCaptionText(String text) {
  CMutableDocument doc = element.getMutableDoc();
  ContentElement caption = DocHelper.getElementWithTagName(doc, Caption.TAGNAME, element);
  if (caption != null) {
    doc.emptyElement(caption);
    doc.insertText(Point.<ContentNode> end(caption), text);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:12,代码来源:ImageThumbnailWrapper.java

示例9: findLinkAnnotationRange

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
/**
 * Find an annotation range for links.
 *
 * @param doc
 * @param element
 * @return returns the range or null if none is found.
 */
private Range findLinkAnnotationRange(CMutableDocument doc, ContentElement element) {
  // By default, we will look for link keys.
  // TODO(user): Refactor this to not assume that we are interested
  // in just links.
  // Find range that covers contentElement and the annotation.
  for (String key : Link.LINK_KEYS) {
    Range range = AnnotationHelper.getRangePrecedingElement(doc, contentElement, key);
    if (range != null) {
      return range;
    }
  }
  return null;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:21,代码来源:Suggestion.java

示例10: populateSuggestionMenu

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
@Override
public void populateSuggestionMenu(Menu menu, RangeTracker replacementRangeHelper,
    CMutableDocument mutableDocument, ContentElement element) {
  final String movieAttribute = element.getAttribute(MOVIE_ATTR);

  if (movieAttribute != null) {
    final StateMap stateMap = StateMap.create();
    stateMap.put(GADGET_MOVIE_KEY, movieAttribute);

    menu.addItem(EMBED_VIDEO,
        new GadgetCommand<ContentNode, ContentElement, ContentTextNode>(MOVIE_GADGET_URL,
            stateMap, mutableDocument, AnnotationConstants.LINK_AUTO, replacementRangeHelper));
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:15,代码来源:VideoLinkPlugin.java

示例11: waveEnable

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
@Override
public void waveEnable(String waveApiVersion) {    
  if (!isActive()) {
    return;
  }
  log("GW.waveEnable: waveApiVersion=" + waveApiVersion);

  waveEnabled = true;      

  // HACK: See substituteIframeId() description.
  // TODO(user): Remove when the Firefox bug is fixed.
  if (UserAgent.isFirefox()) {
    substituteIframeId();
  }

  sendWaveGadgetInitialization();

  GadgetWidget.this.element.getMutableDoc().addListener(
      new CMutableDocument.EditingModeChangeListener() {

    @Override
    public void onEditingModeChanged(boolean editingMode) {
      sendMode();
    }
  });

  ui.showAsLoaded();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:29,代码来源:GadgetWidget.java

示例12: selectGadget

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
@Override
public void selectGadget() {
  if (isActive()) {
    CMutableDocument doc = element.getMutableDoc();
    element.getSelectionHelper().setSelectionPoints(
        Point.before(doc, element), Point.after(doc, element));
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:9,代码来源:GadgetWidget.java

示例13: AggressiveSelectionHelper

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
/**
 * @param bundle
 * @param htmlHelper
 */
public AggressiveSelectionHelper(HtmlSelectionHelper htmlHelper, NodeManager nodeManager,
    ContentView renderedContentView, LocationMapper<ContentNode> locationMapper,
    CMutableDocument mutableDocument) {
  super(htmlHelper, nodeManager, renderedContentView, locationMapper);

  this.mutableDocument = mutableDocument;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:12,代码来源:AggressiveSelectionHelper.java

示例14: getFirstLine

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
public static Line getFirstLine(LocationMapper<ContentNode> mapper, int start) {
  Point<ContentNode> point = mapper.locate(start);
  CMutableDocument doc = point.getContainer().getMutableDoc();
  LineContainers.checkNotParagraphDocument(doc);

  // get line element we are in:
  ContentNode first = LineContainers.getRelatedLineElement(doc, point);

  if (first == null) {
    return null;
  }

  // go through the lines one by one:
  return Line.fromLineElement(first.asElement());
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:16,代码来源:Paragraph.java

示例15: isEmptyLine

import org.waveprotocol.wave.client.editor.content.CMutableDocument; //导入依赖的package包/类
boolean isEmptyLine(ContentElement e) {
  // The line containing element e is considered empty if its line element is the last
  // element or if it is followed by another line element
  ContentElement lineElement = Line.fromParagraph(e).getLineElement();
  CMutableDocument doc = lineElement.getMutableDoc();
  ContentNode next = doc.getNextSibling(lineElement);
  return next == null
      || (next.asElement() != null && LineRendering.isLineElement(next.asElement()));
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:10,代码来源:LocalParagraphEventHandler.java


注:本文中的org.waveprotocol.wave.client.editor.content.CMutableDocument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。