/** * Get a TextBox relevant to the specified data-type * @param dataType * @return */ public static TextBox getTextBox( final String dataType ) { if ( DataType.TYPE_NUMERIC.equals( dataType ) ) { return new NumericTextBox(); } else if ( DataType.TYPE_NUMERIC_BIGDECIMAL.equals( dataType ) ) { return new NumericBigDecimalTextBox(); } else if ( DataType.TYPE_NUMERIC_BIGINTEGER.equals( dataType ) ) { return new NumericBigIntegerTextBox(); } else if ( DataType.TYPE_NUMERIC_BYTE.equals( dataType ) ) { return new NumericByteTextBox(); } else if ( DataType.TYPE_NUMERIC_DOUBLE.equals( dataType ) ) { return new NumericDoubleTextBox(); } else if ( DataType.TYPE_NUMERIC_FLOAT.equals( dataType ) ) { return new NumericFloatTextBox(); } else if ( DataType.TYPE_NUMERIC_INTEGER.equals( dataType ) ) { return new NumericIntegerTextBox(); } else if ( DataType.TYPE_NUMERIC_LONG.equals( dataType ) ) { return new NumericLongTextBox(); } else if ( DataType.TYPE_NUMERIC_SHORT.equals( dataType ) ) { return new NumericShortTextBox(); } else { return new TextBox(); } }
private AbstractRestrictedEntryTextBox makeNumericBigDecimalTextBox( final DTCellValue52 value ) { final AbstractRestrictedEntryTextBox tb = new NumericBigDecimalTextBox( allowEmptyValues ); final BigDecimal numericValue = (BigDecimal) value.getNumericValue(); tb.setValue( numericValue == null ? "" : numericValue.toPlainString() ); // Wire up update handler tb.setEnabled( !isReadOnly ); if ( !isReadOnly ) { tb.addValueChangeHandler( new ValueChangeHandler<String>() { public void onValueChange( ValueChangeEvent<String> event ) { try { value.setNumericValue( new BigDecimal( event.getValue() ) ); } catch ( NumberFormatException nfe ) { if ( allowEmptyValues ) { value.setNumericValue( (BigDecimal) null ); tb.setValue( "" ); } else { value.setNumericValue( BigDecimal.ZERO ); tb.setValue( BigDecimal.ZERO.toPlainString() ); } } } } ); } return tb; }