Search in sources :

Example 1 with RemoteCallback

use of org.jboss.errai.common.client.api.RemoteCallback in project drools-wb by kiegroup.

the class GuidedRuleTemplateEditorViewImpl method setContent.

@Override
public void setContent(final TemplateModel model, final AsyncPackageDataModelOracle oracle, final Caller<RuleNamesService> ruleNamesService, final EventBus eventBus, final boolean isReadOnly) {
    this.modeller = new RuleModeller(model, oracle, new TemplateModellerWidgetFactory(), eventBus, isReadOnly);
    panel.setWidget(modeller);
    ruleNamesService.call(new RemoteCallback<Collection<String>>() {

        @Override
        public void callback(Collection<String> ruleNames) {
            modeller.setRuleNamesForPackage(ruleNames);
        }
    }).getRuleNames(oracle.getResourcePath(), model.getPackageName());
}
Also used : RuleModeller(org.drools.workbench.screens.guided.rule.client.editor.RuleModeller) Collection(java.util.Collection) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 2 with RemoteCallback

use of org.jboss.errai.common.client.api.RemoteCallback 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 3 with RemoteCallback

use of org.jboss.errai.common.client.api.RemoteCallback 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 RemoteCallback

use of org.jboss.errai.common.client.api.RemoteCallback 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 RemoteCallback

use of org.jboss.errai.common.client.api.RemoteCallback in project drools-wb by kiegroup.

the class GuidedRuleEditorPresenter method getModelSuccessCallback.

private RemoteCallback<GuidedEditorContent> getModelSuccessCallback() {
    return new RemoteCallback<GuidedEditorContent>() {

        @Override
        public void callback(final GuidedEditorContent content) {
            // Path is set to null when the Editor is closed (which can happen before async calls complete).
            if (versionRecordManager.getCurrentPath() == null) {
                return;
            }
            GuidedRuleEditorPresenter.this.model = content.getModel();
            final PackageDataModelOracleBaselinePayload dataModel = content.getDataModel();
            oracle = oracleFactory.makeAsyncPackageDataModelOracle(versionRecordManager.getCurrentPath(), model, dataModel);
            resetEditorPages(content.getOverview());
            addSourcePage();
            addImportsTab(importsWidget);
            List<RuleModellerActionPlugin> actionPlugins = new ArrayList<>();
            actionPluginInstance.forEach(actionPlugins::add);
            view.setContent(model, actionPlugins, oracle, getRuleNamesService(), isReadOnly, isDSLEnabled);
            importsWidget.setContent(oracle, model.getImports(), isReadOnly);
            view.hideBusyIndicator();
            createOriginalHash(model);
        }
    };
}
Also used : PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) GuidedEditorContent(org.drools.workbench.screens.guided.rule.model.GuidedEditorContent) RuleModellerActionPlugin(org.drools.workbench.screens.guided.rule.client.editor.plugin.RuleModellerActionPlugin) ArrayList(java.util.ArrayList) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Aggregations

RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)11 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)5 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)4 ObservablePath (org.uberfire.backend.vfs.ObservablePath)4 List (java.util.List)2 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)2 ValidationMessage (org.guvnor.common.services.shared.validation.model.ValidationMessage)2 HasBusyIndicatorDefaultErrorCallback (org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback)2 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)2 IsWidget (com.google.gwt.user.client.ui.IsWidget)1 ProvidesResize (com.google.gwt.user.client.ui.ProvidesResize)1 RequiresResize (com.google.gwt.user.client.ui.RequiresResize)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Event (javax.enterprise.event.Event)1 ConversionMessage (org.drools.workbench.models.guided.dtable.shared.conversion.ConversionMessage)1 ConversionResult (org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult)1 ConversionMessageWidget (org.drools.workbench.screens.dtablexls.client.widgets.ConversionMessageWidget)1