use of org.uberfire.client.callbacks.Callback in project drools-wb by kiegroup.
the class EnumLoaderUtilitiesTest method checkQueryExpressionDefinitionWithCaching.
@Test
public void checkQueryExpressionDefinitionWithCaching() {
final Callback<Map<String, String>> callback = (result) -> {
assertFalse(result.isEmpty());
assertEquals(2, result.size());
assertTrue(result.containsKey("one"));
assertTrue(result.containsKey("two"));
};
final String[] fixedList = { "one", "two" };
final String[] valuePairs = { "param1=a", "param2=b" };
final DropDownData enumDefinition = DropDownData.create("expression", valuePairs);
when(enumDropdownService.loadDropDownExpression(any(Path.class), any(String[].class), any(String.class))).thenReturn(fixedList);
// Call twice to check caching
enumLoaderUtilities.getEnums(enumDefinition, callback, presenter, onFetchCommand, onFetchCompleteCommand);
enumLoaderUtilities.getEnums(enumDefinition, callback, presenter, onFetchCommand, onFetchCompleteCommand);
verify(enumDropdownService, times(1)).loadDropDownExpression(any(Path.class), any(String[].class), any(String.class));
verify(onFetchCommand, times(1)).execute();
verify(onFetchCompleteCommand, times(1)).execute();
verify(enumLoaderUtilities, times(1)).convertDropDownData(any(String[].class));
verify(view, times(1)).batch();
}
use of org.uberfire.client.callbacks.Callback in project drools-wb by kiegroup.
the class EnumLoaderUtilitiesTest method checkFixedListDefinitionWithCaching.
@Test
public void checkFixedListDefinitionWithCaching() {
final Callback<Map<String, String>> callback = (result) -> {
assertFalse(result.isEmpty());
assertEquals(2, result.size());
assertTrue(result.containsKey("one"));
assertTrue(result.containsKey("two"));
};
final String[] fixedList = { "one", "two" };
final DropDownData enumDefinition = DropDownData.create(fixedList);
// Call twice to check caching
enumLoaderUtilities.getEnums(enumDefinition, callback, presenter, onFetchCommand, onFetchCompleteCommand);
enumLoaderUtilities.getEnums(enumDefinition, callback, presenter, onFetchCommand, onFetchCompleteCommand);
verify(enumDropdownService, never()).loadDropDownExpression(any(Path.class), any(String[].class), any(String.class));
verify(onFetchCommand, never()).execute();
verify(onFetchCompleteCommand, never()).execute();
verify(enumLoaderUtilities, times(1)).convertDropDownData(any(String[].class));
}
use of org.uberfire.client.callbacks.Callback in project drools-wb by kiegroup.
the class ActionCallMethodWidget method showAddFieldPopup.
protected void showAddFieldPopup(Widget w) {
final AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.ChooseAMethodToInvoke());
final ListBox box = new ListBox();
box.addItem("...");
for (int i = 0; i < fieldCompletionTexts.length; i++) {
box.addItem(fieldCompletionValues[i], fieldCompletionTexts[i]);
}
box.setSelectedIndex(0);
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.ChooseAMethodToInvoke(), box);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
final String methodNameWithParams = box.getItemText(box.getSelectedIndex());
oracle.getMethodParams(variableClass, methodNameWithParams, new Callback<List<String>>() {
@Override
public void callback(final List<String> methodParameters) {
final String methodName = box.getValue(box.getSelectedIndex());
model.setMethodName(methodName);
model.setState(ActionCallMethod.TYPE_DEFINED);
for (String methodParameter : methodParameters) {
model.addFieldValue(new ActionFieldFunction(methodName, null, methodParameter));
}
getModeller().refreshWidget();
popup.hide();
}
});
}
});
popup.show();
}
use of org.uberfire.client.callbacks.Callback in project drools-wb by kiegroup.
the class ExpressionBuilder method onStartPointChange.
private void onStartPointChange(final String value) {
setModified(true);
panel.clear();
final int dotPos = value.indexOf('.');
final String prefix = value.substring(0, dotPos);
final String attrib = value.substring(dotPos + 1);
if (prefix.equals(VARIABLE_VALUE_PREFIX)) {
FactPattern fact = getRuleModel().getLHSBoundFact(attrib);
ExpressionPart variable;
if (fact != null) {
variable = new ExpressionVariable(fact.getBoundName(), fact.getFactType());
} else {
// if the variable is not bound to a Fact Pattern then it must be bound to a Field
String lhsBindingType = getRuleModel().getLHSBindingType(attrib);
variable = new ExpressionFieldVariable(attrib, lhsBindingType);
}
expression.appendPart(variable);
onStartPointChangeUpdateWidget();
} else if (prefix.equals(GLOBAL_VARIABLE_VALUE_PREFIX)) {
ExpressionPartHelper.getExpressionPartForGlobalVariable(getDataModelOracle(), attrib, new Callback<ExpressionPart>() {
@Override
public void callback(final ExpressionPart part) {
expression.appendPart(part);
onStartPointChangeUpdateWidget();
}
});
}
}
use of org.uberfire.client.callbacks.Callback in project drools-wb by kiegroup.
the class FactPatternsPageViewImpl method initialiseChosenPatterns.
private void initialiseChosenPatterns() {
chosenPatternsContainer.add(chosenPatternWidget);
chosenPatternWidget.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
chosenPatternWidget.setMinimumWidth(270);
final Label lstEmpty = new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableWizardNoChosenPatterns());
lstEmpty.setStyleName(WizardCellListResources.INSTANCE.cellListStyle().cellListEmptyItem());
chosenPatternWidget.setEmptyListWidget(lstEmpty);
final MultiSelectionModel<Pattern52> selectionModel = new MultiSelectionModel<Pattern52>(System::identityHashCode);
chosenPatternWidget.setSelectionModel(selectionModel);
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(final SelectionChangeEvent event) {
chosenPatternSelections = selectionModel.getSelectedSet();
chosenTypesSelected(chosenPatternSelections);
}
private void chosenTypesSelected(final Set<Pattern52> ps) {
btnRemove.setEnabled(true);
if (ps.size() == 1) {
chosenPatternSelection = ps.iterator().next();
patternDefinition.setVisible(true);
validateBinding();
txtBinding.setEnabled(true);
txtBinding.setText(chosenPatternSelection.getBoundName());
txtEntryPoint.setEnabled(true);
txtEntryPoint.setText(chosenPatternSelection.getEntryPointName());
enableMoveUpButton();
enableMoveDownButton();
presenter.isPatternEvent(chosenPatternSelection, new Callback<Boolean>() {
@Override
public void callback(final Boolean result) {
if (Boolean.TRUE.equals(result)) {
ddCEPWindow.setCEPWindow(chosenPatternSelection);
cepWindowContainer.setVisible(true);
} else {
cepWindowContainer.setVisible(false);
}
}
});
} else {
chosenPatternSelection = null;
patternDefinition.setVisible(false);
txtBinding.setEnabled(false);
txtBinding.setText("");
txtEntryPoint.setEnabled(false);
txtEntryPoint.setText("");
btnMoveUp.setEnabled(false);
btnMoveDown.setEnabled(false);
cepWindowContainer.setVisible(false);
}
}
});
}
Aggregations