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