Search in sources :

Example 1 with XTableColumnModel

use of jmri.util.swing.XTableColumnModel in project JMRI by JMRI.

the class SensorTableDataModel method showPullUp.

public void showPullUp(boolean show) {
    XTableColumnModel columnModel = (XTableColumnModel) table.getColumnModel();
    TableColumn column = columnModel.getColumnByModelIndex(PULLUPCOL);
    columnModel.setColumnVisible(column, show);
}
Also used : XTableColumnModel(jmri.util.swing.XTableColumnModel) TableColumn(javax.swing.table.TableColumn)

Example 2 with XTableColumnModel

use of jmri.util.swing.XTableColumnModel in project JMRI by JMRI.

the class TrackTableModel method setColumnsVisible.

// only show "Load", "Ship", "Road", "Destination", "Planned", "Pool" "Alternate" if they are needed
protected void setColumnsVisible() {
    XTableColumnModel tcm = (XTableColumnModel) _table.getColumnModel();
    tcm.setColumnVisible(tcm.getColumnByModelIndex(RESTRICTION_COLUMN), _location.hasServiceRestrictions());
    tcm.setColumnVisible(tcm.getColumnByModelIndex(LOAD_COLUMN), _location.hasLoadRestrictions());
    tcm.setColumnVisible(tcm.getColumnByModelIndex(SHIP_COLUMN), _location.hasShipLoadRestrictions());
    tcm.setColumnVisible(tcm.getColumnByModelIndex(ROAD_COLUMN), _location.hasRoadRestrictions());
    tcm.setColumnVisible(tcm.getColumnByModelIndex(DESTINATION_COLUMN), _location.hasDestinationRestrictions());
    tcm.setColumnVisible(tcm.getColumnByModelIndex(PLANPICKUP_COLUMN), _location.hasPlannedPickups());
    tcm.setColumnVisible(tcm.getColumnByModelIndex(POOL_COLUMN), _location.hasPools());
    tcm.setColumnVisible(tcm.getColumnByModelIndex(ALT_TRACK_COLUMN), _location.hasAlternateTracks());
    tcm.setColumnVisible(tcm.getColumnByModelIndex(MOVES_COLUMN), Setup.isShowTrackMovesEnabled());
}
Also used : XTableColumnModel(jmri.util.swing.XTableColumnModel)

Example 3 with XTableColumnModel

use of jmri.util.swing.XTableColumnModel in project JMRI by JMRI.

the class EnginesTableModel method setSort.

/**
     * Not all columns are visible at the same time.
     * 
     * @param sort which sort is active
     */
public void setSort(int sort) {
    _sort = sort;
    updateList();
    if (sort == SORTBY_MOVES || sort == SORTBY_BUILT || sort == SORTBY_OWNER || sort == SORTBY_VALUE || sort == SORTBY_RFID || sort == SORTBY_LAST) {
        XTableColumnModel tcm = (XTableColumnModel) _table.getColumnModel();
        tcm.setColumnVisible(tcm.getColumnByModelIndex(MOVES_COLUMN), sort == SORTBY_MOVES);
        tcm.setColumnVisible(tcm.getColumnByModelIndex(BUILT_COLUMN), sort == SORTBY_BUILT);
        tcm.setColumnVisible(tcm.getColumnByModelIndex(OWNER_COLUMN), sort == SORTBY_OWNER);
        tcm.setColumnVisible(tcm.getColumnByModelIndex(VALUE_COLUMN), sort == SORTBY_VALUE);
        tcm.setColumnVisible(tcm.getColumnByModelIndex(RFID_COLUMN), sort == SORTBY_RFID);
        tcm.setColumnVisible(tcm.getColumnByModelIndex(RFID_WHEN_LAST_SEEN_COLUMN), sort == SORTBY_RFID);
        tcm.setColumnVisible(tcm.getColumnByModelIndex(RFID_WHERE_LAST_SEEN_COLUMN), sort == SORTBY_RFID);
        tcm.setColumnVisible(tcm.getColumnByModelIndex(LAST_COLUMN), sort == SORTBY_LAST);
    } else {
        fireTableDataChanged();
    }
}
Also used : XTableColumnModel(jmri.util.swing.XTableColumnModel)

Example 4 with XTableColumnModel

use of jmri.util.swing.XTableColumnModel in project JMRI by JMRI.

the class BeanTableDataModel method makeJTable.

/**
     * Create and configure a new table using the given model and row sorter.
     *
     * @param name   the name of the table
     * @param model  the data model for the table
     * @param sorter the row sorter for the table; if null, the table will not
     *               be sortable
     * @return the table
     * @throws NullPointerException if name or model are null
     */
public JTable makeJTable(@Nonnull String name, @Nonnull TableModel model, @Nullable RowSorter<? extends TableModel> sorter) {
    Objects.requireNonNull(name, "the table name must be nonnull");
    Objects.requireNonNull(model, "the table model must be nonnull");
    JTable table = new JTable(model);
    table.setName(name);
    table.setRowSorter(sorter);
    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 5 with XTableColumnModel

use of jmri.util.swing.XTableColumnModel in project JMRI by JMRI.

the class BeanTableDataModel method makeJTable.

/**
     * Create a new table.
     *
     * @param sorter the sorter and model for the table
     * @return a new table
     * @deprecated since 4.5.4; use
     * {@link #makeJTable(java.lang.String, javax.swing.table.TableModel, javax.swing.RowSorter)}
     * instead.
     */
@Deprecated
public JTable makeJTable(TableSorter sorter) {
    JTable table = new JTable(sorter);
    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)

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