ULC Subset Chooser


This extension provides a high-level component that holds two tables of entities and provides the functionality to move one or multiple entities from one table to the other, allowing to choose/define a subset of data. The subset chooser may either be horizontally and vertically oriented.


How to use

Create an instance of ULCSubsetChooser.

Doing this, you have to provide two ITableModel instances that represent the "all data" model and the "subset data" model.


PersonTableModel allDataTableModel = new PersonTableModel(...); PersonTableModel subsetDataTableModel = new PersonTableModel(...);

ULCSubsetChooser subsetChooser = new ULCSubsetChooser(allDataTableModel, subsetDataTableModel);


Register a SubsetChooserListener that implements the move operation

The SubsetChooserListener gets notified whenever one or multiple entites are moved from one table to the other.


subsetChooser.addSubsetChooserListener(new SubsetChooserListener() { public void entitiesMoved(ULCTable sourceTable, ULCTable targetTable, int[] selectedRows) { PersonTableModel sourceTableModel = (PersonTableModel)sourceTable.getModel(); PersonTableModel targetTableModel = (PersonTableModel)targetTable.getModel();

List personsToMove = new ArrayList(); for (int i = 0; i < selectedRows.length; i++) { personsToMove.add(sourceTableModel.getPerson(selectedRows[i])); }

sourceTableModel.removePersons(personsToMove); targetTableModel.addPersons(personsToMove); } });