diff options
| author | Michael Wilson | 2014-08-26 09:32:59 +0200 |
|---|---|---|
| committer | Michael Wilson | 2014-08-26 09:32:59 +0200 |
| commit | 544a8b733317fdc4e59ce5330c2d4c8cc4ffbba5 (patch) | |
| tree | 3f765602d233ed8b7b85f0799058e386c6be399c /Dozentenmodul/src/gui/image/FTPEditDownloader_GUI.java | |
| parent | download prüft jetzt auf label.text == null (diff) | |
| download | tutor-module-544a8b733317fdc4e59ce5330c2d4c8cc4ffbba5.tar.gz tutor-module-544a8b733317fdc4e59ce5330c2d4c8cc4ffbba5.tar.xz tutor-module-544a8b733317fdc4e59ce5330c2d4c8cc4ffbba5.zip | |
Alle Abfragen und Abbrüche für während Up/Downloads implementiert
Diffstat (limited to 'Dozentenmodul/src/gui/image/FTPEditDownloader_GUI.java')
| -rw-r--r-- | Dozentenmodul/src/gui/image/FTPEditDownloader_GUI.java | 153 |
1 files changed, 83 insertions, 70 deletions
diff --git a/Dozentenmodul/src/gui/image/FTPEditDownloader_GUI.java b/Dozentenmodul/src/gui/image/FTPEditDownloader_GUI.java index 18df360e..013c2774 100644 --- a/Dozentenmodul/src/gui/image/FTPEditDownloader_GUI.java +++ b/Dozentenmodul/src/gui/image/FTPEditDownloader_GUI.java @@ -84,7 +84,8 @@ public class FTPEditDownloader_GUI extends JFrame implements JButton btnZurck = new JButton("Zur\u00FCck"); JButton btnDownloadStarten = new JButton("Download starten"); private JLabel lblAnleitung; - private boolean isCurrentlyLoading = false; // currently up or downloading file + private boolean isCurrentlyLoading = false; // currently up or downloading + // file /** * Create the frame. @@ -108,7 +109,6 @@ public class FTPEditDownloader_GUI extends JFrame implements options, options[1]); // 0=beenden, 1=abbrechen if (choice == 0) { - try { client.DeleteFtpUser(user.userName); con.closeThriftConnection(); @@ -119,9 +119,8 @@ public class FTPEditDownloader_GUI extends JFrame implements task.cancel(true); System.exit(0); }// end if coice - - }else { - //no download running, close window + } else { + // no download running, close window System.exit(0); }// end if taskrun }// end window closing @@ -160,8 +159,11 @@ public class FTPEditDownloader_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()); @@ -192,12 +194,11 @@ 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)); + 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(); @@ -212,7 +213,7 @@ public class FTPEditDownloader_GUI extends JFrame implements btnDownloadStarten.setEnabled(false); btnDownloadStarten.setText("Bitte warten"); } else { - // wenn leer, dann upload button nicht freigeben + // wenn leer, dann upload button freigeben btnDownloadStarten.setEnabled(true); btnDownloadStarten.setText("Download starten"); } @@ -356,20 +357,15 @@ public class FTPEditDownloader_GUI extends JFrame implements menuItem.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent arg0) { - OpenLinks open = new OpenLinks(); - URI windows; try { windows = new URI(Links.getFAQ()); - open.openWebpage(windows); - } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } - } }); @@ -379,20 +375,15 @@ public class FTPEditDownloader_GUI extends JFrame implements menuItem_1.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent arg0) { - OpenLinks open = new OpenLinks(); - URI windows; try { windows = new URI(Links.getOTRS()); - open.openWebpage(windows); - } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } - } }); @@ -435,39 +426,72 @@ public class FTPEditDownloader_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 + SearchEditImage_GUI se = new SearchEditImage_GUI(); + se.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(); - } - SearchEditImage_GUI se = new SearchEditImage_GUI(); - se.setVisible(true); - dispose(); + // go back one page + SearchEditImage_GUI se = new SearchEditImage_GUI(); + se.setVisible(true); + dispose(); + + }// end else + } }); btnZurck.setActionCommand("Cancel"); @@ -514,22 +538,10 @@ public class FTPEditDownloader_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); - - } else { - // currently uploading, don't let user interact - btnZurck.setEnabled(false); - - } } if ("speed" == arg0.getPropertyName()) { speed = (double) arg0.getNewValue(); - // if(speed<=1){ downspeed.setText(String.valueOf(speed).substring(0, String.valueOf(speed).lastIndexOf(".") + 3) @@ -561,17 +573,18 @@ public class FTPEditDownloader_GUI extends JFrame implements } - }//end PropertyChange() - + }// end PropertyChange() + public boolean isCurrentlyLoading() { isCurrentlyLoading = false; - if (labelVerbleibend.getText().equals("0")) { + if (labelVerbleibend.getText().equals("0 MB") || labelVerbleibend.getText().equals("0")) { isCurrentlyLoading = false; } else { isCurrentlyLoading = true; } - System.out.println("isCurrentlyLoading"+isCurrentlyLoading); + System.out.println("isCurrentlyLoading="+isCurrentlyLoading); return isCurrentlyLoading; }// end isCurrentlyLoading() + }// end class |
