use of org.uberfire.client.callbacks.Callback in project kie-wb-common by kiegroup.
the class KieMultipleDocumentEditorTest method testVersionRecordManagerSelectionChange.
@Test
@SuppressWarnings("unchecked")
public void testVersionRecordManagerSelectionChange() {
final TestDocument document = createTestDocument();
final ObservablePath path = document.getLatestPath();
registerDocument(document);
activateDocument(document);
final ArgumentCaptor<Callback> callbackArgumentCaptor = ArgumentCaptor.forClass(Callback.class);
verify(versionRecordManager, times(1)).init(eq(null), eq(path), callbackArgumentCaptor.capture());
final Callback<VersionRecord> callback = callbackArgumentCaptor.getValue();
assertNotNull(callback);
final VersionRecord versionRecord = mock(VersionRecord.class);
final ObservablePath newPath = mock(ObservablePath.class);
when(versionRecord.id()).thenReturn("id");
when(versionRecordManager.getCurrentPath()).thenReturn(newPath);
when(versionRecordManager.isLatest(versionRecord)).thenReturn(false);
callback.callback(versionRecord);
verify(versionRecordManager, times(1)).setVersion(eq("id"));
verify(document, times(1)).setVersion(eq("id"));
verify(document, times(1)).setCurrentPath(eq(newPath));
verify(document, times(1)).setReadOnly(eq(true));
verify(editor, times(1)).refreshDocument(document);
}
use of org.uberfire.client.callbacks.Callback in project drools-wb by kiegroup.
the class ColumnHeaderPopOverImpl method showSource.
private void showSource(final GuidedDecisionTableModellerView modellerView, final GuidedDecisionTableView.Presenter dtPresenter, final int uiColumnIndex) {
final BaseColumn column = dtPresenter.getModel().getExpandedColumns().get(uiColumnIndex);
final int screenX = getScreenX(modellerView, dtPresenter, uiColumnIndex);
final int screenY = getScreenY(modellerView, dtPresenter);
view.show((Callback<PopOverView.Content> callback) -> columnDefinitionFactory.generateColumnDefinition(dtPresenter, column, (String definition) -> callback.callback(new PopOverView.Content() {
@Override
public String getContent() {
return definition;
}
@Override
public int getX() {
return screenX;
}
@Override
public int getY() {
return screenY;
}
})));
}
use of org.uberfire.client.callbacks.Callback in project drools-wb by kiegroup.
the class BusinessCentralDMODataManagementStrategyTest method populateTestToolsWithoutFactTupleWithOnlyDataObjects.
@Test
public void populateTestToolsWithoutFactTupleWithOnlyDataObjects() {
factModelTreeHolderlocal.setFactModelTuple(null);
Map<String, List<String>> alreadyAssignedProperties = new HashMap<>();
doReturn(alreadyAssignedProperties).when(businessCentralDmoDataManagementStrategySpy).getPropertiesToHide(scenarioGridModelMock);
String[] notEmptyFactTypes = getRandomStringArray();
when(oracleMock.getFactTypes()).thenReturn(notEmptyFactTypes);
businessCentralDmoDataManagementStrategySpy.populateTestTools(testToolsPresenterMock, scenarioSimulationContextLocal, GridWidget.SIMULATION);
for (String factType : notEmptyFactTypes) {
verify(oracleMock, times(1)).getSuperType(eq(factType), callbackArgumentCaptor.capture());
callbackArgumentCaptor.getValue().callback("");
}
verify(businessCentralDmoDataManagementStrategySpy, times(1)).aggregatorCallback(eq(testToolsPresenterMock), anyInt(), any(SortedMap.class), eq(scenarioSimulationContextLocal), isA(List.class), eq(GridWidget.SIMULATION));
for (String factType : notEmptyFactTypes) {
verify(oracleMock, times(1)).getFieldCompletions(eq(factType), any(Callback.class));
}
}
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);
}
}
});
}
use of org.uberfire.client.callbacks.Callback in project drools-wb by kiegroup.
the class CallMethodWidget method showAddFieldPopup.
protected void showAddFieldPopup(final Widget w) {
final FormStylePopup popup = new FormStylePopup(TestScenarioAltedImages.INSTANCE.Wizard(), TestScenarioConstants.INSTANCE.ChooseAMethodToInvoke());
ListBox box = new ListBox();
box.addItem("...");
for (int i = 0; i < fieldCompletionTexts.length; i++) {
box.addItem(fieldCompletionTexts[i], fieldCompletionValues[i]);
}
box.setSelectedIndex(0);
popup.addAttribute(TestScenarioConstants.INSTANCE.ChooseAMethodToInvoke(), box);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
mCall.setState(ActionCallMethod.TYPE_DEFINED);
ListBox sourceW = (ListBox) event.getSource();
final String methodName = sourceW.getItemText(sourceW.getSelectedIndex());
final String methodNameWithParams = sourceW.getValue(sourceW.getSelectedIndex());
mCall.setMethodName(methodName);
oracle.getMethodParams(variableClass, methodNameWithParams, new Callback<List<String>>() {
@Override
public void callback(final List<String> fieldList) {
// String fieldType = oracle.getFieldType( variableClass, fieldName );
int i = 0;
for (String fieldParameter : fieldList) {
mCall.addFieldValue(new CallFieldValue(methodName, String.valueOf(i), fieldParameter));
i++;
}
parent.renderEditor();
popup.hide();
}
});
}
});
popup.show();
}
Aggregations