private Component buildMainButtonBar() {
return ButtonBarFactory.buildRightAlignedBar(okButton);
}
private void initComponents() {
TurnoutPersistenceIface turnoutPersistence = AdHocRailway.getInstance()
.getTurnoutPersistence();
ArrayListModel<TurnoutGroup> turnoutGroups = turnoutPersistence
.getAllTurnoutGroups();
turnoutGroupModel = new SelectionInList<TurnoutGroup>(
(ListModel) turnoutGroups);
turnoutGroupList = BasicComponentFactory.createList(turnoutGroupModel);
turnoutGroupList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
turnoutGroupList.setCellRenderer(new TurnoutGroupListCellRenderer());
turnoutGroupList.getInputMap().put(
KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
"deleteTurnoutGroup");
turnoutGroupList.getInputMap().put(
KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0),
"deleteTurnoutGroup");
turnoutGroupList.getActionMap().put("deleteTurnoutGroup",
new RemoveTurnoutGroupAction());
turnoutGroupConfig = new TurnoutGroupConfigPanel();
addGroupButton = new JButton(new AddTurnoutGroupAction());
removeGroupButton = new JButton(new RemoveTurnoutGroupAction());
turnoutModel = new SelectionInList<Turnout>();
turnoutsTable = new JTable();
turnoutsTable.setModel(new TurnoutTableModel(turnoutModel));
// turnoutsTable.setSelectionModel(new SingleListSelectionAdapter(
// turnoutModel.getSelectionIndexHolder()));
turnoutsTable
.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
turnoutsTable.getInputMap().put(
KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "deleteTurnout");
turnoutsTable.getInputMap().put(
KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0),
"deleteTurnout");
turnoutsTable.getActionMap().put("deleteTurnout",
new RemoveTurnoutAction());
TableColumn typeColumn = turnoutsTable.getColumnModel().getColumn(1);
typeColumn.setCellRenderer(new TurnoutTypeCellRenderer());
TableColumn defaultStateColumn = turnoutsTable.getColumnModel()
.getColumn(8);
defaultStateColumn
.setCellRenderer(new TurnoutDefaultStateCellRenderer());
turnoutsTable.setRowHeight(30);
addTurnoutButton = new JButton(new AddTurnoutAction());
removeTurnoutButton = new JButton(new RemoveTurnoutAction());
okButton = new JButton("OK");
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
TurnoutPersistenceIface turnoutPersistence = AdHocRailway
.getInstance().getTurnoutPersistence();
turnoutPersistence.flush();
} catch (TurnoutPersistenceException e1) {
ExceptionProcessor.getInstance().processException(e1);
} finally {
okPressed = true;
setVisible(false);