Author: jflesch
Date: 2007-07-01 23:12:55 +0000 (Sun, 01 Jul 2007)
New Revision: 13870

Modified:
   trunk/apps/Thaw/src/thaw/core/Core.java
   trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java
   trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
Log:
Let the user select the directory used for temporary files

Modified: trunk/apps/Thaw/src/thaw/core/Core.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Core.java     2007-07-01 22:50:16 UTC (rev 
13869)
+++ trunk/apps/Thaw/src/thaw/core/Core.java     2007-07-01 23:12:55 UTC (rev 
13870)
@@ -178,6 +178,9 @@
                        config.setDefaultValues();
                }

+               if (config.getValue("tmpDir") != null)
+                       System.setProperty("java.io.tmpdir", 
config.getValue("tmpDir"));
+
                return true;
        }


Modified: trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java  2007-07-01 22:50:16 UTC 
(rev 13869)
+++ trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java  2007-07-01 23:12:55 UTC 
(rev 13870)
@@ -1,18 +1,25 @@
 package thaw.core;

 import java.awt.GridLayout;
+import java.awt.BorderLayout;
 import java.util.Observable;
 import java.util.Observer;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;

 import javax.swing.JCheckBox;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
+import javax.swing.JButton;
 import javax.swing.JTextField;
+import javax.swing.JTextField;

+import thaw.gui.FileChooser;
+
 /**
  * Creates and manages the panel containing all the things to configure 
related to Thaw and only Thaw.
  */
-public class ThawConfigPanel implements Observer {
+public class ThawConfigPanel implements Observer, ActionListener {
        private Core core;
        private JPanel thawConfigPanel = null;

@@ -20,7 +27,10 @@

        private boolean advancedMode;

+       private JTextField tmpDirField;
+       private JButton tmpDirButton;

+
        public ThawConfigPanel(final ConfigWindow configWindow, final Core 
core) {
                this.core = core;

@@ -38,6 +48,23 @@
                thawConfigPanel.add(advancedModeBox);
                thawConfigPanel.add(new JLabel(" "));

+               tmpDirField = new 
JTextField(System.getProperty("java.io.tmpdir"));
+               tmpDirButton = new 
JButton(I18n.getMessage("thaw.common.browse"));
+               tmpDirButton.addActionListener(this);
+
+               if (advancedMode) {
+                       thawConfigPanel.add(new 
JLabel(I18n.getMessage("thaw.common.tempDir")));
+
+                       JPanel tempDirPanel = new JPanel(new BorderLayout());
+
+                       tempDirPanel.add(tmpDirField,
+                                        BorderLayout.CENTER);
+                       tempDirPanel.add(tmpDirButton,
+                                        BorderLayout.EAST);
+
+                       thawConfigPanel.add(tempDirPanel);
+               }
+
                configWindow.addObserver(this);
        }

@@ -47,14 +74,31 @@
        }


+       public void actionPerformed(ActionEvent e) {
+               FileChooser chooser = new 
FileChooser(System.getProperty("java.io.tmpdir"));
+               chooser.setTitle(I18n.getMessage("thaw.common.tempDir"));
+               chooser.setDirectoryOnly(true);
+               chooser.setDialogType(javax.swing.JFileChooser.OPEN_DIALOG);
+
+               java.io.File file = chooser.askOneFile();
+               tmpDirField.setText(file.getPath());
+       }
+
+
        public void update(final Observable o, final Object arg) {
                if(arg == core.getConfigWindow().getOkButton()) {
                        advancedMode = advancedModeBox.isSelected();
                        core.getConfig().setValue("advancedMode", 
Boolean.toString(advancedMode));
+
+                       core.getConfig().setValue("tmpDir", 
tmpDirField.getText());
+                       System.setProperty("java.io.tmpdir", 
tmpDirField.getText());
+                       
tmpDirField.setText(System.getProperty("java.io.tmpdir"));
                }

                if(arg == core.getConfigWindow().getCancelButton()) {
                        advancedModeBox.setSelected(advancedMode);
+
+                       
tmpDirField.setText(System.getProperty("java.io.tmpdir"));
                }
        }


Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-07-01 
22:50:16 UTC (rev 13869)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-07-01 
23:12:55 UTC (rev 13870)
@@ -83,7 +83,10 @@

 thaw.common.apply=Appliquer

+thaw.common.tempDir=R?pertoire pour les fichiers temporaires
+thaw.common.browse=Parcourir...

+
 ## Errors
 thaw.error.idAlreadyUsed=Impossible de se connecter. Notre identifiant est 
d?j? utilis? par un autre client connect? au noeud.


Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-07-01 22:50:16 UTC 
(rev 13869)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-07-01 23:12:55 UTC 
(rev 13870)
@@ -85,6 +85,9 @@

 thaw.common.apply=Apply

+thaw.common.tempDir=Directory for the temporary files
+thaw.common.browse=Browse...
+
 ## Errors
 thaw.error.idAlreadyUsed=Unable to connect. Our Id is already used by another 
client connected to the node.


Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-07-01 22:50:16 UTC 
(rev 13869)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-07-01 23:12:55 UTC 
(rev 13870)
@@ -83,7 +83,10 @@

 thaw.common.apply=Appliquer

+thaw.common.tempDir=R\u00e9pertoire pour les fichiers temporaires
+thaw.common.browse=Parcourir...

+
 ## Errors
 thaw.error.idAlreadyUsed=Impossible de se connecter. Notre identifiant est 
d\u00e9j\u00e0 utilis\u00e9 par un autre client connect\u00e9 au noeud.



Reply via email to