use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class MethodParameterValueEditor method boundFormulaTextBox.
private TextBox boundFormulaTextBox() {
final TextBox box = new TextBox();
box.setStyleName("constraint-value-Editor");
if (this.methodParameter.getValue() == null) {
box.setValue("");
} else {
box.setValue(this.methodParameter.getValue());
}
box.addKeyUpHandler(new KeyUpHandler() {
@Override
public void onKeyUp(KeyUpEvent event) {
setMethodParameterValue(box.getValue());
}
});
return box;
}
use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class MethodParameterValueEditor method boundLiteralTextBox.
private TextBox boundLiteralTextBox() {
final TextBox box = TextBoxFactory.getTextBox(methodParameter.getType());
// We need both handlers, since The textbox TextBoxFactory can return a box that changes the value in itself
box.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
setMethodParameterValue(box.getValue());
}
});
box.addKeyUpHandler(new KeyUpHandler() {
@Override
public void onKeyUp(KeyUpEvent event) {
setMethodParameterValue(box.getValue());
}
});
box.setStyleName("constraint-value-Editor");
if (this.methodParameter.getValue() != null || this.methodParameter.getValue().isEmpty()) {
box.setValue(this.methodParameter.getValue());
}
// This updates the model
setMethodParameterValue(box.getValue());
return box;
}
use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class RuleAttributeWidget method getEditorWidget.
private Widget getEditorWidget(final RuleAttribute at, final int idx, final boolean isReadOnly) {
Widget editor = null;
final String attributeName = at.getAttributeName();
if (attributeName.equals(RULEFLOW_GROUP_ATTR) || attributeName.equals(AGENDA_GROUP_ATTR) || attributeName.equals(ACTIVATION_GROUP_ATTR) || attributeName.equals(TIMER_ATTR) || attributeName.equals(CALENDARS_ATTR)) {
final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_STRING);
tb.setEnabled(!isReadOnly);
if (!isReadOnly) {
tb.addValueChangeHandler(new ValueChangeHandler<String>() {
public void onValueChange(ValueChangeEvent<String> event) {
at.setValue(tb.getValue());
}
});
}
tb.setValue(at.getValue());
editor = tb;
} else if (attributeName.equals(SALIENCE_ATTR)) {
final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_INTEGER);
tb.setEnabled(!isReadOnly);
if (!isReadOnly) {
tb.addValueChangeHandler(new ValueChangeHandler<String>() {
public void onValueChange(ValueChangeEvent<String> event) {
at.setValue(tb.getValue());
}
});
}
tb.setValue(at.getValue());
editor = tb;
} else if (attributeName.equals(DURATION_ATTR)) {
final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_LONG);
tb.setEnabled(!isReadOnly);
if (!isReadOnly) {
tb.addValueChangeHandler(new ValueChangeHandler<String>() {
public void onValueChange(ValueChangeEvent<String> event) {
at.setValue(tb.getValue());
}
});
}
tb.setValue(at.getValue());
editor = tb;
} else if (attributeName.equals(NO_LOOP_ATTR) || attributeName.equals(LOCK_ON_ACTIVE_ATTR) || attributeName.equals(AUTO_FOCUS_ATTR) || attributeName.equals(ENABLED_ATTR)) {
editor = checkBoxEditor(at, isReadOnly);
} else if (attributeName.equals(DATE_EFFECTIVE_ATTR) || attributeName.equals(DATE_EXPIRES_ATTR)) {
if (isReadOnly) {
final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_STRING);
tb.setValue(at.getValue());
tb.setEnabled(false);
} else {
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()));
at.setValue(sDate);
}
});
datePicker.setFormat(DATE_FORMAT);
datePicker.setValue(assertDateValue(at));
editor = datePicker;
}
} else if (attributeName.equals(DIALECT_ATTR)) {
final ListBox lb = new ListBox();
lb.addItem(DIALECTS[0]);
lb.addItem(DIALECTS[1]);
lb.setEnabled(!isReadOnly);
if (!isReadOnly) {
lb.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
final int selectedIndex = lb.getSelectedIndex();
if (selectedIndex < 0) {
return;
}
at.setValue(lb.getValue(selectedIndex));
}
});
}
if (at.getValue() == null || at.getValue().isEmpty()) {
lb.setSelectedIndex(1);
at.setValue(DIALECTS[1]);
} else if (at.getValue().equals(DIALECTS[0])) {
lb.setSelectedIndex(0);
} else if (at.getValue().equals(DIALECTS[1])) {
lb.setSelectedIndex(1);
} else {
lb.setSelectedIndex(1);
at.setValue(DIALECTS[1]);
}
editor = lb;
}
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
if (editor != null) {
horiz.add(editor);
if (!isReadOnly) {
horiz.add(getRemoveIcon(idx));
}
}
return horiz;
}
use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class PopupCreator method doBindingEditor.
/**
* This adds in (optionally) the editor for changing the bound variable
* name. If its a bindable pattern, it will show the editor, if it is
* already bound, and the name is used, it should not be editable.
*/
private void doBindingEditor(final FormStylePopup popup) {
if (bindable || !(modeller.getModel().isBoundFactUsed(pattern.getBoundName()))) {
HorizontalPanel varName = new HorizontalPanel();
final TextBox varTxt = new BindingTextBox();
if (pattern.getBoundName() == null) {
varTxt.setText("");
} else {
varTxt.setText(pattern.getBoundName());
}
((InputElement) varTxt.getElement().cast()).setSize(6);
varName.add(varTxt);
Button bindVar = new Button(HumanReadableConstants.INSTANCE.Set());
bindVar.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String var = varTxt.getText();
if (modeller.isVariableNameUsed(var)) {
Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
return;
}
pattern.setBoundName(varTxt.getText());
modeller.refreshWidget();
popup.hide();
}
});
varName.add(bindVar);
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.VariableName(), varName);
}
}
use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class ActionInsertFactWidget method showAddFieldPopup.
protected void showAddFieldPopup(Widget w) {
final AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.AddAField());
final ListBox box = new ListBox();
box.addItem("...");
final ModelField[] availableFieldCompletions = ModelFieldUtil.getAvailableFieldCompletions(fieldCompletions, model);
final boolean isEnabled = !isReadOnly() && availableFieldCompletions.length > 0;
if (availableFieldCompletions.length > 0) {
for (int i = 0; i < availableFieldCompletions.length; i++) {
box.addItem(availableFieldCompletions[i].getName());
}
}
box.setSelectedIndex(0);
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddField(), box);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String fieldName = box.getItemText(box.getSelectedIndex());
String fieldType = oracle.getFieldType(model.getFactType(), fieldName);
model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
/*
* Propose a textBox to the user to make him set a variable name
*/
final HorizontalPanel vn = new HorizontalPanel();
final TextBox varName = new TextBox();
if (this.model.getBoundName() != null) {
varName.setText(this.model.getBoundName());
}
final Button ok = new Button(HumanReadableConstants.INSTANCE.Set());
vn.add(varName);
vn.add(ok);
ok.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String var = varName.getText();
if (getModeller().isVariableNameUsed(var) && ((model.getBoundName() != null && model.getBoundName().equals(var) == false) || model.getBoundName() == null)) {
Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
return;
}
model.setBoundName(var);
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.BoundVariable(), vn);
box.setEnabled(isEnabled);
varName.setEnabled(isEnabled);
ok.setEnabled(isEnabled);
popup.show();
}
Aggregations