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(), "");
}
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);
}
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());
}
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);
}
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, "");
}
Aggregations