Search in sources :

Example 1 with IBeanSelectionClipboard

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

Example 2 with IBeanSelectionClipboard

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);
        }
    }
}
Also used : IBeanSelectionClipboard(org.jowidgets.cap.ui.api.clipboard.IBeanSelectionClipboard) IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto)

Example 3 with IBeanSelectionClipboard

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());
}
Also used : IBeanSelectionClipboard(org.jowidgets.cap.ui.api.clipboard.IBeanSelectionClipboard) IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto)

Aggregations

IBeanSelectionClipboard (org.jowidgets.cap.ui.api.clipboard.IBeanSelectionClipboard)3 IBeanDto (org.jowidgets.cap.common.api.bean.IBeanDto)2