Search in sources :

Example 6 with IBeanProxy

use of org.jowidgets.cap.ui.api.bean.IBeanProxy in project jo-client-platform by jo-source.

the class BeanTableModelImpl method addBeanDtos.

@Override
public List<IBeanProxy<BEAN_TYPE>> addBeanDtos(final Collection<? extends IBeanDto> beanDtos, final boolean sorted) {
    Assert.paramNotNull(beanDtos, "beanDtos");
    final List<IBeanProxy<BEAN_TYPE>> proxies = new ArrayList<IBeanProxy<BEAN_TYPE>>(beanDtos.size());
    for (final IBeanDto beanDto : beanDtos) {
        final IBeanProxy<BEAN_TYPE> beanProxy = createBeanProxy(beanDto);
        proxies.add(beanProxy);
    }
    addBeans(proxies, sorted);
    return proxies;
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) ArrayList(java.util.ArrayList) IBeanProxy(org.jowidgets.cap.ui.api.bean.IBeanProxy)

Example 7 with IBeanProxy

use of org.jowidgets.cap.ui.api.bean.IBeanProxy in project jo-client-platform by jo-source.

the class BeanTableModelImpl method addBeansSorted.

private void addBeansSorted(final Collection<IBeanProxy<BEAN_TYPE>> beansToAdd) {
    final List<IBeanProxy<BEAN_TYPE>> selectedBeans = getSelectedBeans();
    final Comparator<IBeanDto> comparator = BeanDtoComparator.create(sortModel.getSorting());
    final ListIterator<IBeanProxy<BEAN_TYPE>> addedDataIterator = addedData.listIterator();
    boolean beanListenerIndicesStale = false;
    for (final IBeanProxy<BEAN_TYPE> bean : beansToAdd) {
        while (addedDataIterator.hasNext()) {
            final IBeanProxy<BEAN_TYPE> nextBean = addedDataIterator.next();
            final int compare = comparator.compare(bean, nextBean);
            if (compare < 0) {
                addedDataIterator.previous();
                break;
            } else if (beanListenerIndicesStale) {
                updateRowIndexOfBean(bean, rowCountOfPages + addedDataIterator.previousIndex());
            }
        }
        addedDataIterator.add(bean);
        beanListenerIndicesStale = true;
        final int rowIndex = rowCountOfPages + addedDataIterator.previousIndex();
        bean.addPropertyChangeListener(new BeanPropertyChangeListener(rowIndex));
    }
    beansStateTracker.register(beansToAdd);
    cachedReaderService.addBeans(getParentBeanKeys(), new HashSet<IBeanProxy<BEAN_TYPE>>(beansToAdd));
    setSelectedBeans(selectedBeans);
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) TableCellBluePrint(org.jowidgets.tools.model.table.TableCellBluePrint) IBeanProxy(org.jowidgets.cap.ui.api.bean.IBeanProxy)

Example 8 with IBeanProxy

use of org.jowidgets.cap.ui.api.bean.IBeanProxy in project jo-client-platform by jo-source.

the class BeanLinkCreatorCommand method getBeanLink.

private IBeanLink<LINK_BEAN_TYPE, LINKABLE_BEAN_TYPE> getBeanLink(final IExecutionContext executionContext) {
    final ICapApiBluePrintFactory cbpf = CapUiToolkit.bluePrintFactory();
    final IBeanLinkPanelBluePrint<LINK_BEAN_TYPE, LINKABLE_BEAN_TYPE> linkPanelBp = cbpf.beanLinkPanel();
    linkPanelBp.setLinkBeanForm(linkBeanForm);
    linkPanelBp.setLinkableBeanForm(linkableBeanForm);
    linkPanelBp.setLinkableTable(linkableTable);
    final IBeanLinkDialogBluePrint<LINK_BEAN_TYPE, LINKABLE_BEAN_TYPE> dialogBp = cbpf.beanLinkDialog(linkPanelBp);
    dialogBp.setMinPackSize(new Dimension(800, 600));
    dialogBp.setMaxPackSize(new Dimension(1600, 1000));
    dialogBp.setExecutionContext(executionContext);
    dialogBp.setMissingInputHint(null);
    dialogBp.setContentScrolled(false);
    if (dialogBounds != null) {
        dialogBp.setPosition(dialogBounds.getPosition()).setSize(dialogBounds.getSize());
        dialogBp.autoPackOff().autoCenterOff();
    }
    final IBeanLinkDialog<LINK_BEAN_TYPE, LINKABLE_BEAN_TYPE> linkDialog;
    linkDialog = Toolkit.getActiveWindow().createChildWindow(dialogBp);
    final IBeanProxy<LINK_BEAN_TYPE> defaultLinkBean;
    if (linkDefaultFactory != null) {
        defaultLinkBean = linkDefaultFactory.create();
    } else {
        defaultLinkBean = createDefaultBean(linkBeanForm, linkBeanTypeId, linkBeanType, linkBeanPropertyValidators);
    }
    final List<IBeanProxy<LINKABLE_BEAN_TYPE>> defaultLinkedBeans;
    if (linkableBeanForm != null) {
        defaultLinkedBeans = Collections.singletonList(createDefaultBean(linkableBeanForm, linkableBeanTypeId, linkableBeanType, linkableBeanPropertyValidators));
    } else {
        defaultLinkedBeans = Collections.emptyList();
    }
    linkDialog.setValue(new IBeanLink<LINK_BEAN_TYPE, LINKABLE_BEAN_TYPE>() {

        @Override
        public IBeanProxy<LINK_BEAN_TYPE> getLinkBean() {
            return defaultLinkBean;
        }

        @Override
        public List<IBeanProxy<LINKABLE_BEAN_TYPE>> getLinkableBeans() {
            return defaultLinkedBeans;
        }
    });
    linkDialog.setVisible(true);
    final IBeanLink<LINK_BEAN_TYPE, LINKABLE_BEAN_TYPE> result;
    if (linkDialog.isOkPressed()) {
        final IBeanLink<LINK_BEAN_TYPE, LINKABLE_BEAN_TYPE> dialogValue = linkDialog.getValue();
        result = new IBeanLink<LINK_BEAN_TYPE, LINKABLE_BEAN_TYPE>() {

            @Override
            public IBeanProxy<LINK_BEAN_TYPE> getLinkBean() {
                final IBeanProxy<LINK_BEAN_TYPE> original = dialogValue.getLinkBean();
                return original != null ? original : defaultLinkBean;
            }

            @Override
            public List<IBeanProxy<LINKABLE_BEAN_TYPE>> getLinkableBeans() {
                return dialogValue.getLinkableBeans();
            }
        };
    } else {
        result = null;
    }
    dialogBounds = linkDialog.getBounds();
    linkDialog.dispose();
    return result;
}
Also used : Dimension(org.jowidgets.common.types.Dimension) IBeanProxy(org.jowidgets.cap.ui.api.bean.IBeanProxy) ICapApiBluePrintFactory(org.jowidgets.cap.ui.api.widgets.ICapApiBluePrintFactory) List(java.util.List) LinkedList(java.util.LinkedList)

Example 9 with IBeanProxy

use of org.jowidgets.cap.ui.api.bean.IBeanProxy in project jo-client-platform by jo-source.

the class BeanListExecutionHelper method prepareExecutions.

List<List<IBeanProxy<BEAN_TYPE>>> prepareExecutions(final boolean allowTransient, final IExecutionContext executionContext) {
    final List<List<IBeanProxy<BEAN_TYPE>>> result = new LinkedList<List<IBeanProxy<BEAN_TYPE>>>();
    if (BeanExecutionPolicy.BATCH == beanExecutionPolicy) {
        final IExecutionTask executionTask = createExecutionTask(executionContext);
        final List<IBeanProxy<BEAN_TYPE>> subList = new LinkedList<IBeanProxy<BEAN_TYPE>>();
        result.add(subList);
        for (final IBeanProxy<BEAN_TYPE> bean : beans) {
            if (bean.getExecutionTask() == null && !bean.isDummy() && !bean.isLastRowDummy() && (allowTransient || !bean.isTransient())) {
                bean.setExecutionTask(executionTask);
                subList.add(bean);
            }
        }
    } else {
        for (final IBeanProxy<BEAN_TYPE> bean : beans) {
            final List<IBeanProxy<BEAN_TYPE>> subList = new LinkedList<IBeanProxy<BEAN_TYPE>>();
            result.add(subList);
            if (bean.getExecutionTask() == null && !bean.isDummy() && (allowTransient || !bean.isTransient())) {
                final IExecutionTask executionTask = createExecutionTask(executionContext);
                bean.setExecutionTask(executionTask);
                subList.add(bean);
            }
        }
    }
    if (fireBeansChanged) {
        listModel.fireBeansChanged();
    }
    return result;
}
Also used : IExecutionTask(org.jowidgets.cap.ui.api.execution.IExecutionTask) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList) IBeanProxy(org.jowidgets.cap.ui.api.bean.IBeanProxy)

Example 10 with IBeanProxy

use of org.jowidgets.cap.ui.api.bean.IBeanProxy in project jo-client-platform by jo-source.

the class BeanListExecutionHelper method updateTransientBeans.

private void updateTransientBeans(final List<IBeanProxy<BEAN_TYPE>> executedBeans, final List<IBeanDto> result) {
    if (executedBeans.size() != result.size()) {
        listModel.removeBeans(executedBeans);
        for (final IBeanDto beanDto : result) {
            listModel.addBeanDto(beanDto);
        }
    } else {
        final Iterator<IBeanProxy<BEAN_TYPE>> sourceIterator = executedBeans.iterator();
        final Iterator<IBeanDto> resultIterator = result.iterator();
        while (sourceIterator.hasNext()) {
            sourceIterator.next().update(resultIterator.next());
        }
    }
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) IBeanProxy(org.jowidgets.cap.ui.api.bean.IBeanProxy)

Aggregations

IBeanProxy (org.jowidgets.cap.ui.api.bean.IBeanProxy)25 LinkedList (java.util.LinkedList)13 IBeanDto (org.jowidgets.cap.common.api.bean.IBeanDto)7 TableCellBluePrint (org.jowidgets.tools.model.table.TableCellBluePrint)6 List (java.util.List)5 IBeanKey (org.jowidgets.cap.common.api.bean.IBeanKey)5 IExecutionTask (org.jowidgets.cap.ui.api.execution.IExecutionTask)5 ArrayList (java.util.ArrayList)3 BeanKey (org.jowidgets.cap.common.tools.bean.BeanKey)3 IBeanRelationNodeModel (org.jowidgets.cap.ui.api.tree.IBeanRelationNodeModel)3 ITreeNode (org.jowidgets.api.widgets.ITreeNode)2 IBeanKeyFactory (org.jowidgets.cap.ui.api.bean.IBeanKeyFactory)2 ITableCellPopupEvent (org.jowidgets.common.widgets.controller.ITableCellPopupEvent)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 IEnabledChecker (org.jowidgets.api.command.IEnabledChecker)1 IEnabledState (org.jowidgets.api.command.IEnabledState)1 IDisposeListener (org.jowidgets.api.controller.IDisposeListener)1