use of org.gwtbootstrap3.client.ui.TextBox 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.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class MethodParameterCallValueEditor method boundTextBox.
private TextBox boundTextBox(final CallFieldValue c) {
final TextBox box = TextBoxFactory.getTextBox(methodParameter.type);
box.setStyleName("constraint-value-Editor");
if (c.value == null) {
box.setText("");
} else {
if (c.value.trim().equals("")) {
c.value = "";
}
box.setText(c.value);
}
if (c.value == null || c.value.length() < 5) {
((InputElement) box.getElement().cast()).setSize(6);
} else {
((InputElement) box.getElement().cast()).setSize(c.value.length() - 1);
}
box.addValueChangeHandler(new ValueChangeHandler<String>() {
public void onValueChange(final ValueChangeEvent<String> event) {
c.value = event.getValue();
}
});
box.addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) {
((InputElement) box.getElement().cast()).setSize(box.getText().length());
}
});
return box;
}
use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class VerifyRulesFiredWidget method render.
private FlexTable render(final FixtureList rfl, final Scenario sc) {
FlexTable data = new FlexTable();
for (int i = 0; i < rfl.size(); i++) {
final VerifyRuleFired v = (VerifyRuleFired) rfl.get(i);
if (showResults && v.getSuccessResult() != null) {
if (!v.getSuccessResult().booleanValue()) {
data.setWidget(i, 0, new Image(CommonImages.INSTANCE.warning()));
data.setWidget(i, 4, new HTML(TestScenarioConstants.INSTANCE.ActualResult(v.getActualResult().toString())));
data.getCellFormatter().addStyleName(i, 4, // NON-NLS
"testErrorValue");
} else {
data.setWidget(i, 0, new Image(TestScenarioImages.INSTANCE.testPassed()));
}
}
data.setWidget(i, 1, new SmallLabel(v.getRuleName() + ":"));
data.getFlexCellFormatter().setAlignment(i, 1, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE);
final ListBox b = new ListBox();
b.addItem(TestScenarioConstants.INSTANCE.firedAtLeastOnce(), "y");
b.addItem(TestScenarioConstants.INSTANCE.didNotFire(), "n");
b.addItem(TestScenarioConstants.INSTANCE.firedThisManyTimes(), "e");
final TextBox num = new TextBox();
((InputElement) num.getElement().cast()).setSize(5);
if (v.getExpectedFire() != null) {
b.setSelectedIndex((v.getExpectedFire().booleanValue()) ? 0 : 1);
num.setVisible(false);
} else {
b.setSelectedIndex(2);
String xc = (v.getExpectedCount() != null) ? "" + v.getExpectedCount().intValue() : "0";
num.setText(xc);
}
b.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String s = b.getValue(b.getSelectedIndex());
if (s.equals("y") || s.equals("n")) {
num.setVisible(false);
v.setExpectedFire((s.equals("y")) ? Boolean.TRUE : Boolean.FALSE);
v.setExpectedCount(null);
} else {
num.setVisible(true);
v.setExpectedFire(null);
num.setText("1");
v.setExpectedCount(Integer.valueOf(1));
}
}
});
b.addItem(TestScenarioConstants.INSTANCE.ChooseDotDotDot());
num.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
v.setExpectedCount(Integer.valueOf(num.getText()));
}
});
HorizontalPanel h = new HorizontalPanel();
h.add(b);
h.add(num);
data.setWidget(i, 2, h);
Button del = new Button();
del.setIcon(IconType.TRASH);
del.setTitle(TestScenarioConstants.INSTANCE.RemoveThisRuleExpectation());
del.addClickHandler(clickEvent -> {
if (Window.confirm(TestScenarioConstants.INSTANCE.AreYouSureYouWantToRemoveThisRuleExpectation())) {
rfl.remove(v);
sc.removeFixture(v);
outer.setWidget(1, 0, render(rfl, sc));
}
});
data.setWidget(i, 3, del);
// we only want numbers here...
num.addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
if (Character.isLetter(event.getCharCode())) {
((TextBox) event.getSource()).cancelKey();
}
}
});
}
ScenarioUtils.addBottomAndRightPaddingToTableCells(data);
return data;
}
use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class DTCellValueWidgetFactory method makeTextBox.
private TextBox makeTextBox(final DTCellValue52 value) {
TextBox tb = new TextBox();
tb.setValue(value.getStringValue());
// Wire up update handler
tb.setEnabled(!isReadOnly);
if (!isReadOnly) {
tb.addValueChangeHandler(new ValueChangeHandler<String>() {
public void onValueChange(ValueChangeEvent<String> event) {
value.setStringValue(event.getValue());
}
});
}
return tb;
}
use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class DefaultValueWidgetFactory method getDefaultValueWidget.
// BZ-996932: Added value change notifications.
public static Widget getDefaultValueWidget(final AttributeCol52 ac, final boolean isReadOnly, final DefaultValueChangedEventHandler defaultValueChangedEventHandler) {
Widget editor = null;
final String attributeName = ac.getAttribute();
if (attributeName.equals(RuleAttributeWidget.RULEFLOW_GROUP_ATTR) || attributeName.equals(RuleAttributeWidget.AGENDA_GROUP_ATTR) || 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) {
DTCellValue52 editedDefaultValue = defaultValue.cloneDefaultValueCell();
editedDefaultValue.setStringValue(tb.getValue());
defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, editedDefaultValue));
}
});
}
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) {
DTCellValue52 editedDefaultValue = defaultValue.cloneDefaultValueCell();
try {
editedDefaultValue.setNumericValue(Integer.valueOf(event.getValue()));
} catch (NumberFormatException nfe) {
editedDefaultValue.setNumericValue(0);
tb.setValue("0");
} finally {
defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, editedDefaultValue));
}
}
});
}
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) {
DTCellValue52 editedDefaultValue = defaultValue.cloneDefaultValueCell();
try {
editedDefaultValue.setNumericValue(Long.valueOf(event.getValue()));
} catch (NumberFormatException nfe) {
editedDefaultValue.setNumericValue(0L);
tb.setValue("0");
} finally {
defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, editedDefaultValue));
}
}
});
}
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) {
DTCellValue52 editedDefaultValue = defaultValue.cloneDefaultValueCell();
editedDefaultValue.setBooleanValue(cb.getValue());
defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, editedDefaultValue));
}
});
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 DatePicker datePicker = new DatePicker();
// Wire up update handler
datePicker.addChangeDateHandler((e) -> {
DTCellValue52 editedDefaultValue = defaultValue.cloneDefaultValueCell();
editedDefaultValue.setDateValue(datePicker.getValue());
defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, editedDefaultValue));
});
final Date dateValue = defaultValue.getDateValue();
datePicker.setFormat(DATE_FORMAT);
datePicker.setValue(dateValue);
editor = datePicker;
}
} 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 editedDefaultValue = defaultValue.cloneDefaultValueCell();
editedDefaultValue.setStringValue(lb.getValue(selectedIndex));
defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, editedDefaultValue));
}
});
}
if (stringValue == null || stringValue.isEmpty()) {
lb.setSelectedIndex(1);
defaultValue.setStringValue(RuleAttributeWidget.DIALECTS[1]);
} else if (stringValue.equals(RuleAttributeWidget.DIALECTS[0])) {
lb.setSelectedIndex(0);
} else if (stringValue.equals(RuleAttributeWidget.DIALECTS[1])) {
lb.setSelectedIndex(1);
} else {
lb.setSelectedIndex(1);
defaultValue.setStringValue(RuleAttributeWidget.DIALECTS[1]);
}
editor = lb;
}
return editor;
}
Aggregations