use of org.jowidgets.cap.ui.tools.execution.AbstractUiResultCallback in project jo-client-platform by jo-source.
the class BeanLinkCreatorCommand method createResultCallback.
private IResultCallback<List<IBeanDto>> createResultCallback(final List<IBeanProxy<SOURCE_BEAN_TYPE>> selection, final IExecutionContext executionContext) {
return new AbstractUiResultCallback<List<IBeanDto>>() {
@Override
protected void finishedUi(final List<IBeanDto> result) {
for (final IBeanProxy<SOURCE_BEAN_TYPE> bean : selection) {
bean.setExecutionTask(null);
}
if (linkedModel != null) {
if (Cardinality.LESS_OR_EQUAL_ONE.equals(linkedCardinality)) {
linkedModel.removeAllBeans();
}
for (final IBeanDto resultBean : result) {
linkedModel.addBeanDto(resultBean);
}
}
executionObservable.fireAfterExecutionSuccess(executionContext, result);
}
@Override
protected void exceptionUi(final Throwable exception) {
int beanIndex = 0;
for (final IBeanProxy<SOURCE_BEAN_TYPE> bean : selection) {
bean.setExecutionTask(null);
if (!(exception instanceof ServiceCanceledException)) {
bean.addMessage(exceptionConverter.convert(getShortErrorMessage(), selection, beanIndex++, bean, exception));
}
}
executionObservable.fireAfterExecutionError(executionContext, exception);
}
private String getShortErrorMessage() {
final String actionText = executionContext.getAction().getText().replaceAll("\\.", "").trim();
return MessageReplacer.replace(SHORT_ERROR.get(), actionText);
}
};
}
use of org.jowidgets.cap.ui.tools.execution.AbstractUiResultCallback in project jo-client-platform by jo-source.
the class PasteLinkCommand method createResultCallback.
private IResultCallback<List<IBeanDto>> createResultCallback(final List<IBeanProxy<SOURCE_BEAN_TYPE>> selection, final IExecutionContext executionContext) {
return new AbstractUiResultCallback<List<IBeanDto>>() {
@Override
protected void finishedUi(final List<IBeanDto> result) {
for (final IBeanProxy<SOURCE_BEAN_TYPE> bean : selection) {
bean.setExecutionTask(null);
}
if (linkedModel != null) {
if (Cardinality.LESS_OR_EQUAL_ONE.equals(linkedCardinality)) {
linkedModel.removeAllBeans();
}
for (final IBeanDto resultBean : result) {
linkedModel.addBeanDto(resultBean);
}
}
executionObservable.fireAfterExecutionSuccess(executionContext, result);
}
@Override
protected void exceptionUi(final Throwable exception) {
int beanIndex = 0;
for (final IBeanProxy<SOURCE_BEAN_TYPE> bean : selection) {
bean.setExecutionTask(null);
if (!(exception instanceof ServiceCanceledException)) {
bean.addMessage(exceptionConverter.convert(getShortErrorMessage(), selection, beanIndex++, bean, exception));
}
}
executionObservable.fireAfterExecutionError(executionContext, exception);
}
private String getShortErrorMessage() {
final String actionText = executionContext.getAction().getText().replaceAll("\\.", "").trim();
return MessageReplacer.replace(SHORT_ERROR.get(), actionText);
}
};
}
Aggregations