Search in sources :

Example 1 with IBeanSelectionListener

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

the class BeanLinkPanelImpl method createTable.

private void createTable(final IContainer container, final IBeanTableBluePrint<LINKABLE_BEAN_TYPE> linkableTableBp) {
    final IBeanTableBluePrint<LINKABLE_BEAN_TYPE> beanTableBpCopy = CapUiToolkit.bluePrintFactory().beanTable();
    beanTableBpCopy.setSetup(linkableTableBp);
    beanTableBpCopy.setSearchFilterToolbarVisible(true);
    container.setLayout(MigLayoutFactory.growingInnerCellLayout());
    this.linkableTable = container.add(beanTableBpCopy, MigLayoutFactory.GROWING_CELL_CONSTRAINTS);
    final IBeanSelectionListener<LINKABLE_BEAN_TYPE> selectionListener = new IBeanSelectionListener<LINKABLE_BEAN_TYPE>() {

        @Override
        public void selectionChanged(final IBeanSelectionEvent<LINKABLE_BEAN_TYPE> selectionEvent) {
            final IBeanProxy<LINKABLE_BEAN_TYPE> firstSelected = selectionEvent.getFirstSelected();
            if (firstSelected != null) {
                if (linkableForm != null) {
                    if (createdLinkableBean != null && linkableTable != null) {
                        createdLinkableBean.removePropertyChangeListener(beanFilterListener);
                    }
                    linkableForm.setValue(firstSelected);
                    linkableForm.setEditable(false);
                }
            } else {
                if (linkableForm != null) {
                    linkableForm.setValue(createdLinkableBean);
                    if (createdLinkableBean != null && linkableTable != null) {
                        createdLinkableBean.addPropertyChangeListener(beanFilterListener);
                    }
                    linkableForm.setEditable(true);
                }
            }
            setValidationCacheDirty();
        }
    };
    linkableTable.getModel().addBeanSelectionListener(selectionListener);
    linkableTable.addDisposeListener(new IDisposeListener() {

        @Override
        public void onDispose() {
            linkableTable.getModel().removeBeanSelectionListener(selectionListener);
        }
    });
}
Also used : IDisposeListener(org.jowidgets.api.controller.IDisposeListener) IBeanSelectionEvent(org.jowidgets.cap.ui.api.bean.IBeanSelectionEvent) IBeanSelectionListener(org.jowidgets.cap.ui.api.bean.IBeanSelectionListener)

Aggregations

IDisposeListener (org.jowidgets.api.controller.IDisposeListener)1 IBeanSelectionEvent (org.jowidgets.cap.ui.api.bean.IBeanSelectionEvent)1 IBeanSelectionListener (org.jowidgets.cap.ui.api.bean.IBeanSelectionListener)1