use of org.jowidgets.cap.ui.api.clipboard.IBeanSelectionClipboard in project jo-client-platform by jo-source.
the class BeanSelectionTransferableFactoryImpl method create.
@Override
public ITransferable create(final IBeanListModel<BEAN_TYPE> model) {
Assert.paramNotNull(model, "model");
final String stringRepresentation = renderer.render(model.getBeanSelection());
final IBeanSelectionClipboard beanSelectionClipboard = BeanSelectionClipboard.create(model.getBeanSelection());
return new BeanSelectionTransferableImpl(beanSelectionClipboard, stringRepresentation);
}
use of org.jowidgets.cap.ui.api.clipboard.IBeanSelectionClipboard 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.ui.api.clipboard.IBeanSelectionClipboard 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());
}
Aggregations