JPanel panelBoards = new JPanel();
panelBoards.setBorder(new TitledBorder(null, "Boards",
TitledBorder.LEADING, TitledBorder.TOP, null, null));
panelBoards.setLayout(new BorderLayout(0, 0));
boardsTable = new AutoSelectTextTable(boardsTableModel);
boardsTable.setAutoCreateRowSorter(true);
boardsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
// TODO: Add a tooltip for the path, see
// http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#celltooltip
boardsTable.getSelectionModel().addListSelectionListener(
new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
Board board = getSelectedBoard();
boardSelectionActionGroup.setEnabled(board != null);
if (board == null) {
placementsTableModel.setBoard(null);
}
else {
placementsTableModel.setBoard(board);
}
}
});
JToolBar toolBarBoards = new JToolBar();
panelBoards.add(toolBarBoards, BorderLayout.NORTH);
toolBarBoards.setFloatable(false);
JButton btnNewBoard = new JButton(newBoardAction);
btnNewBoard.setHideActionText(true);
toolBarBoards.add(btnNewBoard);
JButton btnLoadBoard = new JButton(addBoardAction);
btnLoadBoard.setHideActionText(true);
toolBarBoards.add(btnLoadBoard);
JScrollPane scrollPaneBoards = new JScrollPane(boardsTable);
panelBoards.add(scrollPaneBoards, BorderLayout.CENTER);
JPanel panelPlacements = new JPanel();
panelPlacements.setBorder(new TitledBorder(null, "Placements",
TitledBorder.LEADING, TitledBorder.TOP, null, null));
panelPlacements.setLayout(new BorderLayout(0, 0));
JComboBox partsComboBox = new JComboBox(new PartsComboBoxModel());
partsComboBox.setRenderer(new IdentifiableListCellRenderer<Part>());
placementsTable = new AutoSelectTextTable(placementsTableModel);
placementsTable.setAutoCreateRowSorter(true);
placementsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
placementsTable.setDefaultEditor(Side.class, new DefaultCellEditor(
sidesComboBox));
placementsTable.setDefaultEditor(Part.class, new DefaultCellEditor(