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);
}
});
}
Aggregations