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


Java FocusedContentRange类代码示例

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


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

示例1: handleEventsManuallyOnNode

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的package包/类
private boolean handleEventsManuallyOnNode(EditorEvent event, Point<ContentNode> caret)
    throws SelectionLostException {
  // Note that caret may be null if this is called during typing extraction

  // Always handle enter specially, and always cancel the default action.
  // TODO(danilatos): This is still a slight anomaly, to call a
  // node.handleXYZ method here.
  if (event.isOnly(KeyCodes.KEY_ENTER)) {
    refreshEditorWithCaret(event);
    caret = event.getCaret().asPoint();
    editorInteractor.checkpoint(new FocusedContentRange(caret));
    router.handleEnter(caret.getContainer(), event);
    editorInteractor.rebiasSelection(CursorDirection.FROM_LEFT);
    return true;
  } else if (event.isCombo(KeyCodes.KEY_ENTER, KeyModifier.SHIFT)) {
    // shift+enter inserts a "newline" (such as a <br/>) by default
    // TODO(danilatos): Form elements want to handle this.
    return true;
  }
  return false;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:22,代码来源:EditorEventHandler.java

示例2: getSelectionPoint

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的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

示例3: setupFakeEditorInteractor

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的package包/类
/**
 * Set up a FakeEditorInteractor with some default expectations.
 *
 * - allow any number of calls to getSelectionPoints, forceFlush, isEditing,
 * setCaret, normalizePoint and notifyingListeners
 *
 * - set default return values for some of these
 *
 * - normalizePoint returns the start of selection. This might be unexpected,
 * but is convenient for most cases.
 *
 * @param selection
 */
private FakeEditorInteractor setupFakeEditorInteractor(FocusedContentRange selection) {
  FakeEditorInteractor interactor = new FakeEditorInteractor();
  interactor.call(FakeEditorInteractor.GET_SELECTION_POINTS).anyOf().returns(selection);
  interactor.call(FakeEditorInteractor.FORCE_FLUSH).anyOf();
  interactor.call(FakeEditorInteractor.IS_EDITING).anyOf().returns(true);
  interactor.call(FakeEditorInteractor.SET_CARET).anyOf();
  interactor.call(FakeEditorInteractor.NOTIFYING_LISTENERS).anyOf().returns(false);
  interactor.call(FakeEditorInteractor.CHECKPOINT).anyOf();
  interactor.call(FakeEditorInteractor.HAS_CONTENT_SELECTION).anyOf().returns(true);
  interactor.call(FakeEditorInteractor.REBIAS_SELECTION).anyOf();

  FocusedPointRange<Node> htmlSelection = null;
  if (selection != null) {
    interactor.call(FakeEditorInteractor.NORMALIZE_POINT).anyOf().returns(selection.getFocus());
    htmlSelection = new FocusedPointRange<Node>(
        toNodePoint(selection.getAnchor()), toNodePoint(selection.getFocus()));
  }
  interactor.call(FakeEditorInteractor.GET_HTML_SELECTION).anyOf().returns(htmlSelection);
  return interactor;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:34,代码来源:EditorEventHandlerGwtTest.java

示例4: testNormalisesSelection

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的package包/类
/**
 * Ensure that the event handler normalises the selection when necessary
 * Note that this is currently just for firefox.
 */
public void testNormalisesSelection() {
  FakeEditorEvent fakeEvent = FakeEditorEvent.create(KeySignalType.INPUT, 'a');
  final Point<ContentNode> caret =
      Point.<ContentNode> end(newParaElement());

  EditorEventsSubHandler subHandler = new FakeEditorEventsSubHandler();
  FakeEditorInteractor interactor = setupFakeEditorInteractor(new FocusedContentRange(caret));
  final Point<ContentNode> newCaret = Point.<ContentNode>inText(
      new ContentTextNode(Document.get().createTextNode("hi"), null), 2);
  interactor.call(FakeEditorInteractor.NORMALIZE_POINT).returns(newCaret);
  interactor.call(FakeEditorInteractor.SET_CARET).nOf(1).withArgs(newCaret);
  interactor.call(FakeEditorInteractor.NOTIFYING_TYPING_EXTRACTOR).nOf(1).withArgs(
      newCaret, false);
  EditorEventHandler handler = createEditorEventHandler(interactor, subHandler);

  handler.handleEvent(fakeEvent);
  interactor.checkExpectations();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:23,代码来源:EditorEventHandlerGwtTest.java

示例5: testEventsHandledByListenerExitsHandler

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的package包/类
/**
 * Tests that events handled by listeners exits the EditorEventHandler and
 * does not continue triggering other handler methods.
 */
public void testEventsHandledByListenerExitsHandler() {
  FakeEditorEvent fakeEvent = FakeEditorEvent.create(KeySignalType.INPUT, 'a');
  final Point<ContentNode> caret =
      Point.<ContentNode> end(newParaElement());

  FakeEditorEventsSubHandler subHandler = new FakeEditorEventsSubHandler();
  FakeEditorInteractor interactor = setupFakeEditorInteractor(new FocusedContentRange(caret));
  EditorEventHandler handler = createEditorEventHandler(interactor, subHandler);

  interactor.call(FakeEditorInteractor.NOTIFYING_LISTENERS).nOf(1).withArgs(fakeEvent).returns(
      true);
  boolean cancel = handler.handleEvent(fakeEvent);
  assertFalse("Should not cancel events even if handled by listeners", cancel);
  interactor.checkExpectations();
  subHandler.checkExpectations();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:21,代码来源:EditorEventHandlerGwtTest.java

示例6: testMouseEventsTriggeredOnNode

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的package包/类
/**
 * Tests mouse event triggers on node.
 */
public void testMouseEventsTriggeredOnNode() {
  EditorEvent mouseSignal = FakeSignalEvent.createClick(FakeEditorEvent.ED_FACTORY, null);
  ContentElement fakeContentElement = newElement();
  final Point<ContentNode> caret = Point.<ContentNode> end(fakeContentElement);

  FakeRouter router = new FakeRouter();
  FakeEditorEventsSubHandler subHandler = new FakeEditorEventsSubHandler();
  FakeEditorInteractor interactor = setupFakeEditorInteractor(new FocusedContentRange(caret));
  EditorEventHandler handler = createEditorEventHandler(router, interactor, subHandler);

  interactor.call(FakeEditorInteractor.FIND_ELEMENT_WRAPPER).nOf(1).withArgs(
      mouseSignal.getTarget()).returns(fakeContentElement);
  router.ctx.call(FakeRouter.HANDLE_CLICK).nOf(1).withArgs(mouseSignal)
      .returns(true);
  interactor.call(FakeEditorInteractor.CLEAR_ANNOTATIONS).nOf(1);

  boolean cancel = handler.handleEvent(mouseSignal);
  router.ctx.checkExpectations();
  interactor.checkExpectations();
  subHandler.checkExpectations();
  assertEquals("Allow iff event allows browser default", mouseSignal.shouldAllowBrowserDefault(),
      !cancel);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:27,代码来源:EditorEventHandlerGwtTest.java

示例7: testDeleteWithRangeSelectedDeletesRange

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的package包/类
public void testDeleteWithRangeSelectedDeletesRange() {
  FakeEditorEvent fakeEvent = FakeEditorEvent.create(KeySignalType.DELETE, KeyCodes.KEY_LEFT);

  //Event event = Document.get().createKeyPressEvent(
  //    false, false, false, false, KeyCodes.KEY_BACKSPACE, 0).cast();

  Text input = Document.get().createTextNode("ABCDE");
  ContentNode node = new ContentTextNode(input, null);

  final Point<ContentNode> start = Point.inText(node, 1);
  final Point<ContentNode> end = Point.inText(node, 4);
  FakeEditorInteractor interactor = setupFakeEditorInteractor(
      new FocusedContentRange(start, end));
  EditorEventsSubHandler subHandler = new FakeEditorEventsSubHandler();
  EditorEventHandler handler = createEditorEventHandler(interactor, subHandler);

  interactor.call(FakeEditorInteractor.DELETE_RANGE).nOf(1).withArgs(
      start, end, false).returns(start);

  handler.handleEvent(fakeEvent);
  interactor.checkExpectations();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:23,代码来源:EditorEventHandlerGwtTest.java

示例8: testNonCharacterMoveUnitIsCancelledHelper

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的package包/类
private void testNonCharacterMoveUnitIsCancelledHelper(EditorEvent event, boolean backspace) {
  final Point<ContentNode> caret =
      Point.<ContentNode> end(newParaElement());

  FocusedContentRange selection = new FocusedContentRange(caret);
  FakeEditorInteractor interactor = setupFakeEditorInteractor(selection);
  FakeEditorEventsSubHandler subHandler = new FakeEditorEventsSubHandler();
  EditorEventHandler handler = createEditorEventHandler(interactor, subHandler);

  if (backspace) {
    interactor.call(FakeEditorInteractor.DELETE_WORD_ENDING_AT).withArgs(caret).anyOf();
  } else {
    interactor.call(FakeEditorInteractor.DELETE_WORD_STARTING_AT).withArgs(caret).anyOf();
  }
  boolean cancel = handler.handleEvent(event);
  interactor.checkExpectations();
  subHandler.checkExpectations();
  assertEquals("Cancel does not match expected", true, cancel);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:20,代码来源:EditorEventHandlerGwtTest.java

示例9: testRoutePasteEvent

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的package包/类
/**
 * Test that paste events are routed correctly.
 */
public void testRoutePasteEvent() {
  final Point<ContentNode> caret =
    Point.<ContentNode> end(newParaElement());
  FocusedContentRange selection = new FocusedContentRange(caret);

  FakeEditorEvent pasteEvent = FakeEditorEvent.createPasteEvent();
  FakeEditorInteractor interactor = setupFakeEditorInteractor(selection);
  FakeEditorEventsSubHandler subHandler = new FakeEditorEventsSubHandler();
  EditorEventHandler handler = createEditorEventHandler(interactor, subHandler);

  subHandler.call(FakeEditorEventsSubHandler.HANDLE_PASTE).nOf(1).withArgs(pasteEvent).returns(
      false);
  boolean cancel = handler.handleEvent(pasteEvent);
  interactor.checkExpectations();
  subHandler.checkExpectations();
  assertFalse(cancel);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:21,代码来源:EditorEventHandlerGwtTest.java

示例10: onUploadStarted

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的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

示例11: getSelectionPoints

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public FocusedContentRange getSelectionPoints() {
  FocusedPointRange<Node> range = htmlHelper.getHtmlSelection();
  try {
    needsCorrection = false;

    range = SelectionUtil.filterNonContentSelection(range);

    if (range == null) {
      return null;
    }
    Point<ContentNode>
      anchor = nodeletPointToFixedContentPoint(range.getAnchor()),
      focus = range.isCollapsed()
            ? anchor : nodeletPointToFixedContentPoint(range.getFocus());

    if (anchor == null || focus == null) {
      return null;
    }

    // Uncomment for verbose debugging
    // if (Debug.isOn(LogSeverity.DEBUG)) {
    //   logger.logXml("SELECTION: " + start + " - " + end);
    // }

    FocusedContentRange ret = range.isCollapsed()
        ? new FocusedContentRange(anchor) : new FocusedContentRange(anchor, focus);

    if (needsCorrection && ret != null) {
      setSelectionPoints(ret.getAnchor(), ret.getFocus());
    }

    return ret;
  } finally {
    needsCorrection = false;
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:39,代码来源:PassiveSelectionHelper.java

示例12: getSelectionRange

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public FocusedRange getSelectionRange() {
  FocusedContentRange contentRange = getSelectionPoints();
  if (contentRange == null) {
    return null;
  }
  return new FocusedRange(
      mapper.getLocation(contentRange.getAnchor()),
      mapper.getLocation(contentRange.getFocus())
  );
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:13,代码来源:PassiveSelectionHelper.java

示例13: compositionEnd

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的package包/类
@Override
public FocusedContentRange compositionEnd() {
  try {

    if (!imeExtractor.isActive()) {
      EditorStaticDeps.logger.error().log(
          "Composition end called with inactive ImeExtractor! "
              + "Maybe caret was null initially?");
      return null;
    }

    // HACK(danilatos): prevent CC from sending the insertion before the annotation update.
    // TODO(zdwang/danilatos): Implement batching in CcBasedWavelet, or something, and send
    // out in a deferred command, so synchronously generated ops always go in the same
    // delta, whether or not CC is waiting for an unacknowledged op.
    mutable().hackConsume(new Nindo.Builder().build());

    String composition = imeExtractor.getContent();
    assert composition != null : "Composition should not be null with active IME extractor";
    Point<ContentNode> contentPoint = imeExtractor.deactivate(content.getAnnotatableContent());
    Point<ContentNode> caret = insertText(contentPoint, composition, true);
    aggressiveSelectionHelper.setCaret(caret);
    rebiasSelection(CursorDirection.FROM_LEFT);

    // HACK(danilatos): Flush updates, so that listeners to the ime state get an immediate
    // update, to synchronously clear the composition state from any selection annotations,
    // so that there's no instant where the other side sees both the inserted text and
    // the last composed bit.
    // This can be avoided by keeping track of the selection annotations directly in the
    // editor, something worth considering.
    responsibility.startIndirectSequence();
    updateEvent.flushUpdates();
    responsibility.endIndirectSequence();

    return passiveSelectionHelper.getSelectionPoints();
  } finally {
    EditorStaticDeps.endIgnoreMutations();
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:40,代码来源:EditorImpl.java

示例14: checkpoint

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的package包/类
@Override
public void checkpoint(FocusedContentRange currentRange) {
  if (currentRange != null) {
    editorUndoManager.maybeCheckpoint(mutable().getLocation(currentRange.getFocus()), mutable()
        .getLocation(currentRange.getAnchor()));
  } else {
    editorUndoManager.maybeCheckpoint();
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:10,代码来源:EditorImpl.java

示例15: testNormalTypingNotifiesExtractor

import org.waveprotocol.wave.client.editor.content.FocusedContentRange; //导入依赖的package包/类
/**
 * Firefox specific-
 *
 * Test that typing extractor is notifed of the correct caret location.
 */
public void testNormalTypingNotifiesExtractor() {
  FakeEditorEvent fakeEvent = FakeEditorEvent.create(KeySignalType.INPUT, 'a');
  final Point<ContentNode> caret =
      Point.<ContentNode> end(newParaElement());

  EditorEventsSubHandler subHandler = new FakeEditorEventsSubHandler();
  FakeEditorInteractor interactor = setupFakeEditorInteractor(new FocusedContentRange(caret));
  EditorEventHandler handler = createEditorEventHandler(interactor, subHandler);

  interactor.call(FakeEditorInteractor.NOTIFYING_TYPING_EXTRACTOR).nOf(1).withArgs(caret, false);
  boolean cancel = handler.handleEvent(fakeEvent);
  assertFalse("Should allow typing event", cancel);
  interactor.checkExpectations();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:20,代码来源:EditorEventHandlerGwtTest.java


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