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

public class DocumentFreeSelectionHelper implements SelectionHelper {
  /** Track the simple range directly. */
  FocusedRange selection = null;

  public DocumentFreeSelectionHelper(int start, int end) {
    selection = new FocusedRange(start, end);
  }
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

   * 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("Select some text to create a link.");
      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, Link.KEY, linkAnnotationValue);
    } catch (InvalidLinkException e) {
      String rawLinkValue =
View Full Code Here

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

   * @param editorDiv editor
   * @param end end of selection range
   */
  public static void webdriverEditorSetSelection(Element editorDiv, int start, int end) {
    EditorContext editor = getByEditorDiv(editorDiv);
    editor.getSelectionHelper().setSelectionRange(new FocusedRange(start, end));
  }
View Full Code Here

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

   *
   * @return false if the editor has no selection, or the selection is
   *         collapsed.
   */
  public static boolean hasRangeSelected(ContentDocument doc) {
    FocusedRange range = createSelectionHelper(doc).getSelectionRange();
    return range == null ? false : !range.isCollapsed();
  }
View Full Code Here

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

        });
  }

  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) {
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
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.