package net.sourceforge.fenixedu.dataTransferObject; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import net.sourceforge.fenixedu.domain.DomainObject; import net.sourceforge.fenixedu.domain.DomainReference; public abstract class MergeResearchActivityPageContainerBean extends PageContainerBean implements Serializable { private List> selectedObjects = new ArrayList>(); private PageContainerBean pageContainerBean; public MergeResearchActivityPageContainerBean() { pageContainerBean = new PageContainerBean(); } public List getSelectedObjects() { List result = new ArrayList(); for (DomainReference domainReference : this.selectedObjects) { result.add(domainReference.getObject()); } return result; } public void setPageObjects(List pageObjects) { this.selectedObjects = new ArrayList>(); for (DomainObject object : pageObjects) { this.selectedObjects.add(new DomainReference(object)); } } public PageContainerBean getPageContainerBean() { return pageContainerBean; } public void setPageContainerBean(PageContainerBean pageContainerBean) { this.pageContainerBean = pageContainerBean; } @Override public List getObjects() { return getSelectedObjects(); } @Override public void setObjects(List objects) { List result = new ArrayList(objects); result.removeAll(getSelectedObjects()); getPageContainerBean().setObjects(result); } public void addSelected() { if (getPageContainerBean().getSelected() != null) { this.selectedObjects.add(new DomainReference(getPageContainerBean().getSelected())); getPageContainerBean().setSelected(null); } } public void removeSelected() { if (getSelected() != null) { this.selectedObjects.remove(new DomainReference(getSelected())); setSelected(null); } } public void reset() { setSelected(null); selectedObjects = new ArrayList>(); } }