use of org.drools.workbench.screens.guided.rule.client.widget.EnumDropDown in project drools-wb by kiegroup.
the class VerifyFieldConstraintEditor method refreshEditor.
private void refreshEditor() {
String flType = oracle.getFieldType(factType, field.getFieldName());
panel.clear();
if (flType != null && flType.equals(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.valueChanged(newValue);
}
}, DropDownData.create(c), oracle.getResourcePath()));
} else if (flType != null && flType.equals(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 (dropDownData != null) {
// GUVNOR-1324: Java enums are of type TYPE_COMPARABLE whereas Guvnor enums are not.
// The distinction here controls whether the EXPECTED value is handled as a true
// Java enum or a literal with a selection list (i.e. Guvnor enum)
String dataType = oracle.getFieldType(factType, field.getFieldName());
if (dataType.equals(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.valueChanged(newValue);
}
}, dropDownData, oracle.getResourcePath()));
} else {
if (field.getExpected() != null && field.getExpected().length() > 0 && field.getNature() == FieldData.TYPE_UNDEFINED) {
if (field.getExpected().charAt(0) == '=') {
field.setNature(FieldData.TYPE_VARIABLE);
} else {
field.setNature(FieldData.TYPE_LITERAL);
}
}
if (field.getNature() == FieldData.TYPE_UNDEFINED && isThereABoundVariableToSet() == true) {
Image clickme = CommonAltedImages.INSTANCE.Edit();
clickme.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
showTypeChoice((Widget) event.getSource(), field);
}
});
panel.add(clickme);
} else if (field.getNature() == FieldData.TYPE_VARIABLE) {
panel.add(variableEditor());
} else {
panel.add(editableTextBox(callback, flType, field.getFieldName(), field.getExpected()));
}
}
}
}
use of org.drools.workbench.screens.guided.rule.client.widget.EnumDropDown in project drools-wb by kiegroup.
the class FieldDataConstraintEditor method refreshDropDownData.
private void refreshDropDownData() {
if (this.valueEditorWidget instanceof EnumDropDown) {
final EnumDropDown dropdown = (EnumDropDown) this.valueEditorWidget;
dropdown.setDropDownData(field.getValue(), helper.getEnums());
}
}
use of org.drools.workbench.screens.guided.rule.client.widget.EnumDropDown 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.drools.workbench.screens.guided.rule.client.widget.EnumDropDown 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);
}
Aggregations