コード例 #1
0
  @Override
  public boolean stopCellEditing() {

    System.out.println("Advanced stopCellEditing");
    component.hidePopup();

    if (tabledesign.colls.get(last_col).validator != null) {
      if (!tabledesign.colls.get(last_col).validator.acceptData(component.getText())) {
        component.setBorder(new LineBorder(Color.RED));
        return false;
      }
    }

    DBValue val = null;

    if (DBValue.class.isInstance(current_value)) {
      val = (DBValue) current_value;
    } else {
      Object o = tabledesign.rows.get(last_row).get(last_col);
      if (o instanceof DBValue) val = (DBValue) o;
    }

    if (val != null) {
      String s = component.getText();

      boolean do_self = true;

      if (tabledesign.colls.get(last_col).validator != null) {
        if (tabledesign.colls.get(last_col).validator.wantDoLoadSelf()) {
          do_self = false;

          if (!tabledesign.colls.get(last_col).validator.loadToValue(val, s, last_row)) {
            component.setBorder(new LineBorder(Color.RED));
            return false;
          }
        }
      }

      if (do_self) {
        if (!val.acceptString(s)) {
          component.setBorder(new LineBorder(Color.RED));
          return false;
        } else {
          val.loadFromString(s);
        }
      }
    }

    component.setBackground(Color.WHITE);

    return super.stopCellEditing();
  }
コード例 #2
0
  @Override
  public Object getCellEditorValue() {
    /*
    System.out.println( "value+:" + ((JTextField)component).getText() );
    System.out.println( "add row:" + last_row );
     */
    // System.out.println("getCellEditorValue");

    tabledesign.edited_cols.add(last_col);
    tabledesign.edited_rows.add(last_row);
    // return component.getSelectedItem().toString();
    return component.getText();
  }