Search in sources :

Example 6 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenter method onSourceTabSelected.

@Override
public void onSourceTabSelected(final GuidedDecisionTableView.Presenter dtPresenter) {
    final ObservablePath path = dtPresenter.getCurrentPath();
    final GuidedDecisionTable52 model = dtPresenter.getModel();
    service.call(new RemoteCallback<String>() {

        @Override
        public void callback(String source) {
            updateSource(source);
        }
    }, getCouldNotGenerateSourceErrorCallback()).toSource(path, model);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) ObservablePath(org.uberfire.backend.vfs.ObservablePath)

Example 7 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.

the class EnumLoaderUtilities method getEnumsFromServer.

private void getEnumsFromServer(final DropDownData enumDefinition, final Callback<Map<String, String>> callback, final GuidedDecisionTablePresenter presenter, final Command onFetchCommand, final Command onFetchCompleteCommand) {
    final String key = buildKey(enumDefinition);
    if (enumCache.containsKey(key)) {
        callback.callback(enumCache.get(key));
        return;
    }
    // Cache empty value to prevent recurrent calls to the server for the same data.
    // The View will be redrawn once by the batch() command in the success callback.
    enumCache.put(key, Collections.emptyMap());
    final GuidedDecisionTableView view = presenter.getView();
    final ObservablePath currentPath = presenter.getCurrentPath();
    onFetchCommand.execute();
    enumDropdownService.call(new RemoteCallback<String[]>() {

        @Override
        public void callback(final String[] items) {
            onFetchCompleteCommand.execute();
            final Map<String, String> convertedDropDownData = convertDropDownData(items);
            enumCache.put(key, convertedDropDownData);
            callback.callback(convertedDropDownData);
            view.batch();
        }
    }, new HasBusyIndicatorDefaultErrorCallback(view)).loadDropDownExpression(currentPath, enumDefinition.getValuePairs(), enumDefinition.getQueryExpression());
}
Also used : HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) ObservablePath(org.uberfire.backend.vfs.ObservablePath)

Example 8 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.

the class DecisionTableXLSEditorPresenterTest method testOnUploadSuccess.

@Test
public void testOnUploadSuccess() {
    final ObservablePath path = mock(ObservablePath.class);
    doReturn(null).when(versionRecordManager).getCurrentPath();
    doReturn(path).when(versionRecordManager).getPathToLatest();
    presenter.onUploadSuccess();
    verify(versionRecordManager).getPathToLatest();
    verify(versionRecordManager, never()).getCurrentPath();
    verify(versionRecordManager).reloadVersions(path);
}
Also used : ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 9 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.

the class GuidedDecisionTableLockManagerImpl method fireChangeTitleEvent.

@Override
public void fireChangeTitleEvent() {
    final Path path = getLockInfo().getFile();
    if (path == null) {
        return;
    }
    presenter.getActiveDecisionTable().ifPresent(dtPresenter -> {
        final ObservablePath dtPath = dtPresenter.getCurrentPath();
        if (dtPath == null) {
            return;
        }
        if (dtPath.equals(path)) {
            super.fireChangeTitleEvent();
        }
    });
}
Also used : ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) ObservablePath(org.uberfire.backend.vfs.ObservablePath)

Example 10 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerPresenterTest method refreshingDecisionTableRetainsExistingLocation.

@Test
public void refreshingDecisionTableRetainsExistingLocation() {
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable();
    final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent();
    final GuidedDecisionTableView dtView = dtPresenter.getView();
    final ObservablePath path = mock(ObservablePath.class);
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    final Point2D dtLocation = new Point2D(100, 100);
    when(dtView.getLocation()).thenReturn(dtLocation);
    final ArgumentCaptor<Command> afterRemovalCommandCaptor = ArgumentCaptor.forClass(Command.class);
    presenter.refreshDecisionTable(dtPresenter, path, placeRequest, dtContent, false);
    verify(dtView, times(1)).getLocation();
    verify(view, times(1)).removeDecisionTable(eq(dtView), afterRemovalCommandCaptor.capture());
    final Command afterRemovalCommand = afterRemovalCommandCaptor.getValue();
    assertNotNull(afterRemovalCommand);
    afterRemovalCommand.execute();
    verify(dtView, times(1)).setLocation(eq(dtLocation));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) Point2D(com.ait.lienzo.client.core.types.Point2D) Command(com.google.gwt.user.client.Command) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Aggregations

ObservablePath (org.uberfire.backend.vfs.ObservablePath)51 Test (org.junit.Test)38 PlaceRequest (org.uberfire.mvp.PlaceRequest)33 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)29 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)27 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)15 GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)13 GuidedDecisionTableEditorGraphContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent)13 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)11 DecisionTableSelectedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent)11 Path (org.uberfire.backend.vfs.Path)9 OverviewWidgetPresenter (org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter)7 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)7 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)6 GuidedDecisionTableGraphEntry (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry)5 GuidedDecisionTableEditorGraphModel (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)4 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)4 List (java.util.List)3 Overview (org.guvnor.common.services.shared.metadata.model.Overview)3 ValidationMessage (org.guvnor.common.services.shared.validation.model.ValidationMessage)3