/** * 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(); } }
@UiHandler("parameterEditor") void parameterEditorOnChange(ChangeEvent event) { try { ((PortableFloatParameterDefinition) ppd).setValue( Float.parseFloat( parameterEditor.getText() ) ); } catch ( NumberFormatException nfe ) { ((PortableFloatParameterDefinition) ppd).setValue( null ); } }
public WorkItemFloatParameterWidget(PortableFloatParameterDefinition ppd, IBindingProvider bindingProvider, boolean isReadOnly) { super( ppd, bindingProvider ); this.parameterName.setText( ppd.getName() ); this.parameterEditor.setEnabled( !isReadOnly ); //Setup widget to select a literal value if ( ppd.getValue() != null ) { this.parameterEditor.setText( Float.toString( ppd.getValue() ) ); } //Setup widget to use bindings Set<String> bindings = bindingProvider.getBindings( ppd.getClassName() ); if ( bindings.size() > 0 ) { lstAvailableBindings.clear(); lstAvailableBindings.addItem( CommonConstants.INSTANCE.Choose() ); lstAvailableBindings.setEnabled( true && !isReadOnly ); lstAvailableBindings.setVisible( true ); int selectedIndex = 0; for ( String binding : bindings ) { lstAvailableBindings.addItem( binding ); if ( binding.equals( ppd.getBinding() ) ) { selectedIndex = lstAvailableBindings.getItemCount() - 1; } } lstAvailableBindings.setSelectedIndex( selectedIndex ); parameterEditor.setEnabled( selectedIndex == 0 && !isReadOnly ); } }
@UiHandler("lstAvailableBindings") void lstAvailableBindingsOnChange(ChangeEvent event) { int index = lstAvailableBindings.getSelectedIndex(); parameterEditor.setEnabled( index == 0 ); if ( index > 0 ) { ((PortableFloatParameterDefinition) ppd).setValue( null ); ((PortableFloatParameterDefinition) ppd).setBinding( lstAvailableBindings.getItemText( index ) ); } else { ((PortableFloatParameterDefinition) ppd).setBinding( "" ); } }
private AbstractRestrictedEntryTextBox makeNumericFloatTextBox( final DTCellValue52 value ) { final AbstractRestrictedEntryTextBox tb = new NumericFloatTextBox( allowEmptyValues ); final Float numericValue = (Float) value.getNumericValue(); tb.setValue( numericValue == null ? "" : numericValue.toString() ); // Wire up update handler tb.setEnabled( !isReadOnly ); if ( !isReadOnly ) { tb.addValueChangeHandler( new ValueChangeHandler<String>() { public void onValueChange( ValueChangeEvent<String> event ) { try { value.setNumericValue( new Float( event.getValue() ) ); } catch ( NumberFormatException nfe ) { if ( allowEmptyValues ) { value.setNumericValue( (Float) null ); tb.setValue( "" ); } else { value.setNumericValue( new Float( "0" ) ); tb.setValue( "0" ); } } } } ); } return tb; }