public void onDoubleClick(DoubleClickEvent e) {

    GPoint point = table.getIndexFromPixel(e.getClientX(), e.getClientY());

    if (point != null) {
      // auto-fill down if dragging dot is double-clicked
      if (table.isOverDot) {
        // TODO handleAutoFillDown();
        return;
      }

      // otherwise, doubleClick edits cell

      if (!(table.getOneClickEditMap().containsKey(point) && view.allowSpecialEditor())) {
        table.setAllowEditing(true);
        table.editCellAt(table.getSelectedRow() + 1, table.getSelectedColumn() + 1);

        // workaround, see
        // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4192625
        final AutoCompleteTextFieldW f = (AutoCompleteTextFieldW) table.getEditorWidget();
        if (f != null) {
          f.requestFocus();
          // ?//f.getCaret().setVisible(true);
        }

        table.setAllowEditing(false);
      }
    }
  }
예제 #2
0
  /*
   * auto-insert degree symbol when appropriate
   */
  public void onKeyUp(KeyUpEvent e) {

    // return unless digit typed (instead of !Character.isDigit)
    if (e.getNativeKeyCode() < 48
        || (e.getNativeKeyCode() > 57 && e.getNativeKeyCode() < 96)
        || e.getNativeKeyCode() > 105) return;

    AutoCompleteTextFieldW tc = inputPanel.getTextComponent();
    String text = tc.getText();

    // if text already contains degree symbol or variable
    for (int i = 0; i < text.length(); i++) {
      if (!StringUtil.isDigit(text.charAt(i))) return;
    }

    int caretPos = tc.getCaretPosition();

    tc.setText(tc.getText() + Unicode.degree);

    tc.setCaretPosition(caretPos);
  }