diff options
author | Jonathan Bauer | 2014-09-12 15:30:55 +0200 |
---|---|---|
committer | Jonathan Bauer | 2014-09-12 15:30:55 +0200 |
commit | 0cdabcb40bc8d0a3aad8a927a53bd85a95627b8d (patch) | |
tree | 726498f1ca711763e9f61b9b0feb8db8c239ae40 /dozentenmodul/src | |
parent | [client] Show automatically generated version string (diff) | |
download | tutor-module-0cdabcb40bc8d0a3aad8a927a53bd85a95627b8d.tar.gz tutor-module-0cdabcb40bc8d0a3aad8a927a53bd85a95627b8d.tar.xz tutor-module-0cdabcb40bc8d0a3aad8a927a53bd85a95627b8d.zip |
use new Config stuff for reading download/upload paths
Diffstat (limited to 'dozentenmodul/src')
4 files changed, 53 insertions, 259 deletions
diff --git a/dozentenmodul/src/main/java/gui/image/FTPCreateUploader_GUI.java b/dozentenmodul/src/main/java/gui/image/FTPCreateUploader_GUI.java index a9461bb4..63cda60d 100644 --- a/dozentenmodul/src/main/java/gui/image/FTPCreateUploader_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/FTPCreateUploader_GUI.java @@ -54,6 +54,7 @@ import util.OpenLinks; import ftp.UploadTask; import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; +import config.Config; @SuppressWarnings("serial") public class FTPCreateUploader_GUI extends JFrame implements @@ -161,22 +162,8 @@ public class FTPCreateUploader_GUI extends JFrame implements JButton btnSpeicherortAuswhlen = new JButton("Image ausw\u00E4hlen"); btnSpeicherortAuswhlen.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { - try { - Wini ini = new Wini( - new File( - "C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - fc = new JFileChooser(ini.get("main", - "Letzter Uploadpfad", String.class)); - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } - + + fc = new JFileChooser(Config.getString("main", "Letzter Uploadpfad", System.getProperty("user.home"))); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.showOpenDialog(getParent()); @@ -199,18 +186,7 @@ public class FTPCreateUploader_GUI extends JFrame implements contentPanel.add(btnSpeicherortAuswhlen); } lblPath = new JLabel(""); - try { - Wini ini = new Wini(new File("C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - lblPath.setText(ini.get("main", "Letzter Uploadpfad", String.class)); - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } + lblPath.setText(Config.getString("main", "Letzter Uploadpfad", System.getProperty("user.home"))); lblPath.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent arg0) { @@ -366,34 +342,17 @@ public class FTPCreateUploader_GUI extends JFrame implements finishButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { writeData(); - try { - Wini ini = new Wini( - new File( - "C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - - // check if path has content, then write to file - if (lblPath.getText().contains("\\") == true) { - System.out.println("Hole Infos aus Label: " - + lblPath.getText()); - ini.put("main", - "Letzter Uploadpfad", - lblPath.getText().substring( - 0, - lblPath.getText().lastIndexOf( - "\\"))); - ini.store(); - } else { - System.out.println("Mache nix"); - }// end if - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); + + File f = new File(lblPath.getText()); + if (f.isDirectory()) { + // shouldn't be a directory, but let's check that case anyway + Config.setString("main", "Letzter Uploadpfad", f.toString()); + } else if (f.getParentFile().isDirectory()) { + Config.setString("main", "Letzter Uploadpfad", f.getParentFile().toString()); } + // save config. + Config.store(); + dispose(); MainMenue_GUI m = new MainMenue_GUI(); m.setVisible(true); diff --git a/dozentenmodul/src/main/java/gui/image/FTPEditDownloader_GUI.java b/dozentenmodul/src/main/java/gui/image/FTPEditDownloader_GUI.java index 013c2774..2a1d75bb 100644 --- a/dozentenmodul/src/main/java/gui/image/FTPEditDownloader_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/FTPEditDownloader_GUI.java @@ -52,6 +52,7 @@ import util.OpenLinks; import ftp.DownloadTask; import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; +import config.Config; @SuppressWarnings("serial") public class FTPEditDownloader_GUI extends JFrame implements @@ -153,27 +154,9 @@ public class FTPEditDownloader_GUI extends JFrame implements btnSpeicherortAuswhlen.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { - try { - Wini ini = new Wini( - new File( - "C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - System.out.println("FileChooser Pfad: " - + ini.get("main", "Letzter Downloadpfad", - String.class)); - fc = new JFileChooser(ini.get("main", - "Letzter Downloadpfad", String.class)); - fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - - fc.showOpenDialog(getParent()); - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } + fc = new JFileChooser(Config.getString("main", "Letzter Downloadpfad", System.getProperty("user.home"))); + fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + fc.showOpenDialog(getParent()); File dir = fc.getSelectedFile(); // check if directory is selected @@ -193,19 +176,8 @@ public class FTPEditDownloader_GUI extends JFrame implements } lblPath = new JLabel(""); - try { - Wini ini = new Wini(new File("C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - lblPath.setText(ini.get("main", "Letzter Downloadpfad", - String.class)); - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } + lblPath.setText(Config.getString("main", "Letzter Downloadpfad", System.getProperty("user.home"))); + lblPath.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent arg0) { if (lblPath.getText() == null) { @@ -445,22 +417,7 @@ public class FTPEditDownloader_GUI extends JFrame implements // TODO Auto-generated catch block e1.printStackTrace(); } - try { - Wini ini = new Wini( - new File( - "C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - ini.put("main", "Letzter Downloadpfad", - lblPath.getText()); - ini.store(); - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } + // go back one page SearchEditImage_GUI se = new SearchEditImage_GUI(); se.setVisible(true); @@ -469,28 +426,20 @@ public class FTPEditDownloader_GUI extends JFrame implements } else { - try { - Wini ini = new Wini( - new File( - "C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - ini.put("main", "Letzter Downloadpfad", - lblPath.getText()); - ini.store(); - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } // go back one page SearchEditImage_GUI se = new SearchEditImage_GUI(); se.setVisible(true); dispose(); }// end else + // always save download path + File f = new File(lblPath.getText()); + if (f.isDirectory()) { + Config.setString("main", "Letzter Downloadpfad", f.toString()); + } else if (f.getParentFile().isDirectory()) { + Config.setString("main", "Letzter Downloadpfad", f.getParentFile().toString()); + } + Config.store(); } }); diff --git a/dozentenmodul/src/main/java/gui/image/FTPEditUploader_GUI.java b/dozentenmodul/src/main/java/gui/image/FTPEditUploader_GUI.java index 5d679ea5..13f036a9 100644 --- a/dozentenmodul/src/main/java/gui/image/FTPEditUploader_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/FTPEditUploader_GUI.java @@ -54,6 +54,7 @@ import util.OpenLinks; import ftp.UploadTask; import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; +import config.Config; @SuppressWarnings("serial") public class FTPEditUploader_GUI extends JFrame implements @@ -159,22 +160,7 @@ public class FTPEditUploader_GUI extends JFrame implements btnSpeicherortAuswhlen.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { - try { - Wini ini = new Wini( - new File( - "C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - fc = new JFileChooser(ini.get("main", - "Letzter Uploadpfad", String.class)); - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } - + fc = new JFileChooser(Config.getString("main", "Letzter Uploadpfad", System.getProperty("user.home"))); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.showOpenDialog(getParent()); @@ -198,18 +184,8 @@ public class FTPEditUploader_GUI extends JFrame implements } lblPath = new JLabel(""); - try { - Wini ini = new Wini(new File("C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - lblPath.setText(ini.get("main", "Letzter Uploadpfad", String.class)); - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } + lblPath.setText(Config.getString("main", "Letzter Uploadpfad", System.getProperty("user.home"))); + lblPath.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent arg0) { if (lblPath.getText().isEmpty()) { @@ -359,34 +335,14 @@ public class FTPEditUploader_GUI extends JFrame implements public void actionPerformed(ActionEvent e) { updateData(); - try { - Wini ini = new Wini( - new File( - "C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - - // check if path has content, then write to file - if (lblPath.getText().contains("\\") == true) { - System.out.println("Hole Infos aus Label: " - + lblPath.getText()); - ini.put("main", - "Letzter Uploadpfad", - lblPath.getText().substring( - 0, - lblPath.getText().lastIndexOf( - "\\"))); - ini.store(); - } else { - System.out.println("Mache nix"); - }// end if - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); + File f = new File(lblPath.getText()); + if (f.isDirectory()) { + Config.setString("main", "Letzter Downloadpfad", f.toString()); + } else if (f.getParentFile().isDirectory()) { + Config.setString("main", "Letzter Downloadpfad", f.getParentFile().toString()); } + Config.store(); + dispose(); MainMenue_GUI m = new MainMenue_GUI(); m.setVisible(true); diff --git a/dozentenmodul/src/main/java/gui/image/FTPSearchDownloader_GUI.java b/dozentenmodul/src/main/java/gui/image/FTPSearchDownloader_GUI.java index c3041e41..00ba595d 100644 --- a/dozentenmodul/src/main/java/gui/image/FTPSearchDownloader_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/FTPSearchDownloader_GUI.java @@ -51,6 +51,7 @@ import util.OpenLinks; import ftp.DownloadTask; import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; +import config.Config; @SuppressWarnings("serial") public class FTPSearchDownloader_GUI extends JFrame implements @@ -154,27 +155,9 @@ public class FTPSearchDownloader_GUI extends JFrame implements "Speicherort ausw\u00E4hlen"); btnSpeicherortAuswhlen.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { - try { - Wini ini = new Wini( - new File( - "C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - System.out.println("FileChooser Pfad: " - + ini.get("main", "Letzter Downloadpfad", - String.class)); - fc = new JFileChooser(ini.get("main", - "Letzter Downloadpfad", String.class)); - fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - - fc.showOpenDialog(getParent()); - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } + fc = new JFileChooser(Config.getString("main", "Letzter Downloadpfad", System.getProperty("user.home"))); + fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + fc.showOpenDialog(getParent()); File dir = fc.getSelectedFile(); // check if directory is selected @@ -193,20 +176,10 @@ public class FTPSearchDownloader_GUI extends JFrame implements contentPanel.add(btnSpeicherortAuswhlen); } + // read last download path from config lblPath = new JLabel(""); - try { - Wini ini = new Wini(new File("C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - lblPath.setText(ini.get("main", "Letzter Downloadpfad", - String.class)); - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } + lblPath.setText(Config.getString("main", "Letzter Downloadpfad", System.getProperty("user.home"))); + lblPath.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent arg0) { if (lblPath.getText() == null) { @@ -457,22 +430,6 @@ public class FTPSearchDownloader_GUI extends JFrame implements // TODO Auto-generated catch block e1.printStackTrace(); } - try { - Wini ini = new Wini( - new File( - "C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - ini.put("main", "Letzter Downloadpfad", - lblPath.getText()); - ini.store(); - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } // go back one page SearchImage_GUI si = new SearchImage_GUI(); si.setVisible(true); @@ -480,28 +437,14 @@ public class FTPSearchDownloader_GUI extends JFrame implements }// end choice } else { - - try { - Wini ini = new Wini( - new File( - "C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - ini.put("main", "Letzter Downloadpfad", - lblPath.getText()); - ini.store(); - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } // go back one page SearchImage_GUI si = new SearchImage_GUI(); si.setVisible(true); dispose(); }// end else + // save config in any case + Config.setString("main", "Letzter Downloadpfad", lblPath.getText()); + Config.store(); }//end action }); btnZurck.setActionCommand("Cancel"); @@ -510,22 +453,9 @@ public class FTPSearchDownloader_GUI extends JFrame implements btnMainMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { - try { - Wini ini = new Wini( - new File( - "C:\\Users\\" - + System.getProperty("user.name") - + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - ini.put("main", "Letzter Downloadpfad", - lblPath.getText()); - ini.store(); - } catch (InvalidFileFormatException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } catch (IOException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } + Config.setString("main", "Letzter Downloadpfad", lblPath.getText()); + Config.store(); + MainMenue_GUI mm = new MainMenue_GUI(); mm.setVisible(true); dispose(); |