本文整理汇总了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();
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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();
}
示例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);
}
}
}
示例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));
}
示例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);
}
}
示例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;
}
示例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));
}
}
示例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();
}
示例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));
}
}
示例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;
}
示例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());
}
示例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()));
}