Ejemplo n.º 1
0
  public String replaceSelection(String value, boolean collapseSelection) {
    Selection selection = getSession().getSelection();
    String oldValue = getSession().getTextRange(selection.getRange());

    replaceSelection(value);

    if (collapseSelection) {
      collapseSelection(false);
    }

    return oldValue;
  }
Ejemplo n.º 2
0
 public void collapseSelection(boolean collapseToStart) {
   Selection selection = getSession().getSelection();
   Range rng = selection.getRange();
   Position pos = collapseToStart ? rng.getStart() : rng.getEnd();
   selection.setSelectionRange(Range.fromPoints(pos, pos));
 }