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