use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class SlotMonDataModel method setColumnToHoldEStopButton.
void setColumnToHoldEStopButton(JTable slotTable, int column) {
TableColumnModel tcm = slotTable.getColumnModel();
// install the button renderers & editors in this column
ButtonRenderer buttonRenderer = new ButtonRenderer();
tcm.getColumn(column).setCellRenderer(buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton()) {
@Override
public void mousePressed(MouseEvent e) {
stopCellEditing();
}
};
tcm.getColumn(column).setCellEditor(buttonEditor);
// ensure the table rows, columns have enough room for buttons
slotTable.setRowHeight(new JButton(" " + getValueAt(1, column)).getPreferredSize().height);
slotTable.getColumnModel().getColumn(column).setPreferredWidth(new JButton(" " + getValueAt(1, column)).getPreferredSize().width);
}
use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class PacketDataModel method setColumnToHoldButton.
void setColumnToHoldButton(JTable slotTable, int column) {
TableColumnModel tcm = slotTable.getColumnModel();
// install the button renderers & editors in this column
ButtonRenderer buttonRenderer = new ButtonRenderer();
tcm.getColumn(column).setCellRenderer(buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
tcm.getColumn(column).setCellEditor(buttonEditor);
// ensure the table rows, columns have enough room for buttons
slotTable.setRowHeight(new JButton(" " + getValueAt(1, column)).getPreferredSize().height);
slotTable.getColumnModel().getColumn(column).setPreferredWidth(new JButton(" " + getValueAt(1, column)).getPreferredSize().width);
}
use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class SignalGroupSubTableAction method setColumnToHoldButton.
/**
* Configure colum widths for the Turnout and Sensor Conditional tables.
*
* @param table JTable to put button in
* @param column index of column in table
* @param sample sample button to use as spacer
*/
void setColumnToHoldButton(JTable table, int column, JButton sample) {
// install a button renderer & editor
ButtonRenderer buttonRenderer = new ButtonRenderer();
table.setDefaultRenderer(JButton.class, buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
table.setDefaultEditor(JButton.class, buttonEditor);
// ensure the table rows, columns have enough room for buttons
table.setRowHeight(sample.getPreferredSize().height);
table.getColumnModel().getColumn(column).setPreferredWidth((sample.getPreferredSize().width) + 4);
}
use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class TableFrames method makeBlockPathFrame.
/*
* ********************* BlockPathFrame *****************************
*/
protected BlockPathFrame makeBlockPathFrame(OBlock block) {
String title = Bundle.getMessage("TitleBlockPathTable", block.getDisplayName());
BlockPathFrame frame = new BlockPathFrame(title, true, true, false, true);
if (log.isDebugEnabled()) {
log.debug("makeBlockPathFrame for Block " + block.getDisplayName());
}
frame.setName(block.getSystemName());
frame.init(block, this);
BlockPathTableModel blockPathModel = frame.getModel();
blockPathModel.init();
JTable blockPathTable = new JTable(blockPathModel);
blockPathTable.setTransferHandler(new jmri.util.DnDTableImportExportHandler(new int[] { BlockPathTableModel.EDIT_COL, BlockPathTableModel.DELETE_COL, BlockPathTableModel.UNITSCOL }));
blockPathTable.setDragEnabled(true);
blockPathTable.getColumnModel().getColumn(BlockPathTableModel.UNITSCOL).setCellRenderer(new MyBooleanRenderer(Bundle.getMessage("cm"), Bundle.getMessage("in")));
blockPathTable.getColumnModel().getColumn(BlockPathTableModel.EDIT_COL).setCellEditor(new ButtonEditor(new JButton()));
blockPathTable.getColumnModel().getColumn(BlockPathTableModel.EDIT_COL).setCellRenderer(new ButtonRenderer());
blockPathTable.getColumnModel().getColumn(BlockPathTableModel.DELETE_COL).setCellEditor(new ButtonEditor(new JButton()));
blockPathTable.getColumnModel().getColumn(BlockPathTableModel.DELETE_COL).setCellRenderer(new ButtonRenderer());
for (int i = 0; i < blockPathModel.getColumnCount(); i++) {
int width = blockPathModel.getPreferredWidth(i);
blockPathTable.getColumnModel().getColumn(i).setPreferredWidth(width);
}
blockPathTable.sizeColumnsToFit(-1);
int tableWidth = blockPathTable.getPreferredSize().width;
blockPathTable.setPreferredScrollableViewportSize(new java.awt.Dimension(tableWidth, ROW_HEIGHT * 10));
JScrollPane tablePane = new JScrollPane(blockPathTable);
JPanel contentPane = new JPanel();
contentPane.setLayout(new BorderLayout(5, 5));
JLabel prompt = new JLabel(Bundle.getMessage("AddPathPrompt"));
contentPane.add(prompt, BorderLayout.NORTH);
contentPane.add(tablePane, BorderLayout.CENTER);
frame.addInternalFrameListener(this);
frame.setContentPane(contentPane);
frame.setLocation(50, 30);
frame.pack();
return frame;
}
use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class TableFrames method makeSignalFrame.
/*
* ********************* SignalFrame *****************************
*/
protected JInternalFrame makeSignalFrame() {
JInternalFrame frame = new JInternalFrame(Bundle.getMessage("TitleSignalTable"), true, false, false, true);
_signalModel = new SignalTableModel(this);
_signalModel.init();
_signalTable = new JTable(_signalModel);
TableRowSorter<SignalTableModel> sorter = new TableRowSorter<>(_signalModel);
_signalTable.setRowSorter(sorter);
_signalTable.setTransferHandler(new jmri.util.DnDTableImportExportHandler(new int[] { SignalTableModel.UNITSCOL, SignalTableModel.DELETE_COL }));
_signalTable.setDragEnabled(true);
_signalTable.getColumnModel().getColumn(SignalTableModel.UNITSCOL).setCellRenderer(new MyBooleanRenderer(Bundle.getMessage("cm"), Bundle.getMessage("in")));
_signalTable.getColumnModel().getColumn(SignalTableModel.DELETE_COL).setCellEditor(new ButtonEditor(new JButton()));
_signalTable.getColumnModel().getColumn(SignalTableModel.DELETE_COL).setCellRenderer(new ButtonRenderer());
for (int i = 0; i < _signalModel.getColumnCount(); i++) {
int width = SignalTableModel.getPreferredWidth(i);
_signalTable.getColumnModel().getColumn(i).setPreferredWidth(width);
}
_signalTable.sizeColumnsToFit(-1);
int tableWidth = _signalTable.getPreferredSize().width;
_signalTable.setPreferredScrollableViewportSize(new java.awt.Dimension(tableWidth, ROW_HEIGHT * 8));
_signalTablePane = new JScrollPane(_signalTable);
JPanel contentPane = new JPanel();
contentPane.setLayout(new BorderLayout(5, 5));
JLabel prompt = new JLabel(Bundle.getMessage("AddSignalPrompt"));
contentPane.add(prompt, BorderLayout.NORTH);
contentPane.add(_signalTablePane, BorderLayout.CENTER);
frame.setContentPane(contentPane);
frame.setLocation(200, 350);
frame.pack();
return frame;
}
Aggregations