*/
private boolean _autoScroll;
+ /**
+ * Track the most recently calculated minimum width of all log table columns that doesn't truncate any content.
+ *
+ * @see ServerManagement#isLoggable(java.util.logging.LogRecord)
+ */
+ private int currentLogTableRowWidth = 0;
+
+ /**
+ * Track the most recently calculated minimum width of each log table column.
+ *
+ * @see ServerManagement#isLoggable(java.util.logging.LogRecord)
+ */
+ private int currentLogTableRowWidths[] = new int[4];
+
/**
* Regular presence announcements
*/
record.getMessage()
}
);
- if (_autoScroll) { // keep last record added in the view
- int row = gLogTable.getModel().getRowCount();
- gLogTable.scrollRectToVisible(gLogTable.getCellRect(row, 0, true));
+ // calculate row preferredWidth
+ int windowMargin = this.getWidth() - gLogTable.getWidth();
+ int tableMargin = gLogTable.getWidth() - gLogTable.getColumnModel().getTotalColumnWidth();
+ int lastRow = gLogTable.getRowCount() - 1;
+ int spacing = gLogTable.getIntercellSpacing().width;
+ int rowWidth = 0;
+ for (int column = 0; column < gLogTable.getColumnCount(); column++) {
+ int preferredWidth = gLogTable.prepareRenderer(gLogTable.getCellRenderer(lastRow, column), lastRow, column).getPreferredSize().width;
+ int actualWidth = gLogTable.prepareRenderer(gLogTable.getCellRenderer(lastRow, column), lastRow, column).getSize().width;
+ int minimumWidth = java.lang.Math.max(actualWidth, preferredWidth);
+ if (minimumWidth > currentLogTableRowWidths[column])
+ currentLogTableRowWidths[column] = minimumWidth + 8; // add hard-coded margin to ensure column is wider than rendered contents
+
+ rowWidth += spacing + currentLogTableRowWidths[column];
+ gLogTable.getColumnModel().getColumn(column).setPreferredWidth(currentLogTableRowWidths[column]);
+ }
+ if (rowWidth > currentLogTableRowWidth) {
+ java.awt.Dimension windowSize = new java.awt.Dimension(windowMargin + tableMargin + rowWidth, this.getHeight());
+ // FIXME: isLoggable(): remove auto table column and window resize console debug messages once resizing is confirmed to work correctly
+ System.err.println(MessageFormat.format("Before: window={0} margin={2} table={1} margin={3} currentRowWidth={4} newRowWidth={5}", this.getWidth(), gLogTable.getWidth(), windowMargin, tableMargin, currentLogTableRowWidth, rowWidth));
+ gLogTable.validate();
+ this.setSize(windowSize);
+ currentLogTableRowWidth = rowWidth;
+ System.err.println(MessageFormat.format(" After: window={0} margin={2} table={1} margin={3} currentRowWidth={4} newRowWidth={5}", this.getWidth(), gLogTable.getWidth(), windowMargin, tableMargin, currentLogTableRowWidth, rowWidth));
}
+ if (_autoScroll) // keep last record added in the view
+ gLogTable.scrollRectToVisible(gLogTable.getCellRect(lastRow, 0, true));
}
}
return _doLogging;