Search in sources :

Example 31 with ButtonEditor

use of jmri.util.table.ButtonEditor 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 32 with ButtonEditor

use of jmri.util.table.ButtonEditor 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 33 with ButtonEditor

use of jmri.util.table.ButtonEditor 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 34 with ButtonEditor

use of jmri.util.table.ButtonEditor in project JMRI by JMRI.

the class WarrantTableFrame method initComponents.

/**
     * By default, Swing components should be created an installed in this
     * method, rather than in the ctor itself.
     */
@Override
public void initComponents() throws Exception {
    //Casts at getTableCellEditorComponent() now fails with 3.0 ??
    JTable table = new JTable(_model);
    ComboBoxCellEditor comboEd;
    TableRowSorter<WarrantTableModel> sorter = new TableRowSorter<>(_model);
    comboEd = new ComboBoxCellEditor(new JComboBox<>());
    table.setRowSorter(sorter);
    // Use XTableColumnModel so we can control which columns are visible
    XTableColumnModel tcm = new XTableColumnModel();
    table.setColumnModel(tcm);
    table.getTableHeader().setReorderingAllowed(true);
    table.createDefaultColumnsFromModel();
    _model.addHeaderListener(table);
    table.setDefaultRenderer(Boolean.class, new ButtonRenderer());
    table.setDefaultRenderer(JComboBox.class, new jmri.jmrit.symbolicprog.ValueRenderer());
    table.setDefaultEditor(JComboBox.class, new jmri.jmrit.symbolicprog.ValueEditor());
    JComboBox<String> box = new JComboBox<>(controls);
    box.setFont(new Font(null, Font.PLAIN, 12));
    table.getColumnModel().getColumn(WarrantTableModel.CONTROL_COLUMN).setCellEditor(new DefaultCellEditor(box));
    table.getColumnModel().getColumn(WarrantTableModel.ROUTE_COLUMN).setCellEditor(comboEd);
    table.getColumnModel().getColumn(WarrantTableModel.ALLOCATE_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
    table.getColumnModel().getColumn(WarrantTableModel.ALLOCATE_COLUMN).setCellRenderer(new ButtonRenderer());
    table.getColumnModel().getColumn(WarrantTableModel.DEALLOC_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
    table.getColumnModel().getColumn(WarrantTableModel.DEALLOC_COLUMN).setCellRenderer(new ButtonRenderer());
    table.getColumnModel().getColumn(WarrantTableModel.SET_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
    table.getColumnModel().getColumn(WarrantTableModel.SET_COLUMN).setCellRenderer(new ButtonRenderer());
    table.getColumnModel().getColumn(WarrantTableModel.AUTO_RUN_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
    table.getColumnModel().getColumn(WarrantTableModel.AUTO_RUN_COLUMN).setCellRenderer(new ButtonRenderer());
    table.getColumnModel().getColumn(WarrantTableModel.MANUAL_RUN_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
    table.getColumnModel().getColumn(WarrantTableModel.MANUAL_RUN_COLUMN).setCellRenderer(new ButtonRenderer());
    table.getColumnModel().getColumn(WarrantTableModel.EDIT_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
    table.getColumnModel().getColumn(WarrantTableModel.EDIT_COLUMN).setCellRenderer(new ButtonRenderer());
    table.getColumnModel().getColumn(WarrantTableModel.DELETE_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
    table.getColumnModel().getColumn(WarrantTableModel.DELETE_COLUMN).setCellRenderer(new ButtonRenderer());
    //table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    for (int i = 0; i < _model.getColumnCount(); i++) {
        int width = _model.getPreferredWidth(i);
        table.getColumnModel().getColumn(i).setPreferredWidth(width);
    }
    tcm.setColumnVisible(tcm.getColumnByModelIndex(WarrantTableModel.MANUAL_RUN_COLUMN), false);
    _rowHeight = box.getPreferredSize().height;
    table.setRowHeight(_rowHeight);
    table.setDragEnabled(true);
    table.setTransferHandler(new jmri.util.DnDTableExportHandler());
    _tablePane = new JScrollPane(table);
    JPanel tablePanel = new JPanel();
    tablePanel.setLayout(new BoxLayout(tablePanel, BoxLayout.Y_AXIS));
    tablePanel.add(Box.createVerticalGlue());
    JLabel title = new JLabel(Bundle.getMessage("ShowWarrants"));
    tablePanel.add(title);
    tablePanel.add(_tablePane);
    JPanel bottom = new JPanel();
    JPanel panel = new JPanel();
    JButton nxButton = new JButton(Bundle.getMessage("CreateNXWarrant"));
    nxButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            nxAction();
        }
    });
    panel.add(nxButton);
    panel.add(Box.createGlue());
    panel.add(new JLabel("status"));
    _status.addMouseListener(this);
    _status.setBackground(Color.white);
    _status.setFont(_status.getFont().deriveFont(Font.BOLD));
    _status.setEditable(false);
    setStatusText(BLANK.substring(0, 90), null, false);
    panel.add(_status);
    JButton haltAllButton = new JButton(Bundle.getMessage("HaltAllTrains"));
    haltAllButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            haltAllAction();
        }
    });
    haltAllButton.setForeground(Color.RED);
    panel.add(Box.createGlue());
    panel.add(haltAllButton);
    ///
    bottom.add(panel);
    tablePanel.add(bottom);
    addWindowListener(new java.awt.event.WindowAdapter() {

        @Override
        public void windowClosing(java.awt.event.WindowEvent e) {
            dispose();
        }
    });
    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
    fileMenu.add(new jmri.configurexml.SaveMenu());
    menuBar.add(fileMenu);
    JMenu warrantMenu = new JMenu(Bundle.getMessage("MenuWarrant"));
    warrantMenu.add(new AbstractAction(Bundle.getMessage("ConcatWarrants")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            concatMenuAction();
        }
    });
    warrantMenu.add(new jmri.jmrit.logix.WarrantTableAction("CreateWarrant"));
    warrantMenu.add(WarrantTableAction._trackerTable);
    warrantMenu.add(new AbstractAction(Bundle.getMessage("CreateNXWarrant")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            nxAction();
        }
    });
    warrantMenu.add(WarrantTableAction.makeLogMenu());
    menuBar.add(warrantMenu);
    setJMenuBar(menuBar);
    addHelpMenu("package.jmri.jmrit.logix.WarrantTable", true);
    getContentPane().add(tablePanel);
    //        setLocation(50,0);
    pack();
}
Also used : JPanel(javax.swing.JPanel) ButtonEditor(jmri.util.table.ButtonEditor) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) Font(java.awt.Font) AbstractAction(javax.swing.AbstractAction) TableRowSorter(javax.swing.table.TableRowSorter) JScrollPane(javax.swing.JScrollPane) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) XTableColumnModel(jmri.util.swing.XTableColumnModel) DefaultCellEditor(javax.swing.DefaultCellEditor) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) ButtonRenderer(jmri.util.table.ButtonRenderer) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 35 with ButtonEditor

use of jmri.util.table.ButtonEditor 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)

Aggregations

ButtonEditor (jmri.util.table.ButtonEditor)41 ButtonRenderer (jmri.util.table.ButtonRenderer)41 JButton (javax.swing.JButton)40 TableCellEditor (javax.swing.table.TableCellEditor)33 TableColumnModel (javax.swing.table.TableColumnModel)23 JLabel (javax.swing.JLabel)17 JPanel (javax.swing.JPanel)15 JScrollPane (javax.swing.JScrollPane)15 JTable (javax.swing.JTable)15 ActionEvent (java.awt.event.ActionEvent)10 BoxLayout (javax.swing.BoxLayout)10 Dimension (java.awt.Dimension)9 ActionListener (java.awt.event.ActionListener)9 FlowLayout (java.awt.FlowLayout)7 XTableColumnModel (jmri.util.swing.XTableColumnModel)7 TableColumn (javax.swing.table.TableColumn)6 TableRowSorter (javax.swing.table.TableRowSorter)6 BorderLayout (java.awt.BorderLayout)5 Point (java.awt.Point)5 DefaultCellEditor (javax.swing.DefaultCellEditor)5