Search in sources :

Example 81 with TableCellEditor

use of javax.swing.table.TableCellEditor in project JMRI by JMRI.

the class SchedulesTableModel method initTable.

public void initTable(SchedulesTableFrame frame, JTable table) {
    this.table = table;
    // Install the button handlers
    TableColumnModel tcm = table.getColumnModel();
    ButtonRenderer buttonRenderer = new ButtonRenderer();
    TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
    tcm.getColumn(EDIT_COLUMN).setCellRenderer(buttonRenderer);
    tcm.getColumn(EDIT_COLUMN).setCellEditor(buttonEditor);
    tcm.getColumn(DELETE_COLUMN).setCellRenderer(buttonRenderer);
    tcm.getColumn(DELETE_COLUMN).setCellEditor(buttonEditor);
    table.setDefaultRenderer(JComboBox.class, new jmri.jmrit.symbolicprog.ValueRenderer());
    table.setDefaultEditor(JComboBox.class, new jmri.jmrit.symbolicprog.ValueEditor());
    // set column preferred widths
    table.getColumnModel().getColumn(ID_COLUMN).setPreferredWidth(40);
    table.getColumnModel().getColumn(NAME_COLUMN).setPreferredWidth(200);
    table.getColumnModel().getColumn(SCHEDULE_STATUS_COLUMN).setPreferredWidth(80);
    table.getColumnModel().getColumn(SPUR_NUMBER_COLUMN).setPreferredWidth(40);
    table.getColumnModel().getColumn(SPUR_COLUMN).setPreferredWidth(350);
    table.getColumnModel().getColumn(STATUS_COLUMN).setPreferredWidth(150);
    table.getColumnModel().getColumn(MODE_COLUMN).setPreferredWidth(70);
    table.getColumnModel().getColumn(EDIT_COLUMN).setPreferredWidth(70);
    table.getColumnModel().getColumn(DELETE_COLUMN).setPreferredWidth(90);
    frame.loadTableDetails(table);
}
Also used : ButtonEditor(jmri.util.table.ButtonEditor) JButton(javax.swing.JButton) TableColumnModel(javax.swing.table.TableColumnModel) TableCellEditor(javax.swing.table.TableCellEditor) ButtonRenderer(jmri.util.table.ButtonRenderer)

Example 82 with TableCellEditor

use of javax.swing.table.TableCellEditor in project JMRI by JMRI.

the class ScheduleTableModel method initTable.

private void initTable(JTable table) {
    // Install the button handlers
    TableColumnModel tcm = table.getColumnModel();
    ButtonRenderer buttonRenderer = new ButtonRenderer();
    TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
    tcm.getColumn(UP_COLUMN).setCellRenderer(buttonRenderer);
    tcm.getColumn(UP_COLUMN).setCellEditor(buttonEditor);
    tcm.getColumn(DOWN_COLUMN).setCellRenderer(buttonRenderer);
    tcm.getColumn(DOWN_COLUMN).setCellEditor(buttonEditor);
    tcm.getColumn(DELETE_COLUMN).setCellRenderer(buttonRenderer);
    tcm.getColumn(DELETE_COLUMN).setCellEditor(buttonEditor);
    table.setDefaultRenderer(JComboBox.class, new jmri.jmrit.symbolicprog.ValueRenderer());
    table.setDefaultEditor(JComboBox.class, new jmri.jmrit.symbolicprog.ValueEditor());
    // set column preferred widths
    table.getColumnModel().getColumn(ID_COLUMN).setPreferredWidth(35);
    table.getColumnModel().getColumn(CURRENT_COLUMN).setPreferredWidth(50);
    table.getColumnModel().getColumn(TYPE_COLUMN).setPreferredWidth(90);
    table.getColumnModel().getColumn(RANDOM_COLUMN).setPreferredWidth(60);
    table.getColumnModel().getColumn(SETOUT_DAY_COLUMN).setPreferredWidth(90);
    table.getColumnModel().getColumn(ROAD_COLUMN).setPreferredWidth(90);
    table.getColumnModel().getColumn(LOAD_COLUMN).setPreferredWidth(90);
    table.getColumnModel().getColumn(SHIP_COLUMN).setPreferredWidth(90);
    table.getColumnModel().getColumn(DEST_COLUMN).setPreferredWidth(130);
    table.getColumnModel().getColumn(TRACK_COLUMN).setPreferredWidth(130);
    table.getColumnModel().getColumn(PICKUP_DAY_COLUMN).setPreferredWidth(90);
    table.getColumnModel().getColumn(COUNT_COLUMN).setPreferredWidth(45);
    table.getColumnModel().getColumn(WAIT_COLUMN).setPreferredWidth(40);
    table.getColumnModel().getColumn(UP_COLUMN).setPreferredWidth(60);
    table.getColumnModel().getColumn(DOWN_COLUMN).setPreferredWidth(70);
    table.getColumnModel().getColumn(DELETE_COLUMN).setPreferredWidth(70);
    _frame.loadTableDetails(table);
    // does not use a table sorter
    table.setRowSorter(null);
    updateList();
}
Also used : ButtonEditor(jmri.util.table.ButtonEditor) JButton(javax.swing.JButton) TableColumnModel(javax.swing.table.TableColumnModel) TableCellEditor(javax.swing.table.TableCellEditor) ButtonRenderer(jmri.util.table.ButtonRenderer)

Example 83 with TableCellEditor

use of javax.swing.table.TableCellEditor 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 84 with TableCellEditor

use of javax.swing.table.TableCellEditor in project JMRI by JMRI.

the class AutomationsTableModel method initTable.

protected void initTable(AutomationsTableFrame frame, JTable table) {
    _table = table;
    // Install the button handlers
    TableColumnModel tcm = table.getColumnModel();
    ButtonRenderer buttonRenderer = new ButtonRenderer();
    TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
    tcm.getColumn(RUN_COLUMN).setCellRenderer(buttonRenderer);
    tcm.getColumn(RUN_COLUMN).setCellEditor(buttonEditor);
    tcm.getColumn(EDIT_COLUMN).setCellRenderer(buttonRenderer);
    tcm.getColumn(EDIT_COLUMN).setCellEditor(buttonEditor);
    tcm.getColumn(DELETE_COLUMN).setCellRenderer(buttonRenderer);
    tcm.getColumn(DELETE_COLUMN).setCellEditor(buttonEditor);
    table.setDefaultRenderer(JComboBox.class, new jmri.jmrit.symbolicprog.ValueRenderer());
    table.setDefaultEditor(JComboBox.class, new jmri.jmrit.symbolicprog.ValueEditor());
    // set column preferred widths
    table.getColumnModel().getColumn(ID_COLUMN).setPreferredWidth(40);
    table.getColumnModel().getColumn(NAME_COLUMN).setPreferredWidth(200);
    table.getColumnModel().getColumn(COMMENT_COLUMN).setPreferredWidth(350);
    table.getColumnModel().getColumn(ACTION_COLUMN).setPreferredWidth(250);
    table.getColumnModel().getColumn(STATUS_COLUMN).setPreferredWidth(90);
    table.getColumnModel().getColumn(RUN_COLUMN).setPreferredWidth(90);
    table.getColumnModel().getColumn(EDIT_COLUMN).setPreferredWidth(70);
    table.getColumnModel().getColumn(DELETE_COLUMN).setPreferredWidth(90);
    frame.loadTableDetails(table);
}
Also used : ButtonEditor(jmri.util.table.ButtonEditor) JButton(javax.swing.JButton) TableColumnModel(javax.swing.table.TableColumnModel) TableCellEditor(javax.swing.table.TableCellEditor) ButtonRenderer(jmri.util.table.ButtonRenderer)

Example 85 with TableCellEditor

use of javax.swing.table.TableCellEditor in project JMRI by JMRI.

the class TrainsTableModel 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();
    TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
    tcm.getColumn(EDITCOLUMN).setCellRenderer(buttonRenderer);
    tcm.getColumn(EDITCOLUMN).setCellEditor(buttonEditor);
    tcm.getColumn(ACTIONCOLUMN).setCellRenderer(buttonRenderer);
    tcm.getColumn(ACTIONCOLUMN).setCellEditor(buttonEditor);
    tcm.getColumn(BUILDCOLUMN).setCellRenderer(buttonRenderer);
    tcm.getColumn(BUILDCOLUMN).setCellEditor(buttonEditor);
    _table.setDefaultRenderer(Boolean.class, new EnablingCheckboxRenderer());
    // set column preferred widths
    for (int i = 0; i < tcm.getColumnCount(); i++) {
        tcm.getColumn(i).setPreferredWidth(_tableColumnWidths[i]);
    }
    _frame.loadTableDetails(_table);
    // turn off column
    tcm.setColumnVisible(tcm.getColumnByModelIndex(IDCOLUMN), _sort == SORTBYID);
}
Also used : ButtonEditor(jmri.util.table.ButtonEditor) JButton(javax.swing.JButton) EnablingCheckboxRenderer(jmri.jmrit.beantable.EnablingCheckboxRenderer) TableCellEditor(javax.swing.table.TableCellEditor) XTableColumnModel(jmri.util.swing.XTableColumnModel) ButtonRenderer(jmri.util.table.ButtonRenderer)

Aggregations

TableCellEditor (javax.swing.table.TableCellEditor)129 JButton (javax.swing.JButton)41 ButtonEditor (jmri.util.table.ButtonEditor)33 ButtonRenderer (jmri.util.table.ButtonRenderer)33 TableColumnModel (javax.swing.table.TableColumnModel)24 JTable (javax.swing.JTable)22 ActionEvent (java.awt.event.ActionEvent)21 TableCellRenderer (javax.swing.table.TableCellRenderer)21 TableColumn (javax.swing.table.TableColumn)20 JLabel (javax.swing.JLabel)16 JScrollPane (javax.swing.JScrollPane)16 ActionListener (java.awt.event.ActionListener)15 MouseEvent (java.awt.event.MouseEvent)13 JPanel (javax.swing.JPanel)13 Component (java.awt.Component)11 Dimension (java.awt.Dimension)11 EventObject (java.util.EventObject)10 TableModel (javax.swing.table.TableModel)10 JComponent (javax.swing.JComponent)9 JTextField (javax.swing.JTextField)9