use of org.jowidgets.cap.common.api.bean.IBeanDto in project jo-client-platform by jo-source.
the class BeanPasteCommand method doExecution.
private void doExecution() {
final IBeanSelectionClipboard selectionClipboard = Clipboard.getData(IBeanSelectionClipboard.TRANSFER_TYPE);
if (selectionClipboard != null) {
for (final IBeanDto beanDto : selectionClipboard.getBeans()) {
final IBeanProxy<BEAN_TYPE> transientBean = model.addTransientBean();
for (final IAttribute<?> attribute : attributes) {
final String propertyName = attribute.getPropertyName();
if (!propertyName.equals(IBean.ID_PROPERTY) && !propertyName.equals(IBean.VERSION_PROPERTY) && !IBeanProxy.ALL_META_ATTRIBUTES.contains(propertyName)) {
transientBean.setValue(propertyName, beanDto.getValue(propertyName));
}
}
final IBeanProxy<BEAN_TYPE> unmodifiedCopy = transientBean.createUnmodifiedCopy();
model.removeBeans(Collections.singleton(transientBean));
model.addBean(unmodifiedCopy);
}
}
}
use of org.jowidgets.cap.common.api.bean.IBeanDto in project jo-client-platform by jo-source.
the class BeanDtoComparatorTest method testSortConverter.
@Test
public void testSortConverter() {
final IBeanDto bean1 = createBeanDto(new Long(1), "2");
final IBeanDto bean2 = createBeanDto(new Long(2), "12");
final List<IBeanDto> beans = new ArrayList<IBeanDto>(2);
beans.add(bean2);
beans.add(bean1);
Assert.assertSame(bean2, beans.get(0));
Assert.assertSame(bean1, beans.get(1));
Collections.sort(beans, createSortComparator(SORT_STRING_PROPERTY_ASC, STRING_PROPRTY_NAME, STRING_SORT_CONVERTER));
Assert.assertSame(bean1, beans.get(0));
Assert.assertSame(bean2, beans.get(1));
Collections.sort(beans, createSortComparator(SORT_STRING_PROPERTY_DESC, STRING_PROPRTY_NAME, STRING_SORT_CONVERTER));
Assert.assertSame(bean2, beans.get(0));
Assert.assertSame(bean1, beans.get(1));
}
use of org.jowidgets.cap.common.api.bean.IBeanDto in project jo-client-platform by jo-source.
the class ClipboardSelectionEnabledChecker method getEnabledState.
@Override
public IEnabledState getEnabledState() {
final IBeanSelectionClipboard selection = Clipboard.getData(IBeanSelectionClipboard.TRANSFER_TYPE);
if (selection != null) {
final Collection<IBeanDto> beans = selection.getBeans();
final Object selectedBeanTypeId = selection.getBeanTypeId();
final Class<?> selectedBeanType = selection.getBeanType();
if (beans != null && !beans.isEmpty() && NullCompatibleEquivalence.equals(expectedBeanTypeId, selectedBeanTypeId) && NullCompatibleEquivalence.equals(expectedBeanType, selectedBeanType)) {
return EnabledState.ENABLED;
}
}
return EnabledState.disabled(EMPTY_CLIPBOARD.get());
}
use of org.jowidgets.cap.common.api.bean.IBeanDto 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.common.api.bean.IBeanDto 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