Search in sources :

Example 1 with HasBusyIndicatorDefaultErrorCallback

use of org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback in project drools-wb by kiegroup.

the class NewGuidedDecisionTableGraphHandler method create.

@Override
public void create(final Package pkg, final String baseFileName, final NewResourcePresenter presenter) {
    busyIndicatorView.showBusyIndicator(CommonConstants.INSTANCE.Saving());
    graphService.call(getSuccessCallback(presenter), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)).create(pkg.getPackageMainResourcesPath(), buildFileName(baseFileName, resourceType), new GuidedDecisionTableEditorGraphModel(), "");
}
Also used : GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback)

Example 2 with HasBusyIndicatorDefaultErrorCallback

use of org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenter method onSave.

@Override
public void onSave(final GuidedDecisionTableView.Presenter dtPresenter, final String commitMessage) {
    final ObservablePath path = dtPresenter.getCurrentPath();
    final GuidedDecisionTable52 model = dtPresenter.getModel();
    final Metadata metadata = dtPresenter.getOverview().getMetadata();
    service.call(getSaveSuccessCallback(dtPresenter, model.hashCode()), new HasBusyIndicatorDefaultErrorCallback(view)).saveAndUpdateGraphEntries(path, model, metadata, commitMessage);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) ObservablePath(org.uberfire.backend.vfs.ObservablePath)

Example 3 with HasBusyIndicatorDefaultErrorCallback

use of org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback 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 4 with HasBusyIndicatorDefaultErrorCallback

use of org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback in project drools-wb by kiegroup.

the class NewGuidedDecisionTableWizardHelper method createNewGuidedDecisionTable.

/**
 * Presents the {@link NewGuidedDecisionTableWizard} to Users to creates a new Guided Decision Table.
 *
 * @param contextPath           The base path where the Decision Table will be created. Cannot be null.
 * @param baseFileName          The base file name of the new Decision Table. Cannot be null.
 * @param tableFormat           The format of the Decision Table. Cannot be null.
 * @param view                  A {@link HasBusyIndicator} to handle status messages. Cannot be null.
 * @param onSaveSuccessCallback Called when the new Decision Table has successfully been created. Cannot be null.
 */
public void createNewGuidedDecisionTable(final Path contextPath, final String baseFileName, final GuidedDecisionTable52.TableFormat tableFormat, final GuidedDecisionTable52.HitPolicy hitPolicy, final HasBusyIndicator view, final RemoteCallback<Path> onSaveSuccessCallback) {
    PortablePreconditions.checkNotNull("contextPath", contextPath);
    PortablePreconditions.checkNotNull("baseFileName", baseFileName);
    PortablePreconditions.checkNotNull("tableFormat", tableFormat);
    PortablePreconditions.checkNotNull("hitPolicy", hitPolicy);
    PortablePreconditions.checkNotNull("view", view);
    PortablePreconditions.checkNotNull("onSaveSuccessCallback", onSaveSuccessCallback);
    dtService.call(new RemoteCallback<PackageDataModelOracleBaselinePayload>() {

        @Override
        public void callback(final PackageDataModelOracleBaselinePayload dataModel) {
            final AsyncPackageDataModelOracle oracle = oracleFactory.makeAsyncPackageDataModelOracle(contextPath, dataModel);
            // NewGuidedDecisionTableHandler is @ApplicationScoped and so has a single instance of the NewGuidedDecisionTableWizard injected.
            // The Wizard maintains state and hence multiple use of the same Wizard instance leads to the Wizard UI showing stale values.
            // Rather than have the Wizard initialise fields when shown I elected to create new instances whenever needed.
            wizard = beanManager.lookupBean(NewGuidedDecisionTableWizard.class).getInstance();
            wizard.setContent(contextPath, baseFileName, tableFormat, hitPolicy, oracle, new NewGuidedDecisionTableWizard.GuidedDecisionTableWizardHandler() {

                @Override
                public void save(final Path contextPath, final String baseFileName, final GuidedDecisionTable52 model) {
                    destroyWizard();
                    oracleFactory.destroy(oracle);
                    view.showBusyIndicator(CommonConstants.INSTANCE.Saving());
                    dtService.call((Path path) -> {
                        view.hideBusyIndicator();
                        onSaveSuccessCallback.callback(path);
                    }, new HasBusyIndicatorDefaultErrorCallback(view)).create(contextPath, buildFileName(baseFileName), model, "");
                }

                private String buildFileName(final String baseFileName) {
                    final String suffix = dtResourceType.getSuffix();
                    final String prefix = dtResourceType.getPrefix();
                    final String extension = !(suffix == null || "".equals(suffix)) ? "." + dtResourceType.getSuffix() : "";
                    if (baseFileName.endsWith(extension)) {
                        return prefix + baseFileName;
                    }
                    return prefix + baseFileName + extension;
                }

                @Override
                public void destroyWizard() {
                    if (wizard != null) {
                        beanManager.destroyBean(wizard);
                        wizard = null;
                    }
                }
            });
            wizard.start();
        }
    }).loadDataModel(contextPath);
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) Path(org.uberfire.backend.vfs.Path) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) NewGuidedDecisionTableWizard(org.drools.workbench.screens.guided.dtable.client.wizard.table.NewGuidedDecisionTableWizard) HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 5 with HasBusyIndicatorDefaultErrorCallback

use of org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback in project drools-wb by kiegroup.

the class NewGuidedDecisionTreeHandler method create.

@Override
public void create(final Package pkg, final String baseFileName, final NewResourcePresenter presenter) {
    final GuidedDecisionTree model = new GuidedDecisionTree();
    model.setTreeName(baseFileName);
    busyIndicatorView.showBusyIndicator(CommonConstants.INSTANCE.Saving());
    service.call(getSuccessCallback(presenter), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)).create(pkg.getPackageMainResourcesPath(), buildFileName(baseFileName, resourceType), model, "");
}
Also used : HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree)

Aggregations

HasBusyIndicatorDefaultErrorCallback (org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback)17 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)3 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)3 HashMap (java.util.HashMap)2 ObservablePath (org.uberfire.backend.vfs.ObservablePath)2 Path (org.uberfire.backend.vfs.Path)2 ClientResourceType (org.uberfire.client.workbench.type.ClientResourceType)2 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)1 MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)1 GuidedDecisionTree (org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree)1 ScoreCardModel (org.drools.workbench.models.guided.scorecard.shared.ScoreCardModel)1 TemplateModel (org.drools.workbench.models.guided.template.shared.TemplateModel)1 Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)1 GlobalsModel (org.drools.workbench.screens.globals.model.GlobalsModel)1 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)1