Examples of FocusedRange


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

    if (contentSelection == null) {
      return true;
    }

    final FocusedRange selection = aggressiveSelectionHelper.getSelectionRange();
    performCopyOrCut(selectionHelper, pasteBuffer.getContainer(), contentSelection, isCut);

    busy = true;
    deferredCommands.addCommand(new Command() {
      public void execute() {
        if (isCut) {
          aggressiveSelectionHelper.setCaret(selection.asRange().getStart());
        } else {
          aggressiveSelectionHelper.setSelectionRange(selection);
        }
        busy = false;
      }
View Full Code Here

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

        CursorDirection current = lastDirection;
        if (!settings.useFancyCursorBias()) {
          current = CursorDirection.FROM_LEFT;
        }

        FocusedRange focused = getSelectionHelper().getSelectionRange();
        if (focused != null) {
          Range range = focused.asRange();
          currentSelectionBias = annotationLogic.rebias(range.getStart(), range.getEnd(), current);
        } else {
          // no selection, so have default bias
          currentSelectionBias = BiasDirection.LEFT;
        }
View Full Code Here

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

  private void safelyRestoreSelection(SelectionHelper selectionHelper, boolean collapsed) {
    assert savedSelection != null;

    boolean selectionRestored = false;

    FocusedRange sel = savedSelection.getFocusedRange();
    if (sel != null) {
      EditorStaticDeps.logger.trace().log("Focusing, set selection at: " + sel.getFocus());

      // either set to the focus point (to give visual edit cue) or keep entire selection
      if (collapsed) {
        selectionHelper.setCaret(sel.getFocus());
      } else {
        selectionHelper.setSelectionRange(sel);
      }

      // Check if it successfully is restored, even in the content view.
View Full Code Here

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

  };

  private void doSaveSelection() {
    if (passiveSelectionHelper != null) {
      assert savedSelection != null;
      FocusedRange range = passiveSelectionHelper.getSelectionRange();
      if (range != null) {
        // We don't want to clear it - only remember the last existing selection
        savedSelection.trackRange(range);
      }
    }
View Full Code Here

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

    }
  }

  private void writeSelection(EditorContext context) {
    MutableAnnotationSet.Persistent document = context.getDocument();
    FocusedRange selection = context.getSelectionHelper().getSelectionRange();
    String compositionState = context.getImeCompositionState();
    double currentTimeMillis = clock.currentTimeMillis();

    writeSelection(document, selection, compositionState, currentTimeMillis);
  }
View Full Code Here

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

  private void createInsertGadgetButton(ToolbarView toolbar, final ParticipantId user) {
    new ToolbarButtonViewBuilder()
        .setIcon(css.insertGadget())
        .applyTo(toolbar.addClickButton(), new ToolbarClickButton.Listener() {
          @Override public void onClicked() {
            final FocusedRange focusedRange = editor.getSelectionHelper().getSelectionRange();
            GadgetSelectorWidget selector = new GadgetSelectorWidget(new GadgetInfoProviderImpl(new GwtGadgetInfoParser()));
            selector.addFeaturedOptions();
            final UniversalPopup popup = selector.showInPopup();
            selector.setListener(new GadgetSelectorWidget.Listener() {
              @Override public void onSelect(String url) {
View Full Code Here

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

    new ToolbarButtonViewBuilder().setIcon(css.insertAttachment()).setTooltip("Insert attachment")
        .applyTo(toolbar.addClickButton(), new ToolbarClickButton.Listener() {
          @Override
          public void onClicked() {
            int tmpCursor = -1;
            FocusedRange focusedRange = editor.getSelectionHelper().getSelectionRange();
            if (focusedRange != null) {
              tmpCursor = focusedRange.getFocus();
            }
            final int cursorLoc = tmpCursor;
            AttachmentPopupView attachmentView = new AttachmentPopupWidget();
            attachmentView.init(new Listener() {
View Full Code Here

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

   * @return (copy of) range transformed against modifier
   */
  public static FocusedRange applyModifier(DocOp modifier, FocusedRange range) {
    int anchor = LocationModifier.transformLocation(modifier, range.getAnchor());
    int focus  = LocationModifier.transformLocation(modifier, range.getFocus());
    return new FocusedRange(anchor, focus);
  }
View Full Code Here

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

   * Helper for insert links while editing a document
   *
   * @param editor the wave editor
   */
  public static void onCreateLink(EditorContext editor) {
    FocusedRange range = editor.getSelectionHelper().getSelectionRange();
    if (range == null || range.isCollapsed()) {
      Window.alert(messages.selectSomeText());
      return;
    }
    try {
      // We try to create a link with the current selection, if fails, we ask
      // for a link
      Range rg = range.asRange();
      String text = DocHelper.getText(editor.getDocument(), rg.getStart(), rg.getEnd());
      String linkAnnotationValue = Link.normalizeLink(text);
      EditorAnnotationUtil.setAnnotationOverSelection(editor, AnnotationConstants.LINK_PREFIX, linkAnnotationValue);
    } catch (InvalidLinkException e) {
      String rawLinkValue =
View Full Code Here

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

   * @param suffix the key suffix
   * @param allowNone the allow none color (in background color)
   */
  private static void showPopup(final EditorContext editor, ToolbarClickButton button,
      final String suffix, boolean allowNone) {
    FocusedRange focusedRange = editor.getSelectionHelper().getSelectionRange();
    if (focusedRange == null) {
      // Lets try to focus
      editor.focus(false);
    }
    focusedRange = editor.getSelectionHelper().getSelectionRange();
    if (focusedRange == null) {
      Window.alert(ComplexColorPicker.messages.selectSomeText());
      return;
    }
    final Range range = focusedRange.asRange();
    final ColorPopup popup = new ColorPopup(button.getButton().hackGetWidget().getElement(), allowNone);
    popup.show(new OnColorChooseListener() {
      @Override
      public void onColorChoose(String color) {
        EditorAnnotationUtil.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.