use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.
the class ActionValueEditorTest method testGetDropDownData.
@Test
public void testGetDropDownData() throws Exception {
final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
final String factType = "Car";
final String factField = "color";
final ActionFieldValue value = new ActionFieldValue() {
{
setField(factField);
}
};
final ActionFieldValue[] values = new ActionFieldValue[0];
final RuleModeller modeller = mock(RuleModeller.class);
doReturn(oracle).when(modeller).getDataModelOracle();
final EventBus eventBus = mock(EventBus.class);
final String variableType = DataType.TYPE_STRING;
final boolean readOnly = false;
actionValueEditor = new ActionValueEditor(factType, value, values, modeller, eventBus, variableType, readOnly);
// reset oracle due to calls in ActionValueEditor constructor
reset(oracle);
actionValueEditor.getDropDownData();
final Map<String, String> fieldValues = new HashMap<>();
verify(oracle).getEnums(eq(factType), eq(factField), eq(fieldValues));
}
use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.
the class DSLDropDownTest method testGetDropDown.
@Test
public void testGetDropDown() throws Exception {
final String fact = "Fact";
final String field = "field";
final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
final RuleModeller ruleModeller = mock(RuleModeller.class);
doReturn(oracle).when(ruleModeller).getDataModelOracle();
final String variableDefinition = "varName:type:" + fact + "." + field;
final DSLSentence dslSentence = mock(DSLSentence.class);
final DSLVariableValue dslVariableValue = mock(DSLVariableValue.class);
final boolean isMultipleSelect = false;
final Callback<DSLDropDown> updateEnumsCallback = mock(Callback.class);
testedDropDown = new DSLDropDown(ruleModeller, variableDefinition, dslSentence, dslVariableValue, isMultipleSelect, updateEnumsCallback);
// reset oracle due to calls in DSLDropDown constructor
reset(oracle);
testedDropDown.getDropDownData();
verify(oracle).getEnums(eq(fact), eq(field), anyMap());
}
use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.
the class FromAccumulateCompositeFactPatternWidget method showSourcePatternSelector.
/**
* Pops up the fact selector.
*/
protected void showSourcePatternSelector() {
final ListBox box = new ListBox();
AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
String[] facts = oracle.getFactTypes();
box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
for (int i = 0; i < facts.length; i++) {
box.addItem(facts[i]);
}
box.setSelectedIndex(0);
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
getFromAccumulatePattern().setSourcePattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
final Button fromBtn = new Button(HumanReadableConstants.INSTANCE.From());
final Button fromAccumulateBtn = new Button(HumanReadableConstants.INSTANCE.FromAccumulate());
final Button fromCollectBtn = new Button(HumanReadableConstants.INSTANCE.FromCollect());
final Button fromEntryPointBtn = new Button(HumanReadableConstants.INSTANCE.FromEntryPoint());
ClickHandler btnsClickHandler = new ClickHandler() {
public void onClick(ClickEvent event) {
Widget sender = (Widget) event.getSource();
if (sender == fromBtn) {
getFromAccumulatePattern().setSourcePattern(new FromCompositeFactPattern());
} else if (sender == fromAccumulateBtn) {
getFromAccumulatePattern().setSourcePattern(new FromAccumulateCompositeFactPattern());
} else if (sender == fromCollectBtn) {
getFromAccumulatePattern().setSourcePattern(new FromCollectCompositeFactPattern());
} else if (sender == fromEntryPointBtn) {
getFromAccumulatePattern().setSourcePattern(new FromEntryPointFactPattern());
} else {
throw new IllegalArgumentException("Unknown sender: " + sender);
}
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
};
fromBtn.addClickHandler(btnsClickHandler);
fromAccumulateBtn.addClickHandler(btnsClickHandler);
fromCollectBtn.addClickHandler(btnsClickHandler);
fromEntryPointBtn.addClickHandler(btnsClickHandler);
popup.addAttribute("", fromBtn);
popup.addAttribute("", fromAccumulateBtn);
popup.addAttribute("", fromCollectBtn);
popup.addAttribute("", fromEntryPointBtn);
popup.show();
}
use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.
the class FromAccumulateCompositeFactPatternWidget method showFactTypeSelector.
/**
* Pops up the fact selector.
*/
@Override
protected void showFactTypeSelector() {
final ListBox box = GWT.create(ListBox.class);
AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
String[] facts = oracle.getFactTypes();
box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
for (int i = 0; i < facts.length; i++) {
box.addItem(facts[i]);
}
box.setSelectedIndex(0);
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
pattern.setFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
popup.show();
}
use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.
the class ConditionColumnPlugin method assertDefaultValue.
void assertDefaultValue() {
final CellUtilities cellUtilities = new CellUtilities();
final AsyncPackageDataModelOracle oracle = presenter.getDataModelOracle();
final ColumnUtilities columnUtilities = new ColumnUtilities(model(), oracle);
final List<String> valueList = Arrays.asList(columnUtilities.getValueList(editingCol));
if (valueList.size() > 0) {
final String defaultValue = cellUtilities.asString(editingCol().getDefaultValue());
if (!valueList.contains(defaultValue)) {
editingCol.getDefaultValue().clearValues();
}
} else {
// Ensure the Default Value has been updated to represent the column's data-type.
final DTCellValue52 defaultValue = editingCol().getDefaultValue();
final DataType.DataTypes dataType = columnUtilities.getDataType(editingPattern(), editingCol());
cellUtilities.convertDTCellValueType(dataType, defaultValue);
}
}
Aggregations