Search in sources :

Example 86 with TableColumn

use of javax.swing.table.TableColumn in project processdash by dtuma.

the class TaskScheduleDialog method createFlatColumnModel.

private TableColumnModel createFlatColumnModel() {
    DefaultTableColumnModel result = new DefaultTableColumnModel();
    int extraWidth = 0;
    for (int i = 0; i < treeColumnModel.getColumnCount(); i++) {
        TableColumn c = treeColumnModel.getColumn(i);
        switch(c.getModelIndex()) {
            case EVTaskList.TASK_COLUMN:
            case EVTaskList.NODE_TYPE_COLUMN:
            case EVTaskList.PLAN_TIME_COLUMN:
            case EVTaskList.PLAN_DTIME_COLUMN:
            //case EVTaskList.ACT_DTIME_COLUMN:
            case EVTaskList.PLAN_DATE_COLUMN:
            case EVTaskList.REPLAN_DATE_COLUMN:
            case EVTaskList.FORECAST_DATE_COLUMN:
            case EVTaskList.MILESTONE_COLUMN:
            case EVTaskList.LABELS_COLUMN:
            case EVTaskList.NOTES_COLUMN:
            case EVTaskList.DEPENDENCIES_COLUMN:
            case EVTaskList.PCT_SPENT_COLUMN:
                result.addColumn(TableUtils.cloneTableColumn(c));
                break;
            default:
                extraWidth += c.getPreferredWidth();
                break;
        }
    }
    TableColumn c = result.getColumn(0);
    c.setPreferredWidth(c.getWidth() + extraWidth);
    return result;
}
Also used : DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) TableColumn(javax.swing.table.TableColumn) Point(java.awt.Point)

Example 87 with TableColumn

use of javax.swing.table.TableColumn in project processdash by dtuma.

the class TableUtils method cloneTableColumn.

public static TableColumn cloneTableColumn(TableColumn c) {
    TableColumn result = new TableColumn(c.getModelIndex(), c.getPreferredWidth(), c.getCellRenderer(), c.getCellEditor());
    result.setMaxWidth(c.getMaxWidth());
    result.setMinWidth(c.getMinWidth());
    result.setResizable(c.getResizable());
    result.setHeaderValue(c.getHeaderValue());
    result.setHeaderRenderer(c.getHeaderRenderer());
    result.setIdentifier(c.getIdentifier());
    return result;
}
Also used : TableColumn(javax.swing.table.TableColumn)

Example 88 with TableColumn

use of javax.swing.table.TableColumn in project processdash by dtuma.

the class SizeMetricsTableModel method createJTable.

public JTable createJTable() {
    JTable table = new ItemListJTable(this);
    // adjust column widths
    table.getColumnModel().getColumn(0).setPreferredWidth(100);
    table.getColumnModel().getColumn(1).setPreferredWidth(200);
    table.getColumnModel().getColumn(2).setPreferredWidth(100);
    table.setRowHeight(table.getRowHeight() + 4);
    // draw read-only phases with a different appearance
    table.setDefaultRenderer(String.class, new ItemTableCellRenderer());
    // install a combo box as the editor for the "phase type" column
    TableColumn unitsColumn = table.getColumnModel().getColumn(UNITS_COL);
    JComboBox unitsEditor = new JComboBox(UNITS_TYPES);
    unitsEditor.setRenderer(new UnitsCellRenderer());
    unitsEditor.setFont(unitsEditor.getFont().deriveFont(Font.PLAIN));
    unitsColumn.setCellEditor(new DefaultCellEditor(unitsEditor));
    return table;
}
Also used : JComboBox(javax.swing.JComboBox) JTable(javax.swing.JTable) TableColumn(javax.swing.table.TableColumn) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 89 with TableColumn

use of javax.swing.table.TableColumn in project processdash by dtuma.

the class TimeLogEditor method constructEditPanel.

private JPanel constructEditPanel() {
    JPanel retPanel = new JPanel(false);
    retPanel.setLayout(new BorderLayout());
    tableModel = new TimeLogTableModel();
    if (Settings.isReadOnly() || forceReadOnly)
        tableModel.setEditable(false);
    tableModel.setApprover(approver);
    tableModel.addTableModelListener(this);
    table = new TimeLogJTable(tableModel);
    TableUtils.configureTable(table, TimeLogTableModel.COLUMN_WIDTHS, TimeLogTableModel.COLUMN_TOOLTIPS);
    TableColumn startTimeCol = table.getColumnModel().getColumn(TimeLogTableModel.COL_START_TIME);
    startTimeCol.setCellEditor(new JDateTimeChooserCellEditor(Settings.getVal("timelog.dateTimeEditFormat", DATE_TIME_FORMAT)));
    retPanel.add("Center", new JScrollPane(table));
    JPanel btnPanel = new JPanel(false);
    addButton = createButton(btnPanel, "Add", "addRow");
    createButton(btnPanel, "Delete", "deleteSelectedRow");
    createButton(btnPanel, "Summarize_Button", "summarizeWarning");
    if (Settings.isReadWrite() && !forceReadOnly)
        retPanel.add("South", btnPanel);
    return retPanel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) TimeLogTableModel(net.sourceforge.processdash.log.time.TimeLogTableModel) JDateTimeChooserCellEditor(net.sourceforge.processdash.ui.lib.JDateTimeChooserCellEditor) TableColumn(javax.swing.table.TableColumn)

Example 90 with TableColumn

use of javax.swing.table.TableColumn in project processdash by dtuma.

the class InstructionTable method setUpWrappedTextColumn.

void setUpWrappedTextColumn() {
    TableColumn column = getColumnModel().getColumn(1);
    column.setCellRenderer(new WrappedTextTableCellRenderer(this));
}
Also used : TableColumn(javax.swing.table.TableColumn) WrappedTextTableCellRenderer(net.sourceforge.processdash.ui.lib.WrappedTextTableCellRenderer)

Aggregations

TableColumn (javax.swing.table.TableColumn)272 TableColumnModel (javax.swing.table.TableColumnModel)75 JTable (javax.swing.JTable)51 TableCellRenderer (javax.swing.table.TableCellRenderer)50 JScrollPane (javax.swing.JScrollPane)44 JPanel (javax.swing.JPanel)33 Component (java.awt.Component)31 JLabel (javax.swing.JLabel)26 BoxLayout (javax.swing.BoxLayout)25 JComboBox (javax.swing.JComboBox)23 ActionEvent (java.awt.event.ActionEvent)21 Dimension (java.awt.Dimension)20 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)20 DefaultCellEditor (javax.swing.DefaultCellEditor)19 ActionListener (java.awt.event.ActionListener)17 JButton (javax.swing.JButton)17 FlowLayout (java.awt.FlowLayout)16 DefaultTableModel (javax.swing.table.DefaultTableModel)15 ArrayList (java.util.ArrayList)14 DefaultTableColumnModel (javax.swing.table.DefaultTableColumnModel)12