diff options
Diffstat (limited to 'Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java')
| -rw-r--r-- | Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java | 152 |
1 files changed, 99 insertions, 53 deletions
diff --git a/Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java b/Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java index e75fa8b9..c3041e41 100644 --- a/Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java +++ b/Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java @@ -84,6 +84,8 @@ public class FTPSearchDownloader_GUI extends JFrame implements JButton btnDownloadStarten = new JButton("Download starten"); JButton btnMainMenu = new JButton("Hauptmen\u00FC"); private JLabel lblAnleitung; + private boolean isCurrentlyLoading = false; // currently up or downloading + // file /** * Create the frame. @@ -119,8 +121,8 @@ public class FTPSearchDownloader_GUI extends JFrame implements System.exit(0); }// end if choice - }else { - //no download running, close window + } else { + // no download running, close window System.exit(0); }// end if taskrun }// end window closing @@ -158,8 +160,11 @@ public class FTPSearchDownloader_GUI extends JFrame implements "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)); + 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()); @@ -190,12 +195,11 @@ public class FTPSearchDownloader_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)); + 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(); @@ -434,40 +438,71 @@ public class FTPSearchDownloader_GUI extends JFrame implements { btnZurck.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - if (taskrun == true) { - task.cancel(true); + // check if loading file or not + if (isCurrentlyLoading() == true) { + int choice = JOptionPane + .showOptionDialog( + null, + "Nicht abgeschlossene Uploads werden beendet. Trotzdem zurück gehen?", + "Warnung", + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE, null, + options, options[1]); + // 0=beenden, 1=abbrechen + if (choice == 0) { + task.cancel(true); + try { + client.DeleteFtpUser(user.userName); + } catch (TException e1) { + // 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); + dispose(); + }// end choice + + } else { + try { - client.DeleteFtpUser(user.userName); - } catch (TException e1) { + 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 - e1.printStackTrace(); - JOptionPane.showMessageDialog( - null, - e1.getCause() + "\n" - + e1.getStackTrace(), - "Debug-Message", - JOptionPane.ERROR_MESSAGE); + e2.printStackTrace(); + } catch (IOException e2) { + // TODO Auto-generated catch block + e2.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(); - } - SearchImage_GUI se = new SearchImage_GUI(); - se.setVisible(true); - dispose(); - } + // go back one page + SearchImage_GUI si = new SearchImage_GUI(); + si.setVisible(true); + dispose(); + }// end else + }//end action }); btnZurck.setActionCommand("Cancel"); buttonPane.add(btnZurck); @@ -481,7 +516,8 @@ public class FTPSearchDownloader_GUI extends JFrame implements "C:\\Users\\" + System.getProperty("user.name") + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - ini.put("main", "Letzter Downloadpfad", lblPath.getText()); + ini.put("main", "Letzter Downloadpfad", + lblPath.getText()); ini.store(); } catch (InvalidFileFormatException e2) { // TODO Auto-generated catch block @@ -538,17 +574,15 @@ public class FTPSearchDownloader_GUI extends JFrame implements if ("progress" == arg0.getPropertyName()) { progress = (Integer) arg0.getNewValue(); progressBar.setValue(progress); + } - // Button zum Fertigstellen freischalten, wenn 100% erreicht sind - if (progress == 0 || progress == 100) { - // not uploading currently - btnZurck.setEnabled(true); - btnMainMenu.setEnabled(true); - } else { - // currently uploading, don't let user interact - btnZurck.setEnabled(false); - btnMainMenu.setEnabled(false); - } + // Button zum Fertigstellen freischalten, wenn 100% erreicht sind + if (isCurrentlyLoading() == true) { + // not uploading currently + btnMainMenu.setEnabled(false); + } else { + // currently uploading, don't let user interact + btnMainMenu.setEnabled(true); } if ("speed" == arg0.getPropertyName()) { @@ -586,4 +620,16 @@ public class FTPSearchDownloader_GUI extends JFrame implements } } -}
\ No newline at end of file + + public boolean isCurrentlyLoading() { + isCurrentlyLoading = false; + + if (labelVerbleibend.getText().equals("0 MB") || labelVerbleibend.getText().equals("0")) { + isCurrentlyLoading = false; + } else { + isCurrentlyLoading = true; + } + return isCurrentlyLoading; + }// end isCurrentlyLoading() + +}// end class
\ No newline at end of file |
