|| attributeName.equals( RuleAttributeWidget.ACTIVATION_GROUP_ATTR )
|| attributeName.equals( RuleAttributeWidget.TIMER_ATTR )
|| attributeName.equals( RuleAttributeWidget.CALENDARS_ATTR ) ) {
final TextBox tb = TextBoxFactory.getTextBox( DataType.TYPE_STRING );
if ( ac.getDefaultValue() == null ) {
ac.setDefaultValue( new DTCellValue52( "" ) );
}
final DTCellValue52 defaultValue = ac.getDefaultValue();
tb.setValue( defaultValue.getStringValue() );
tb.setEnabled( !isReadOnly );
if ( !isReadOnly ) {
tb.addValueChangeHandler( new ValueChangeHandler<String>() {
public void onValueChange( ValueChangeEvent<String> event ) {
defaultValue.setStringValue( tb.getValue() );
defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue));
}
} );
}
editor = tb;
} else if ( attributeName.equals( RuleAttributeWidget.SALIENCE_ATTR ) ) {
final TextBox tb = TextBoxFactory.getTextBox( DataType.TYPE_NUMERIC_INTEGER );
if ( ac.getDefaultValue() == null ) {
ac.setDefaultValue( new DTCellValue52( 0 ) );
} else {
assertIntegerDefaultValue( ac.getDefaultValue() );
}
final DTCellValue52 defaultValue = ac.getDefaultValue();
final Integer numericValue = (Integer) defaultValue.getNumericValue();
tb.setValue( numericValue == null ? "" : numericValue.toString() );
tb.setEnabled( !isReadOnly );
if ( !isReadOnly ) {
tb.addValueChangeHandler( new ValueChangeHandler<String>() {
public void onValueChange( ValueChangeEvent<String> event ) {
try {
defaultValue.setNumericValue( new Integer( event.getValue() ) );
} catch ( NumberFormatException nfe ) {
defaultValue.setNumericValue( new Integer( "0" ) );
tb.setValue( "0" );
} finally {
defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue));
}
}
} );
}
editor = tb;
} else if ( attributeName.equals( RuleAttributeWidget.DURATION_ATTR ) ) {
final TextBox tb = TextBoxFactory.getTextBox( DataType.TYPE_NUMERIC_LONG );
if ( ac.getDefaultValue() == null ) {
ac.setDefaultValue( new DTCellValue52( 0L ) );
} else {
assertLongDefaultValue( ac.getDefaultValue() );
}
final DTCellValue52 defaultValue = ac.getDefaultValue();
final Long numericValue = (Long) defaultValue.getNumericValue();
tb.setValue( numericValue == null ? "" : numericValue.toString() );
tb.setEnabled( !isReadOnly );
if ( !isReadOnly ) {
tb.addValueChangeHandler( new ValueChangeHandler<String>() {
public void onValueChange( ValueChangeEvent<String> event ) {
try {
defaultValue.setNumericValue( new Long( event.getValue() ) );
} catch ( NumberFormatException nfe ) {
defaultValue.setNumericValue( new Long( "0" ) );
tb.setValue( "0" );
} finally {
defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue));
}
}
} );
}
editor = tb;
} else if ( attributeName.equals( RuleAttributeWidget.NO_LOOP_ATTR )
|| attributeName.equals( RuleAttributeWidget.LOCK_ON_ACTIVE_ATTR )
|| attributeName.equals( RuleAttributeWidget.AUTO_FOCUS_ATTR )
|| attributeName.equals( RuleAttributeWidget.ENABLED_ATTR )
|| attributeName.equals( GuidedDecisionTable52.NEGATE_RULE_ATTR ) ) {
final CheckBox cb = new CheckBox();
if ( ac.getDefaultValue() == null ) {
ac.setDefaultValue( new DTCellValue52( Boolean.FALSE ) );
} else {
assertBooleanDefaultValue( ac.getDefaultValue() );
}
final DTCellValue52 defaultValue = ac.getDefaultValue();
final Boolean booleanValue = defaultValue.getBooleanValue();
cb.setEnabled( !isReadOnly );
if ( booleanValue == null ) {
cb.setValue( false );
defaultValue.setBooleanValue( Boolean.FALSE );
} else {
cb.setValue( booleanValue );
}
cb.addClickHandler( new ClickHandler() {
public void onClick( ClickEvent event ) {
defaultValue.setBooleanValue( cb.getValue() );
defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue));
}
} );
editor = cb;
} else if ( attributeName.equals( RuleAttributeWidget.DATE_EFFECTIVE_ATTR )
|| attributeName.equals( RuleAttributeWidget.DATE_EXPIRES_ATTR ) ) {
if ( ac.getDefaultValue() == null ) {
ac.setDefaultValue( new DTCellValue52( new Date() ) );
} else {
assertDateDefaultValue( ac.getDefaultValue() );
}
final DTCellValue52 defaultValue = ac.getDefaultValue();
if ( isReadOnly ) {
final TextBox tb = TextBoxFactory.getTextBox( DataType.TYPE_STRING );
tb.setValue( format.format( defaultValue.getDateValue() ) );
tb.setEnabled( false );
} else {
final PopupDatePicker dp = new PopupDatePicker( false );
final Date dateValue = defaultValue.getDateValue();
dp.setValue( dateValue );
dp.addValueChangeHandler( new ValueChangeHandler<Date>() {
public void onValueChange( ValueChangeEvent<Date> event ) {
defaultValue.setDateValue( event.getValue() );
defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue));
}
} );
editor = dp;
}
} else if ( attributeName.equals( RuleAttributeWidget.DIALECT_ATTR ) ) {
final ListBox lb = new ListBox();
lb.addItem( RuleAttributeWidget.DIALECTS[ 0 ] );
lb.addItem( RuleAttributeWidget.DIALECTS[ 1 ] );
if ( ac.getDefaultValue() == null ) {
ac.setDefaultValue( new DTCellValue52( RuleAttributeWidget.DIALECTS[ 1 ] ) );
}
final DTCellValue52 defaultValue = ac.getDefaultValue();
final String stringValue = defaultValue.getStringValue();
lb.setEnabled( !isReadOnly );
if ( !isReadOnly ) {
lb.addChangeHandler( new ChangeHandler() {
@Override
public void onChange( ChangeEvent event ) {
final int selectedIndex = lb.getSelectedIndex();
if ( selectedIndex < 0 ) {
return;
}
DTCellValue52 newValue = new DTCellValue52( lb.getValue( selectedIndex ) );
ac.setDefaultValue( newValue );
defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(newValue));
}
} );
}