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;
}
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;
}
use of javax.swing.table.TableColumn in project processdash by dtuma.
the class WBSExcelWriter method createHeaderRow.
private void createHeaderRow(HSSFSheet sheet, TableColumnModel columns) {
HSSFRow row = sheet.createRow(0);
StyleKey style = new StyleKey();
style.bold = true;
for (int i = 0; i < columns.getColumnCount(); i++) {
TableColumn col = columns.getColumn(i);
String columnName = data.getColumnName(col.getModelIndex());
HSSFCell cell = row.createCell(s(i + 1));
cell.setCellValue(new HSSFRichTextString(columnName));
styleCache.applyStyle(cell, style);
}
}
use of javax.swing.table.TableColumn in project processdash by dtuma.
the class TeamMemberListTable method recreateWeekColumnsToFit.
/**
* Recreate the columns in the table model, to display data for as many
* weeks as possible (within the constraints of the width of the table)
*/
private void recreateWeekColumnsToFit() {
TeamMemberList teamList = getTeamMemberList();
TableColumnModel tcm = getColumnModel();
// compute the amount of space allocated to the weekly columns.
// first, get the width of the entire table
int tableWidth = getWidth();
int width = tableWidth;
// next, subtract out the width of the initial, fixed columns.
for (int i = COL_WIDTHS.length; i-- > 0; ) width = width - COL_WIDTHS[i];
// then, subtract out the width of the grippy column.
width = width - GRIPPY_WIDTH - getIntercellSpacing().width;
int numWeekColumns = Math.max(0, width / WEEK_COL_WIDTH);
int extraWidth = width - (numWeekColumns * WEEK_COL_WIDTH);
TableColumn firstCol = tcm.getColumn(0);
firstCol.setWidth(COL_WIDTHS[0] + extraWidth);
int existingNumWeekColumns = teamList.getNumWeekColumns();
if (existingNumWeekColumns != numWeekColumns) {
// remove the grippy column.
removeLastColumn(tcm);
// remove any weekly columns that are no longer needed
for (int i = numWeekColumns; i < existingNumWeekColumns; i++) removeLastColumn(tcm);
// reconfigure the table for the desired number of weekly columns
teamList.setNumWeekColumns(numWeekColumns);
// add any weekly columns that are now needed
int colIdx = tcm.getColumnCount();
for (int i = existingNumWeekColumns; i < numWeekColumns; i++) tcm.addColumn(createWeekColumn(colIdx++));
// add a grippy column at the end.
tcm.addColumn(createGrippyColumn(colIdx));
}
repositionHeaderDecorations(tableWidth, numWeekColumns);
}
use of javax.swing.table.TableColumn in project processdash by dtuma.
the class BlameValueTable method autoResizeColumns.
public void autoResizeColumns() {
int cellPad = 0;
for (int column = getColumnCount(); column-- > 1; ) {
int minWidth = 0;
for (int row = getRowCount(); row-- > 0; ) {
int cellWidth = getPreferredCellWidth(row, column);
minWidth = Math.max(minWidth, cellWidth);
}
TableColumn tableCol = getColumnModel().getColumn(column);
tableCol.setMinWidth(minWidth + cellPad);
tableCol.setPreferredWidth(minWidth + cellPad);
cellPad = 8;
}
}
Aggregations