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