Author: bback
Date: 2006-02-19 12:32:50 +0000 (Sun, 19 Feb 2006)
New Revision: 8067
Modified:
trunk/apps/frost-0.7/source/frost/MainFrame.java
trunk/apps/frost-0.7/source/frost/gui/MessageTable.java
Log:
column position and width in messagetable are now saved
Modified: trunk/apps/frost-0.7/source/frost/MainFrame.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/MainFrame.java 2006-02-19 00:58:04 UTC
(rev 8066)
+++ trunk/apps/frost-0.7/source/frost/MainFrame.java 2006-02-19 12:32:50 UTC
(rev 8067)
@@ -61,18 +61,6 @@
*/
private class Listener extends WindowAdapter {
public void windowClosing(WindowEvent e) {
- // save size,location and state of window
- Rectangle bounds = getBounds();
- boolean isMaximized = ((getExtendedState() & Frame.MAXIMIZED_BOTH)
!= 0);
-
- frostSettings.setValue("lastFrameMaximized", isMaximized);
-
- if (!isMaximized) { //Only saves the dimension if it is not
maximized
- frostSettings.setValue("lastFrameHeight", bounds.height);
- frostSettings.setValue("lastFrameWidth", bounds.width);
- frostSettings.setValue("lastFramePosX", bounds.x);
- frostSettings.setValue("lastFramePosY", bounds.y);
- }
fileExitMenuItem_actionPerformed(null);
}
} // end of class popuplistener
@@ -894,6 +882,9 @@
messageTable.getSelectionModel().addListSelectionListener(listener);
messageListScrollPane = new JScrollPane(messageTable);
+ // load message table layout
+ messageTable.loadLayout(frostSettings);
+
// build message body scroll pane
messageTextArea = new AntialiasedTextArea();
messageTextArea.setEditable(false);
@@ -2239,6 +2230,21 @@
*/
private void fileExitMenuItem_actionPerformed(ActionEvent e) {
+ // save size,location and state of window
+ Rectangle bounds = getBounds();
+ boolean isMaximized = ((getExtendedState() & Frame.MAXIMIZED_BOTH) !=
0);
+
+ frostSettings.setValue("lastFrameMaximized", isMaximized);
+
+ if (!isMaximized) { //Only saves the dimension if it is not maximized
+ frostSettings.setValue("lastFrameHeight", bounds.height);
+ frostSettings.setValue("lastFrameWidth", bounds.width);
+ frostSettings.setValue("lastFramePosX", bounds.x);
+ frostSettings.setValue("lastFramePosY", bounds.y);
+ }
+
+ messageTable.saveLayout(frostSettings);
+
if
(tofTree.getRunningBoardUpdateThreads().getRunningUploadThreadCount() > 0) {
int result =
JOptionPane.showConfirmDialog(
Modified: trunk/apps/frost-0.7/source/frost/gui/MessageTable.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/gui/MessageTable.java 2006-02-19
00:58:04 UTC (rev 8066)
+++ trunk/apps/frost-0.7/source/frost/gui/MessageTable.java 2006-02-19
12:32:50 UTC (rev 8067)
@@ -23,6 +23,7 @@
import javax.swing.*;
import javax.swing.table.*;
+import frost.*;
import frost.gui.model.*;
import frost.gui.objects.*;
import frost.messages.*;
@@ -43,6 +44,74 @@
}
/**
+ * Save the current column positions and column sizes for restore on next
startup.
+ *
+ * @param frostSettings
+ */
+ public void saveLayout(SettingsClass frostSettings) {
+ TableColumnModel tcm = getColumnModel();
+ for(int columnIndexInTable=0; columnIndexInTable <
tcm.getColumnCount(); columnIndexInTable++) {
+ TableColumn tc = tcm.getColumn(columnIndexInTable);
+ int columnIndexInModel = tc.getModelIndex();
+ // save the current index in table for column with the fix index
in model
+
frostSettings.setValue("messagetable.tableindex.modelcolumn."+columnIndexInModel,
columnIndexInTable);
+ // save the current width of the column
+ int columnWidth = tc.getWidth();
+
frostSettings.setValue("messagetable.columnwidth.modelcolumn."+columnIndexInModel,
columnWidth);
+ }
+ }
+
+ /**
+ * Load the saved column positions and column sizes.
+ *
+ * @param frostSettings
+ */
+ public void loadLayout(SettingsClass frostSettings) {
+ TableColumnModel tcm = getColumnModel();
+
+ // load the saved tableindex for each column in model, and its saved
width
+ int[] tableToModelIndex = new int[tcm.getColumnCount()];
+ int[] columnWidths = new int[tcm.getColumnCount()];
+
+ for(int x=0; x < tableToModelIndex.length; x++) {
+ String indexKey = "messagetable.tableindex.modelcolumn."+x;
+ if( frostSettings.getObjectValue(indexKey) == null ) {
+ return; // column not found, abort
+ }
+ // build array of table to model associations
+ int tableIndex = frostSettings.getIntValue(indexKey);
+ if( tableIndex < 0 || tableIndex >= tableToModelIndex.length ) {
+ return; // invalid table index value
+ }
+ tableToModelIndex[tableIndex] = x;
+
+ String widthKey = "messagetable.columnwidth.modelcolumn."+x;
+ if( frostSettings.getObjectValue(widthKey) == null ) {
+ return; // column not found, abort
+ }
+ // build array of table to model associations
+ int columnWidth = frostSettings.getIntValue(widthKey);
+ if( columnWidth <= 0 ) {
+ return; // invalid column width
+ }
+ columnWidths[x] = columnWidth;
+ }
+ // columns are currently added in model order, remove them all and
save in an array
+ // while on it, set the loaded width of each column
+ TableColumn[] tcms = new TableColumn[tcm.getColumnCount()];
+ for(int x=tcms.length-1; x >= 0; x--) {
+ tcms[x] = tcm.getColumn(x);
+ tcm.removeColumn(tcms[x]);
+
+ tcms[x].setPreferredWidth(columnWidths[x]);
+ }
+ // add the columns in order loaded from settings
+ for(int x=0; x < tableToModelIndex.length; x++) {
+ tcm.addColumn(tcms[tableToModelIndex[x]]);
+ }
+ }
+
+ /**
* This renderer renders rows in different colors.
* New messages gets a bold look, messages with attachments a blue color.
* Encrypted messages get a red color, no matter if they have attachments.
@@ -179,4 +248,3 @@
setRowHeight(font.getSize() + 5);
}
}
-