Search in sources :

Example 1 with ILinkCreation

use of org.jowidgets.cap.common.api.link.ILinkCreation in project jo-client-platform by jo-source.

the class BeanLinkCreatorCommand method linkBeans.

private void linkBeans(final IExecutionContext executionContext, final List<IBeanProxy<SOURCE_BEAN_TYPE>> selection, final IBeanLink<LINK_BEAN_TYPE, LINKABLE_BEAN_TYPE> beanLink) {
    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 ILinkCreationBuilder linkCreationBuilder = LinkCreation.builder();
    // add the source beans
    for (final IBeanProxy<SOURCE_BEAN_TYPE> sourceBean : selection) {
        if (sourceBean.isTransient()) {
            linkCreationBuilder.addTransientSourceBean(sourceBean.getBeanData());
        } else {
            linkCreationBuilder.addSourceBean(sourceBean.getBeanKey());
        }
    }
    // add the linkable beans
    for (final IBeanProxy<LINKABLE_BEAN_TYPE> linkableBean : beanLink.getLinkableBeans()) {
        if (linkableBean.isTransient()) {
            linkCreationBuilder.addTransientLinkableBean(linkableBean.getBeanData());
        } else {
            linkCreationBuilder.addLinkableBean(linkableBean.getBeanKey());
        }
    }
    // set the additional properties
    final IBeanProxy<LINK_BEAN_TYPE> linkBean = beanLink.getLinkBean();
    if (linkBean != null) {
        linkCreationBuilder.setAdditionalLinkProperties(linkBean.getBeanData());
    }
    final Set<ILinkCreation> linkCreations = Collections.singleton(linkCreationBuilder.build());
    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) ILinkCreationBuilder(org.jowidgets.cap.common.api.link.ILinkCreationBuilder)

Example 2 with ILinkCreation

use of org.jowidgets.cap.common.api.link.ILinkCreation in project jo-client-platform by jo-source.

the class LinkCreatorServiceImpl method createSyncImpl.

private List<IBeanDto> createSyncImpl(final Collection<? extends ILinkCreation> links, final IExecutionCallback executionCallback) {
    final Set<IBeanDto> result = new LinkedHashSet<IBeanDto>();
    for (final ILinkCreation link : links) {
        CapServiceToolkit.checkCanceled(executionCallback);
        result.addAll(createLinks(link, executionCallback));
    }
    return new LinkedList<IBeanDto>(result);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) ILinkCreation(org.jowidgets.cap.common.api.link.ILinkCreation) LinkedList(java.util.LinkedList)

Example 3 with ILinkCreation

use of org.jowidgets.cap.common.api.link.ILinkCreation in project jo-client-platform by jo-source.

the class LinkCreatorServiceImpl method checkExecutableStateSync.

private void checkExecutableStateSync(final Collection<? extends ILinkCreation> links, final IExecutionCallback executionCallback) {
    if ((sourceProperties != null || destinationProperties != null) && linkableReaderService != null) {
        for (final ILinkCreation link : links) {
            CapServiceToolkit.checkCanceled(executionCallback);
            checkExecutableState(link, executionCallback);
        }
    }
}
Also used : ILinkCreation(org.jowidgets.cap.common.api.link.ILinkCreation)

Example 4 with ILinkCreation

use of org.jowidgets.cap.common.api.link.ILinkCreation 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)

Aggregations

ILinkCreation (org.jowidgets.cap.common.api.link.ILinkCreation)4 IUiThreadAccess (org.jowidgets.api.threads.IUiThreadAccess)2 IExecutionCallbackListener (org.jowidgets.cap.common.api.execution.IExecutionCallbackListener)2 IExecutionTask (org.jowidgets.cap.ui.api.execution.IExecutionTask)2 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 IBeanDto (org.jowidgets.cap.common.api.bean.IBeanDto)1 ILinkCreationBuilder (org.jowidgets.cap.common.api.link.ILinkCreationBuilder)1