use of org.uberfire.ext.widgets.common.client.common.DropDownValueChanged in project drools-wb by kiegroup.
the class MethodParameterCallValueEditor method refresh.
private void refresh() {
root.clear();
if (enums != null && (enums.getFixedList() != null || enums.getQueryExpression() != null)) {
root.add(new EnumDropDown(methodParameter.value, new DropDownValueChanged() {
public void valueChanged(String newText, String newValue) {
methodParameter.value = newValue;
}
}, enums, oracle.getResourcePath()));
} else {
if (methodParameter.nature == FieldNatureType.TYPE_UNDEFINED) {
// we have a blank slate..
// have to give them a choice
root.add(choice());
} else {
if (methodParameter.nature == FieldNatureType.TYPE_VARIABLE) {
ListBox list = boundVariable(methodParameter);
root.add(list);
} else {
TextBox box = boundTextBox(this.methodParameter);
root.add(box);
}
}
}
}
use of org.uberfire.ext.widgets.common.client.common.DropDownValueChanged in project drools-wb by kiegroup.
the class ConstraintValueEditor method literalEditor.
private Widget literalEditor() {
// Custom screen
if (this.constraint instanceof SingleFieldConstraint) {
final SingleFieldConstraint con = (SingleFieldConstraint) this.constraint;
CustomFormConfiguration customFormConfiguration = getWorkingSetManager().getCustomFormConfiguration(modeller.getPath(), factType, fieldName);
if (customFormConfiguration != null) {
Button btnCustom = new Button(con.getValue(), new ClickHandler() {
public void onClick(ClickEvent event) {
showTypeChoice(constraint);
}
});
btnCustom.setEnabled(!this.readOnly);
return btnCustom;
}
}
// Label if read-only
if (this.readOnly) {
return new SmallLabel(getSanitizedValue());
}
// Enumeration (these support multi-select for "in" and "not in", so check before comma separated lists)
if (this.dropDownData != null) {
final String operator = constraint.getOperator();
final boolean multipleSelect = OperatorsOracle.operatorRequiresList(operator);
EnumDropDown enumDropDown = new EnumDropDown(constraint.getValue(), new DropDownValueChanged() {
public void valueChanged(String newText, String newValue) {
// Prevent recursion once value change has been applied
if (!newValue.equals(constraint.getValue())) {
constraint.setValue(newValue);
executeOnValueChangeCommand();
}
}
}, dropDownData, multipleSelect, modeller.getPath());
return enumDropDown;
}
// Comma separated value list (this will become a dedicated Widget but for now a TextBox suffices)
String operator = null;
if (this.constraint instanceof SingleFieldConstraint) {
SingleFieldConstraint sfc = (SingleFieldConstraint) this.constraint;
operator = sfc.getOperator();
}
if (OperatorsOracle.operatorRequiresList(operator)) {
return getNewTextBox(DataType.TYPE_STRING);
}
// Date picker
boolean isCEPOperator = CEPOracle.isCEPOperator((this.constraint).getOperator());
if (DataType.TYPE_DATE.equals(this.fieldType) || (DataType.TYPE_THIS.equals(this.fieldName) && isCEPOperator)) {
if (this.readOnly) {
return new SmallLabel(constraint.getValue());
}
final DatePicker datePicker = new DatePicker(false);
// Wire up update handler
datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
@Override
public void onValueChange(final ValueChangeEvent<Date> event) {
final Date date = datePicker.getValue();
final String sDate = (date == null ? null : DATE_FORMATTER.format(datePicker.getValue()));
boolean update = constraint.getValue() == null || !constraint.getValue().equals(sDate);
constraint.setValue(sDate);
if (update) {
executeOnValueChangeCommand();
}
}
});
datePicker.setFormat(DATE_FORMAT);
datePicker.setValue(getSanitizedDateValue());
return datePicker;
}
// Default editor for all other literals
return getNewTextBox(fieldType);
}
use of org.uberfire.ext.widgets.common.client.common.DropDownValueChanged in project drools-wb by kiegroup.
the class VerifyFieldConstraintEditor method refreshEditor.
private void refreshEditor() {
String flType = oracle.getFieldType(factType, field.getFieldName());
panel.clear();
if (Objects.equals(flType, DataType.TYPE_BOOLEAN)) {
String[] c = new String[] { "true", "false" };
panel.add(new EnumDropDown(field.getExpected(), new DropDownValueChanged() {
public void valueChanged(String newText, String newValue) {
callback.callback(newValue);
}
}, DropDownData.create(c), oracle.getResourcePath()));
} else if (Objects.equals(flType, DataType.TYPE_DATE)) {
FieldDatePicker fieldDatePicker = new FieldDatePicker(new FieldDatePickerViewImpl());
fieldDatePicker.setValue(field.getExpected());
fieldDatePicker.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
field.setExpected(event.getValue());
}
});
panel.add(fieldDatePicker);
} else {
Map<String, String> currentValueMap = new HashMap<String, String>();
// TODO fill currentValueMap with values of other VerifyFields (if any)
DropDownData dropDownData = oracle.getEnums(factType, field.getFieldName(), currentValueMap);
if (Objects.nonNull(dropDownData)) {
// Java enum or a literal with a selection list (i.e. Guvnor enum)
if (Objects.equals(flType, DataType.TYPE_COMPARABLE)) {
field.setNature(FieldData.TYPE_ENUM);
} else {
field.setNature(FieldData.TYPE_LITERAL);
}
panel.add(new EnumDropDown(field.getExpected(), new DropDownValueChanged() {
public void valueChanged(String newText, String newValue) {
callback.callback(newValue);
}
}, dropDownData, oracle.getResourcePath()));
} else {
if (field.getNature() == FieldData.TYPE_UNDEFINED) {
if (Objects.nonNull(field.getExpected()) && field.getExpected().indexOf('=') == 0) {
field.setNature(FieldData.TYPE_VARIABLE);
} else if (isThereABoundVariableToSet()) {
Image clickme = CommonAltedImages.INSTANCE.Edit();
clickme.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
showTypeChoice(field);
}
});
panel.add(clickme);
} else {
field.setNature(FieldData.TYPE_LITERAL);
}
}
if (field.getNature() == FieldData.TYPE_VARIABLE) {
panel.add(variableEditor());
} else if (field.getNature() == FieldData.TYPE_LITERAL) {
panel.add(textBoxEditor(flType).asWidget());
}
}
}
}
Aggregations