use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 in project drools-wb by kiegroup.
the class DTCellValueWidgetFactory method makeNumericFloatTextBox.
private AbstractRestrictedEntryTextBox makeNumericFloatTextBox(final DTCellValue52 value) {
final AbstractRestrictedEntryTextBox tb = new NumericFloatTextBox(allowEmptyValues);
final Float numericValue = (Float) value.getNumericValue();
tb.setValue(numericValue == null ? "" : numericValue.toString());
// Wire up update handler
tb.setEnabled(!isReadOnly);
addNumericTextBoxChangeHandler(tb, value, (input -> Float.valueOf(input)), (Float) null, new Float("0"));
return tb;
}
use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 in project drools-wb by kiegroup.
the class DTCellValueWidgetFactory method makeNumericDoubleTextBox.
private AbstractRestrictedEntryTextBox makeNumericDoubleTextBox(final DTCellValue52 value) {
final AbstractRestrictedEntryTextBox tb = new NumericDoubleTextBox(allowEmptyValues);
final Double numericValue = (Double) value.getNumericValue();
tb.setValue(numericValue == null ? "" : numericValue.toString());
// Wire up update handler
tb.setEnabled(!isReadOnly);
addNumericTextBoxChangeHandler(tb, value, (input -> Double.valueOf(input)), (Double) null, new Double("0"));
return tb;
}
use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 in project drools-wb by kiegroup.
the class DTCellValueWidgetFactory method makeNumericBigIntegerTextBox.
private AbstractRestrictedEntryTextBox makeNumericBigIntegerTextBox(final DTCellValue52 value) {
final AbstractRestrictedEntryTextBox tb = new NumericBigIntegerTextBox(allowEmptyValues);
final BigInteger numericValue = (BigInteger) value.getNumericValue();
tb.setValue(numericValue == null ? "" : numericValue.toString());
// Wire up update handler
tb.setEnabled(!isReadOnly);
addNumericTextBoxChangeHandler(tb, value, (input -> new BigInteger(input)), (BigInteger) null, BigInteger.ZERO);
return tb;
}
use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 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;
}
use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 in project drools-wb by kiegroup.
the class GuidedDecisionTablePresenter method initialiseModels.
// Copy Model data to UiModel.
void initialiseModels() {
initialiseLegacyColumnDataTypes();
final List<BaseColumn> modelColumns = model.getExpandedColumns();
for (BaseColumn column : modelColumns) {
initialiseColumn(column);
}
for (List<DTCellValue52> row : model.getData()) {
initialiseRow(modelColumns, row);
}
setOriginalHashCode(model.hashCode());
}
Aggregations