Search in sources :

Example 21 with Callback

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);
}
Also used : RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) Callback(org.uberfire.client.callbacks.Callback) VersionRecord(org.uberfire.java.nio.base.version.VersionRecord) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 22 with Callback

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;
        }
    })));
}
Also used : Callback(org.uberfire.client.callbacks.Callback) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 23 with Callback

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));
    }
}
Also used : Callback(org.uberfire.client.callbacks.Callback) HashMap(java.util.HashMap) SortedMap(java.util.SortedMap) ArrayList(java.util.ArrayList) List(java.util.List) Matchers.anyString(org.mockito.Matchers.anyString) AbstractScenarioSimulationEditorTest(org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest) Test(org.junit.Test)

Example 24 with Callback

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);
            }
        }
    });
}
Also used : Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) Callback(org.uberfire.client.callbacks.Callback) MultiSelectionModel(com.google.gwt.view.client.MultiSelectionModel) Label(org.gwtbootstrap3.client.ui.Label) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent)

Example 25 with Callback

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();
}
Also used : Callback(org.uberfire.client.callbacks.Callback) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) List(java.util.List) ListBox(org.gwtbootstrap3.client.ui.ListBox) CallFieldValue(org.drools.workbench.models.testscenarios.shared.CallFieldValue)

Aggregations

Callback (org.uberfire.client.callbacks.Callback)31 Test (org.junit.Test)21 List (java.util.List)7 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 HashMap (java.util.HashMap)4 Before (org.junit.Before)4 Path (org.uberfire.backend.vfs.Path)4 SortedMap (java.util.SortedMap)3 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)3 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)3 GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)3 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)3 AbstractScenarioSimulationEditorTest (org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest)3 Caller (org.jboss.errai.common.client.api.Caller)3 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)3 Assert.assertEquals (org.junit.Assert.assertEquals)3 Assert.assertFalse (org.junit.Assert.assertFalse)3 Assert.assertTrue (org.junit.Assert.assertTrue)3 RunWith (org.junit.runner.RunWith)3