Search in sources :

Example 21 with XTableColumnModel

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);
}
Also used : XTableColumnModel(jmri.util.swing.XTableColumnModel)

Example 22 with XTableColumnModel

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);
}
Also used : XTableColumnModel(jmri.util.swing.XTableColumnModel) TableColumn(javax.swing.table.TableColumn)

Example 23 with XTableColumnModel

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;
}
Also used : JTable(javax.swing.JTable) XTableColumnModel(jmri.util.swing.XTableColumnModel)

Example 24 with XTableColumnModel

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);
}
Also used : ButtonEditor(jmri.util.table.ButtonEditor) JButton(javax.swing.JButton) TableCellEditor(javax.swing.table.TableCellEditor) XTableColumnModel(jmri.util.swing.XTableColumnModel) ButtonRenderer(jmri.util.table.ButtonRenderer)

Example 25 with XTableColumnModel

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;
}
Also used : TableColumnModel(javax.swing.table.TableColumnModel) XTableColumnModel(jmri.util.swing.XTableColumnModel) XTableColumnModel(jmri.util.swing.XTableColumnModel) TableColumn(javax.swing.table.TableColumn) JTable(javax.swing.JTable) SystemNameComparator(jmri.util.SystemNameComparator)

Aggregations

XTableColumnModel (jmri.util.swing.XTableColumnModel)28 TableColumn (javax.swing.table.TableColumn)12 JButton (javax.swing.JButton)9 JTable (javax.swing.JTable)8 ButtonEditor (jmri.util.table.ButtonEditor)7 ButtonRenderer (jmri.util.table.ButtonRenderer)7 TableCellEditor (javax.swing.table.TableCellEditor)6 JLabel (javax.swing.JLabel)5 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 MouseEvent (java.awt.event.MouseEvent)3 JComboBox (javax.swing.JComboBox)3 JPanel (javax.swing.JPanel)3 RowSorter (javax.swing.RowSorter)3 TableColumnModel (javax.swing.table.TableColumnModel)3 TableRowSorter (javax.swing.table.TableRowSorter)3 MouseAdapter (java.awt.event.MouseAdapter)2 Hashtable (java.util.Hashtable)2 BoxLayout (javax.swing.BoxLayout)2 DefaultCellEditor (javax.swing.DefaultCellEditor)2