Search in sources :

Example 11 with IExecutionTask

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);
                }
            }
        }
    }
}
Also used : IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) IExecutionTask(org.jowidgets.cap.ui.api.execution.IExecutionTask) List(java.util.List) IBeanProxy(org.jowidgets.cap.ui.api.bean.IBeanProxy) IBeanKeyFactory(org.jowidgets.cap.ui.api.bean.IBeanKeyFactory)

Example 12 with IExecutionTask

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();
    }
}
Also used : IExecutionTask(org.jowidgets.cap.ui.api.execution.IExecutionTask) LinkedList(java.util.LinkedList) IBeanProxy(org.jowidgets.cap.ui.api.bean.IBeanProxy) IBeanData(org.jowidgets.cap.common.api.bean.IBeanData) LinkedList(java.util.LinkedList) List(java.util.List)

Example 13 with IExecutionTask

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);
}
Also used : AbstractUiResultCallback(org.jowidgets.cap.ui.tools.execution.AbstractUiResultCallback) IResultCallback(org.jowidgets.cap.common.api.execution.IResultCallback) IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) IExecutionTaskDialog(org.jowidgets.cap.ui.api.widgets.IExecutionTaskDialog) IExecutionTask(org.jowidgets.cap.ui.api.execution.IExecutionTask)

Example 14 with IExecutionTask

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);
}
Also used : IExecutionCallbackListener(org.jowidgets.cap.common.api.execution.IExecutionCallbackListener) IExecutionTask(org.jowidgets.cap.ui.api.execution.IExecutionTask) IUiThreadAccess(org.jowidgets.api.threads.IUiThreadAccess) ILinkCreation(org.jowidgets.cap.common.api.link.ILinkCreation)

Example 15 with IExecutionTask

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("");
        }
    }
}
Also used : IExecutionTask(org.jowidgets.cap.ui.api.execution.IExecutionTask)

Aggregations

IExecutionTask (org.jowidgets.cap.ui.api.execution.IExecutionTask)16 LinkedList (java.util.LinkedList)5 IBeanProxy (org.jowidgets.cap.ui.api.bean.IBeanProxy)5 List (java.util.List)4 IUiThreadAccess (org.jowidgets.api.threads.IUiThreadAccess)4 IExecutionCallbackListener (org.jowidgets.cap.common.api.execution.IExecutionCallbackListener)4 AbstractUiResultCallback (org.jowidgets.cap.ui.tools.execution.AbstractUiResultCallback)3 IBeanData (org.jowidgets.cap.common.api.bean.IBeanData)2 IBeanKey (org.jowidgets.cap.common.api.bean.IBeanKey)2 ILinkCreation (org.jowidgets.cap.common.api.link.ILinkCreation)2 IBeanKeyFactory (org.jowidgets.cap.ui.api.bean.IBeanKeyFactory)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 IWindow (org.jowidgets.api.widgets.IWindow)1 IBeanDto (org.jowidgets.cap.common.api.bean.IBeanDto)1 IBeanModification (org.jowidgets.cap.common.api.bean.IBeanModification)1 ServiceCanceledException (org.jowidgets.cap.common.api.exception.ServiceCanceledException)1 IResultCallback (org.jowidgets.cap.common.api.execution.IResultCallback)1 ILinkCreationBuilder (org.jowidgets.cap.common.api.link.ILinkCreationBuilder)1 IExecutionTaskDialog (org.jowidgets.cap.ui.api.widgets.IExecutionTaskDialog)1