private void saveColumnSpecification() { final TableColumnModel columnModel = table.getColumnModel(); final int numColumns = table.getColumnCount(); final List<String> columns = new ArrayList<String>(numColumns); final List<Integer> columnWidths = new ArrayList<Integer>(numColumns); for (int i = 0; i < numColumns; i++) { final String columnName = table.getColumnName(i); columns.add(columnName); final TableColumn column = columnModel.getColumn(i); final int columnWidth = column.getWidth(); columnWidths.add(Integer.valueOf(columnWidth)); } tableSpecification.setColumnOrder(columns); tableSpecification.setColumnWidths(columnWidths); MetricsProfileRepository.getInstance().persistCurrentProfile(); }
/* * Update the TableColumn with the newly calculated width */ private void updateTableColumn(int column, int width) { final TableColumn tableColumn = table.getColumnModel().getColumn(column); if (!tableColumn.getResizable()) return; width += spacing; // Don't shrink the column width if (isOnlyAdjustLarger) { width = Math.max(width, tableColumn.getPreferredWidth()); } columnSizes.put(tableColumn, new Integer(tableColumn.getWidth())); table.getTableHeader().setResizingColumn(tableColumn); tableColumn.setWidth(width); }