Author: jflesch
Date: 2007-09-06 00:59:22 +0000 (Thu, 06 Sep 2007)
New Revision: 14982

Modified:
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java
Log:
Fix file downloads / attachments in minifrost : Thaw should remember the last 
used directory

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java  2007-09-06 
00:42:25 UTC (rev 14981)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java  2007-09-06 
00:59:22 UTC (rev 14982)
@@ -337,7 +337,12 @@
                }

                public void run() {
-                       FileChooser chooser = new FileChooser();
+                       String initialPath = 
mainPanel.getConfig().getValue("lastSourceDirectory");
+
+                       FileChooser chooser;
+
+                       chooser = ((initialPath != null) ? new 
FileChooser(initialPath) : new FileChooser());
+
                        
chooser.setTitle(I18n.getMessage("thaw.plugin.transferLogs.chooseFile"));
                        chooser.setDirectoryOnly(false);
                        chooser.setDialogType(JFileChooser.OPEN_DIALOG);
@@ -349,6 +354,10 @@
                                return;
                        }

+                       if (files.size() > 0) {
+                               
mainPanel.getConfig().setValue("lastSourceDirectory", 
chooser.getFinalDirectory());
+                       }
+
                        for (Iterator it = files.iterator();
                             it.hasNext(); ) {
                                draft.addAttachment((File)it.next());

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java        
2007-09-06 00:42:25 UTC (rev 14981)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java        
2007-09-06 00:59:22 UTC (rev 14982)
@@ -81,10 +81,17 @@

        private JLabel subject;

+       private KeyActionMenu keyActionMenu;

        public MessagePanel(MiniFrostPanel mainPanel) {
                this.mainPanel = mainPanel;

+
+               /* keyActionMenu == Right click menu when you click on an 
highlighted key
+                */
+               keyActionMenu = new KeyActionMenu(chkActions, indexActions);
+
+
                insidePanel = null;

                panel = new JPanel(new BorderLayout(15, 15));
@@ -535,7 +542,7 @@
        }


-       protected static class KeyActionMenu extends JPopupMenu implements 
ActionListener {
+       protected class KeyActionMenu extends JPopupMenu implements 
ActionListener {
                private String key;
                private JMenuItem[] chkActions;
                private JMenuItem[] indexActions;
@@ -631,32 +638,44 @@

                        } else if (e.getSource() == chkActions[0]) { /* 
download this key */

-                               thaw.gui.FileChooser chooser = new 
thaw.gui.FileChooser();
+                               String lastPath = 
mainPanel.getConfig().getValue("lastDestinationDirectory");

+                               thaw.gui.FileChooser chooser = (lastPath != 
null ?
+                                                               new 
thaw.gui.FileChooser(lastPath) :
+                                                               new 
thaw.gui.FileChooser());
+
                                
chooser.setTitle(I18n.getMessage("thaw.plugin.fetch.chooseDestination"));
                                chooser.setDirectoryOnly(true);
-                               
chooser.setDialogType(javax.swing.JFileChooser.OPEN_DIALOG);
+                               
chooser.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);

                                java.io.File file = chooser.askOneFile();

                                if (file == null)
                                        return;

+                               
mainPanel.getConfig().setValue("lastDestinationDirectory", file.getPath());
+
                                download(key, file);

                        } else if (e.getSource() == chkActions[1]) { /* 
download all the keys */

-                               thaw.gui.FileChooser chooser = new 
thaw.gui.FileChooser();
+                               String lastPath = 
mainPanel.getConfig().getValue("lastDestinationDirectory");

+                               thaw.gui.FileChooser chooser = (lastPath != 
null ?
+                                                               new 
thaw.gui.FileChooser(lastPath) :
+                                                               new 
thaw.gui.FileChooser());
+
                                
chooser.setTitle(I18n.getMessage("thaw.plugin.fetch.chooseDestination"));
                                chooser.setDirectoryOnly(true);
-                               
chooser.setDialogType(javax.swing.JFileChooser.OPEN_DIALOG);
+                               
chooser.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);

                                java.io.File file = chooser.askOneFile();

                                if (file == null)
                                        return;

+                               
mainPanel.getConfig().setValue("lastDestinationDirectory", file.getPath());
+
                                Vector v = messagePanel.getCHKKeys();

                                for (Iterator it = v.iterator();
@@ -683,9 +702,7 @@
        }


-       public final static KeyActionMenu keyActionMenu = new 
KeyActionMenu(chkActions, indexActions);

-
        public void popMenuOnKey(MouseEvent e, String key) {
                keyActionMenu.setKeys(this, key);
                keyActionMenu.show(e.getComponent(), e.getX(), e.getY());


Reply via email to