use of org.uberfire.ext.widgets.common.client.common.SmallLabel in project drools-wb by kiegroup.
the class ActionValueEditor method literalEditor.
private Widget literalEditor() {
if (this.readOnly) {
return new SmallLabel(assertValue());
}
// Date picker
if (DataType.TYPE_DATE.equals(value.getType())) {
final DatePicker datePicker = new DatePicker(false);
// Wire up update handler
datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
@Override
public void onValueChange(ValueChangeEvent<Date> event) {
final Date date = datePicker.getValue();
final String sDate = (date == null ? null : DATE_FORMATTER.format(datePicker.getValue()));
value.setValue(sDate);
}
});
datePicker.setFormat(DATE_FORMAT);
datePicker.setValue(assertDateValue());
return datePicker;
}
// Default editor for all other literals
final TextBox box = TextBoxFactory.getTextBox(value.getType());
box.setStyleName("constraint-value-Editor");
box.addValueChangeHandler(new ValueChangeHandler<String>() {
public void onValueChange(final ValueChangeEvent<String> event) {
value.setValue(event.getValue());
executeOnChangeCommand();
}
});
box.setText(assertValue());
attachDisplayLengthHandler(box);
return box;
}
use of org.uberfire.ext.widgets.common.client.common.SmallLabel in project drools-wb by kiegroup.
the class ConstraintValueEditor method variableEditor.
private Widget variableEditor() {
if (this.readOnly) {
return new SmallLabel(this.constraint.getValue());
}
final ListBox box = new ListBox();
box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
List<String> bindingsInScope = this.model.getBoundVariablesInScope(this.constraint);
for (String var : bindingsInScope) {
final String binding = var;
helper.isApplicableBindingsInScope(var, new Callback<Boolean>() {
@Override
public void callback(final Boolean result) {
if (Boolean.TRUE.equals(result)) {
box.addItem(binding);
if (ConstraintValueEditor.this.constraint.getValue() != null && ConstraintValueEditor.this.constraint.getValue().equals(binding)) {
box.setSelectedIndex(box.getItemCount() - 1);
}
}
}
});
}
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
executeOnValueChangeCommand();
int selectedIndex = box.getSelectedIndex();
if (selectedIndex > 0) {
constraint.setValue(box.getItemText(selectedIndex));
} else {
constraint.setValue(null);
}
}
});
return box;
}
use of org.uberfire.ext.widgets.common.client.common.SmallLabel 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.SmallLabel in project drools-wb by kiegroup.
the class MethodParameterValueEditor method showTypeChoice.
protected void showTypeChoice() {
final FormStylePopup form = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.FieldValue());
// Literal values
Button lit = new Button(GuidedRuleEditorResources.CONSTANTS.LiteralValue());
lit.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
methodParameter.setNature(FieldNatureType.TYPE_LITERAL);
methodParameter.setValue("");
refresh();
form.hide();
}
});
form.addAttribute(GuidedRuleEditorResources.CONSTANTS.LiteralValue() + ":", widgets(lit, new InfoPopup(GuidedRuleEditorResources.CONSTANTS.Literal(), GuidedRuleEditorResources.CONSTANTS.LiteralValTip())));
canTheVariableButtonBeShown(new Callback<Boolean>() {
@Override
public void callback(Boolean result) {
if (result) {
addBoundVariableButton(form);
form.addRow(new HTML("<hr/>"));
form.addRow(new SmallLabel(GuidedRuleEditorResources.CONSTANTS.AdvancedSection()));
}
// Formulas
Button formula = new Button(GuidedRuleEditorResources.CONSTANTS.NewFormula());
formula.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
methodParameter.setNature(FieldNatureType.TYPE_FORMULA);
refresh();
form.hide();
}
});
form.addAttribute(GuidedRuleEditorResources.CONSTANTS.AFormula() + ":", widgets(formula, new InfoPopup(GuidedRuleEditorResources.CONSTANTS.AFormula(), GuidedRuleEditorResources.CONSTANTS.FormulaExpressionTip())));
form.show();
}
});
}
use of org.uberfire.ext.widgets.common.client.common.SmallLabel in project drools-wb by kiegroup.
the class MethodParameterValueEditor method addBoundVariableButton.
private void addBoundVariableButton(final FormStylePopup form) {
form.addRow(new HTML("<hr/>"));
form.addRow(new SmallLabel(GuidedRuleEditorResources.CONSTANTS.AdvancedSection()));
Button variableButton = new Button(GuidedRuleEditorResources.CONSTANTS.BoundVariable());
form.addAttribute(GuidedRuleEditorResources.CONSTANTS.BoundVariable() + ":", variableButton);
variableButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
methodParameter.setNature(FieldNatureType.TYPE_VARIABLE);
methodParameter.setValue("=");
refresh();
form.hide();
}
});
}
Aggregations