use of jmri.util.swing.XTableColumnModel in project JMRI by JMRI.
the class TrainsTableModel method setSort.
public void setSort(int sort) {
_sort = sort;
updateList();
XTableColumnModel tcm = (XTableColumnModel) _table.getColumnModel();
tcm.setColumnVisible(tcm.getColumnByModelIndex(IDCOLUMN), sort == SORTBYID);
tcm.setColumnVisible(tcm.getColumnByModelIndex(TIME_COLUMN), sort == SORTBYTIME);
}
use of jmri.util.swing.XTableColumnModel in project JMRI by JMRI.
the class TurnoutTableAction method showLockChanged.
void showLockChanged() {
boolean showLock = showLockBox.isSelected();
XTableColumnModel columnModel = (XTableColumnModel) table.getColumnModel();
TableColumn column = ((XTableColumnModel) table.getColumnModel()).getColumnByModelIndex(LOCKDECCOL);
columnModel.setColumnVisible(column, showLock);
column = columnModel.getColumnByModelIndex(LOCKOPRCOL);
columnModel.setColumnVisible(column, showLock);
}
use of jmri.util.swing.XTableColumnModel in project JMRI by JMRI.
the class SignalMastTableDataModel method makeJTable.
/**
* Does not appear to be used.
*
* @param srtr a table model
* @return a new table
* @deprecated since 4.5.4 without direct replacement
*/
@Deprecated
public JTable makeJTable(TableModel srtr) {
JTable table = new SignalMastJTable(srtr);
table.getTableHeader().setReorderingAllowed(true);
table.setColumnModel(new XTableColumnModel());
table.createDefaultColumnsFromModel();
addMouseListenerToHeader(table);
return table;
}
use of jmri.util.swing.XTableColumnModel in project JMRI by JMRI.
the class EnginesTableModel method initTable.
void initTable() {
// Use XTableColumnModel so we can control which columns are visible
XTableColumnModel tcm = new XTableColumnModel();
_table.setColumnModel(tcm);
_table.createDefaultColumnsFromModel();
// Install the button handlers
ButtonRenderer buttonRenderer = new ButtonRenderer();
tcm.getColumn(SET_COLUMN).setCellRenderer(buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
tcm.getColumn(SET_COLUMN).setCellEditor(buttonEditor);
tcm.getColumn(EDIT_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(EDIT_COLUMN).setCellEditor(buttonEditor);
// load defaults, xml file data not found
for (int i = 0; i < tcm.getColumnCount(); i++) {
tcm.getColumn(i).setPreferredWidth(_enginesTableColumnWidths[i]);
}
_frame.loadTableDetails(_table);
// turn off columns
tcm.setColumnVisible(tcm.getColumnByModelIndex(BUILT_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(OWNER_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(VALUE_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(RFID_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(RFID_WHEN_LAST_SEEN_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(RFID_WHERE_LAST_SEEN_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(LAST_COLUMN), false);
}
use of jmri.util.swing.XTableColumnModel in project JMRI by JMRI.
the class PickListModel method makePickTable.
/**
* Make pick table, DND enabled.
* @return the table
*/
public JTable makePickTable() {
_sorter = new TableRowSorter<>(this);
_table = new JTable(this) {
/**
* Overridden to prevent empty cells from being selected
*/
@Override
public void changeSelection(int row, int col, boolean toggle, boolean extend) {
if (this.getValueAt(row, col) != null) {
super.changeSelection(row, col, toggle, extend);
}
}
};
_sorter.setComparator(SNAME_COLUMN, new SystemNameComparator());
_table.setRowSorter(_sorter);
_table.setRowSelectionAllowed(true);
_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
_table.setPreferredScrollableViewportSize(new java.awt.Dimension(250, _table.getRowHeight() * 7));
_table.setDragEnabled(true);
_table.setTransferHandler(new jmri.util.DnDTableExportHandler());
_table.getTableHeader().setReorderingAllowed(true);
_table.setColumnModel(new XTableColumnModel());
_table.createDefaultColumnsFromModel();
TableColumnModel columnModel = _table.getColumnModel();
TableColumn sNameColumnT = columnModel.getColumn(SNAME_COLUMN);
sNameColumnT.setResizable(true);
sNameColumnT.setMinWidth(50);
//sNameColumnT.setMaxWidth(200);
TableColumn uNameColumnT = columnModel.getColumn(UNAME_COLUMN);
uNameColumnT.setResizable(true);
uNameColumnT.setMinWidth(100);
//uNameColumnT.setMaxWidth(300);
addMouseListenerToHeader(_table);
_table.setAutoCreateColumnsFromModel(false);
return _table;
}
Aggregations