private Component buildMainButtonBar() {
return ButtonBarFactory.buildRightAlignedBar(okButton);
}
private void initComponents() {
LocomotivePersistenceIface locomotivePersistence = AdHocRailway
.getInstance().getLocomotivePersistence();
ArrayListModel<LocomotiveGroup> locomotiveGroups = locomotivePersistence
.getAllLocomotiveGroups();
locomotiveGroupModel = new SelectionInList<LocomotiveGroup>(
(ListModel) locomotiveGroups);
locomotiveGroupList = BasicComponentFactory
.createList(locomotiveGroupModel);
locomotiveGroupList
.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
locomotiveGroupList
.setCellRenderer(new LocomotiveGroupListCellRenderer());
addGroupButton = new JButton(new AddLocomotiveGroupAction());
removeGroupButton = new JButton(new RemoveLocomotiveGroupAction());
locomotiveModel = new SelectionInList<Locomotive>();
locomotivesTable = new JTable();
locomotivesTable.setModel(new LocomotiveTableModel(locomotiveModel));
locomotivesTable.setSelectionModel(new SingleListSelectionAdapter(
locomotiveModel.getSelectionIndexHolder()));
addLocomotiveButton = new JButton(new AddLocomotiveAction());
removeLocomotiveButton = new JButton(new RemoveLocomotiveAction());
okButton = new JButton("OK");
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
LocomotivePersistenceIface locomotivePersistence = AdHocRailway
.getInstance().getLocomotivePersistence();
locomotivePersistence.flush();
} catch (LocomotivePersistenceException e1) {
ExceptionProcessor.getInstance().processException(e1);
} finally {
okPressed = true;
setVisible(false);