use of org.jowidgets.cap.ui.api.execution.IExecutionTask in project jo-client-platform by jo-source.
the class BeanListRefreshDelegate method refresh.
void refresh(final Collection<IBeanProxy<BEAN_TYPE>> beans) {
if (refreshService != null) {
final BeanListExecutionHelper<BEAN_TYPE> executionHelper = new BeanListExecutionHelper<BEAN_TYPE>(REFRESH_FAILED.get(), listModel, beans, beanExecutionPolicy, exceptionConverter, false, true);
for (final List<IBeanProxy<BEAN_TYPE>> preparedBeans : executionHelper.prepareExecutions(false)) {
if (preparedBeans.size() > 0) {
final IExecutionTask executionTask = preparedBeans.get(0).getExecutionTask();
if (executionTask != null) {
executionTask.setDescription(REFRESH.get());
final IBeanKeyFactory beanKeyFactory = CapUiToolkit.beanKeyFactory();
final List<IBeanKey> beanKeys = beanKeyFactory.createKeys(preparedBeans);
final IResultCallback<List<IBeanDto>> helperCallback = executionHelper.createResultCallback(preparedBeans);
refreshService.refresh(helperCallback, beanKeys, executionTask);
}
}
}
}
}
use of org.jowidgets.cap.ui.api.execution.IExecutionTask in project jo-client-platform by jo-source.
the class BeanListSaveDelegate method create.
private void create(final Runnable finishedCallback) {
final Set<IBeanProxy<BEAN_TYPE>> beansToCreate = beansStateTracker.getBeansToCreate();
if (!EmptyCheck.isEmpty(beansToCreate)) {
if (creatorService == null) {
throw new IllegalStateException("No creator service set. Could not create transient beans");
}
final BeanListExecutionHelper<BEAN_TYPE> executionHelper = new BeanListExecutionHelper<BEAN_TYPE>(CREATION_FAILED.get(), listModel, beansToCreate, beanExecutionPolicy, exceptionConverter, true, fireBeansChanged);
final List<List<IBeanProxy<BEAN_TYPE>>> preparedExecutions = executionHelper.prepareExecutions(true, executionContext);
final CountDownRunnable countDownRunnable = new CountDownRunnable(finishedCallback, preparedExecutions.size());
for (final List<IBeanProxy<BEAN_TYPE>> preparedBeans : preparedExecutions) {
if (preparedBeans.size() > 0) {
final IExecutionTask executionTask = preparedBeans.get(0).getExecutionTask();
if (executionTask != null) {
executionTask.setDescription(CREATE.get());
final List<IBeanData> beansData = new LinkedList<IBeanData>();
for (final IBeanProxy<BEAN_TYPE> bean : preparedBeans) {
beansData.add(createBeanData(bean));
}
final IResultCallback<List<IBeanDto>> helperCallback = executionHelper.createResultCallback(preparedBeans, countDownRunnable);
creatorService.create(helperCallback, parentBeansProvider.get(), beansData, executionTask);
}
}
}
} else {
finishedCallback.run();
}
}
use of org.jowidgets.cap.ui.api.execution.IExecutionTask in project jo-client-platform by jo-source.
the class CsvExportExecutor method execute.
@Override
public void execute(final IExecutionContext executionContext, final List<IBeanProxy<BEAN_TYPE>> beans, final ICsvExportParameter parameter) throws Exception {
final IExecutionTask executionTask = CapUiToolkit.executionTaskFactory().create(executionContext);
final IExecutionTaskDialog executionTaskDialog = createExecutionTaskDialog(executionContext, executionTask);
final IResultCallback<String> resultCallback = new ResultCallback(executionTaskDialog);
final Runnable exportRunnable;
if (parameter.getExportType() == ExportType.SELECTION) {
final List<IBeanDto> beanDtos = createBeanDtos(beans, model.getPropertyNames());
exportRunnable = new CsvExportSelectedRunnable(model, resultCallback, parameter, beanDtos, executionTask);
} else {
final List<IBeanDto> addedData = createBeanDtos(model.getAddedData(), model.getPropertyNames());
exportRunnable = new CsvExportTableRunnable(model, addedData, resultCallback, parameter, executionTask);
}
executionTaskDialog.setVisible(true);
executor.execute(exportRunnable);
}
use of org.jowidgets.cap.ui.api.execution.IExecutionTask in project jo-client-platform by jo-source.
the class PasteLinkCommand method linkBeans.
private void linkBeans(final IExecutionContext executionContext, final List<IBeanProxy<SOURCE_BEAN_TYPE>> selection) {
final IExecutionTask executionTask = CapUiToolkit.executionTaskFactory().create(executionContext);
final IUiThreadAccess uiThreadAccess = Toolkit.getUiThreadAccess();
executionTask.addExecutionCallbackListener(new IExecutionCallbackListener() {
@Override
public void canceled() {
uiThreadAccess.invokeLater(new Runnable() {
@Override
public void run() {
for (final IBeanProxy<SOURCE_BEAN_TYPE> bean : selection) {
bean.setExecutionTask(null);
}
executionObservable.fireAfterExecutionCanceled(executionContext);
}
});
}
});
final Collection<ILinkCreation> linkCreations = linkProvider.get();
executionObservable.fireAfterExecutionPrepared(executionContext);
linkCreatorService.create(createResultCallback(selection, executionContext), linkCreations, executionTask);
}
use of org.jowidgets.cap.ui.api.execution.IExecutionTask in project jo-client-platform by jo-source.
the class BeanFormControl method updateExecutionTaskText.
private void updateExecutionTaskText(final IBeanProxy<BEAN_TYPE> bean) {
if (processStateLabel != null) {
if (bean != null) {
final IExecutionTask executionTask = bean.getExecutionTask();
if (executionTask != null) {
processStateLabel.setText(computeLabelText(executionTask));
ensureProcessStateLabelLayoutet();
} else {
processStateLabel.setText("");
}
} else {
processStateLabel.setText("");
}
}
}
Aggregations