diff options
| -rw-r--r-- | Dozentenmodul/bin/ftp/UploadTask.class | bin | 3842 -> 3838 bytes | |||
| -rw-r--r-- | Dozentenmodul/bin/gui/image/FTPCreateUploader_GUI.class | bin | 14732 -> 14663 bytes | |||
| -rw-r--r-- | Dozentenmodul/bin/gui/image/FTPEditUploader_GUI.class | bin | 14312 -> 14213 bytes | |||
| -rw-r--r-- | Dozentenmodul/bin/gui/image/SearchImage_GUI.class | bin | 16760 -> 16757 bytes | |||
| -rw-r--r-- | Dozentenmodul/src/gui/image/FTPCreateUploader_GUI.java | 64 | ||||
| -rw-r--r-- | Dozentenmodul/src/gui/image/FTPEditDownloader_GUI.java | 153 | ||||
| -rw-r--r-- | Dozentenmodul/src/gui/image/FTPEditUploader_GUI.java | 105 | ||||
| -rw-r--r-- | Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java | 152 |
8 files changed, 267 insertions, 207 deletions
diff --git a/Dozentenmodul/bin/ftp/UploadTask.class b/Dozentenmodul/bin/ftp/UploadTask.class Binary files differindex 14019ffd..dd120af3 100644 --- a/Dozentenmodul/bin/ftp/UploadTask.class +++ b/Dozentenmodul/bin/ftp/UploadTask.class diff --git a/Dozentenmodul/bin/gui/image/FTPCreateUploader_GUI.class b/Dozentenmodul/bin/gui/image/FTPCreateUploader_GUI.class Binary files differindex 0c76818d..230c7fb1 100644 --- a/Dozentenmodul/bin/gui/image/FTPCreateUploader_GUI.class +++ b/Dozentenmodul/bin/gui/image/FTPCreateUploader_GUI.class diff --git a/Dozentenmodul/bin/gui/image/FTPEditUploader_GUI.class b/Dozentenmodul/bin/gui/image/FTPEditUploader_GUI.class Binary files differindex 0e5c8340..f15b74e6 100644 --- a/Dozentenmodul/bin/gui/image/FTPEditUploader_GUI.class +++ b/Dozentenmodul/bin/gui/image/FTPEditUploader_GUI.class diff --git a/Dozentenmodul/bin/gui/image/SearchImage_GUI.class b/Dozentenmodul/bin/gui/image/SearchImage_GUI.class Binary files differindex 8173d4ba..d59c5e1b 100644 --- a/Dozentenmodul/bin/gui/image/SearchImage_GUI.class +++ b/Dozentenmodul/bin/gui/image/SearchImage_GUI.class diff --git a/Dozentenmodul/src/gui/image/FTPCreateUploader_GUI.java b/Dozentenmodul/src/gui/image/FTPCreateUploader_GUI.java index a0d679fb..9e5b7db8 100644 --- a/Dozentenmodul/src/gui/image/FTPCreateUploader_GUI.java +++ b/Dozentenmodul/src/gui/image/FTPCreateUploader_GUI.java @@ -87,7 +87,8 @@ public class FTPCreateUploader_GUI extends JFrame implements JButton btnUploadStarten = new JButton("Upload auf Server starten"); JButton btnZurck = new JButton("Zur\u00FCck"); int progress = 0; // progress of upload - private boolean isCurrentlyLoading = false; // currently up or downloading file + private boolean isCurrentlyLoading = false; // currently up or downloading + // file /** * Create the frame. @@ -166,7 +167,8 @@ public class FTPCreateUploader_GUI extends JFrame implements "C:\\Users\\" + System.getProperty("user.name") + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - fc = new JFileChooser(ini.get("main", "Letzter Uploadpfad",String.class)); + fc = new JFileChooser(ini.get("main", + "Letzter Uploadpfad", String.class)); } catch (InvalidFileFormatException e2) { // TODO Auto-generated catch block e2.printStackTrace(); @@ -174,7 +176,7 @@ public class FTPCreateUploader_GUI extends JFrame implements // TODO Auto-generated catch block e2.printStackTrace(); } - + fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.showOpenDialog(getParent()); @@ -216,8 +218,8 @@ public class FTPCreateUploader_GUI extends JFrame implements // wenn leer, dann upload button nicht freigeben btnUploadStarten.setEnabled(false); btnUploadStarten.setText("Bitte warten"); - } else { - // wenn leer, dann upload button nicht freigeben + } else if (lblPath.getText().endsWith(".vmdk")) { + // wenn leer, dann upload button freigeben btnUploadStarten.setEnabled(true); btnUploadStarten.setText("Upload auf Server starten"); } @@ -431,18 +433,16 @@ public class FTPCreateUploader_GUI extends JFrame implements task.cancel(true); // not loading files, go back one page dispose(); - PermissionCreateImage_GUI m = new PermissionCreateImage_GUI(); m.setVisible(true); - } + }// end if choice } else { dispose(); - PermissionCreateImage_GUI m = new PermissionCreateImage_GUI(); m.setVisible(true); - } - } + }// end else + }// end action }); btnZurck.setActionCommand("Cancel"); buttonPane.add(btnZurck); @@ -461,20 +461,15 @@ public class FTPCreateUploader_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(); } - } }); @@ -484,20 +479,15 @@ public class FTPCreateUploader_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(); } - } }); menu.add(menuItem_1); @@ -560,25 +550,14 @@ public class FTPCreateUploader_GUI extends JFrame implements 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); - } - - // Fertigstellen erlauben wenn upload abgeschlossen - if (progress == 100) { - isCurrentlyLoading(); - finishButton.setEnabled(true); - - } else { - finishButton.setEnabled(false); - - } + } + // Fertigstellen erlauben wenn upload abgeschlossen + if (isCurrentlyLoading() == false) { + // isCurrentlyLoading(); + finishButton.setEnabled(true); + } else { + finishButton.setEnabled(false); } if ("speed" == arg0.getPropertyName()) { @@ -636,9 +615,8 @@ public class FTPCreateUploader_GUI extends JFrame implements Image.image.isVorlage(), Image.image.getFilesize(), Image.image.getShareMode(), Image.image.getOS()); - client.startFileCopy(Image.image.getNewName()); + client.startFileCopy(Image.image.getNewName()); - client.writeImageRights(Image.image.getImagename(), person.verantwortlicher.getUsername(), person.verantwortlicher.getName(), @@ -661,13 +639,13 @@ public class FTPCreateUploader_GUI extends JFrame implements 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); + return isCurrentlyLoading; }// end isCurrentlyLoading() -}// end class +}// end class
\ No newline at end of file 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 diff --git a/Dozentenmodul/src/gui/image/FTPEditUploader_GUI.java b/Dozentenmodul/src/gui/image/FTPEditUploader_GUI.java index 12a5d6bb..a58001a8 100644 --- a/Dozentenmodul/src/gui/image/FTPEditUploader_GUI.java +++ b/Dozentenmodul/src/gui/image/FTPEditUploader_GUI.java @@ -88,7 +88,8 @@ public class FTPEditUploader_GUI extends JFrame implements JButton btnSpeicherortAuswhlen = new JButton("Image ausw\u00E4hlen"); JButton finishButton = new JButton("Fertigstellen"); JButton btnZurck = new JButton("Zur\u00FCck"); - private boolean isCurrentlyLoading = false; // currently up or downloading file + private boolean isCurrentlyLoading = false; // currently up or downloading + // file /** * Create the frame. @@ -100,6 +101,7 @@ public class FTPEditUploader_GUI extends JFrame implements addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent arg0) { + if (taskrun == true) { // check if user wants to quit. int choice = JOptionPane @@ -112,9 +114,7 @@ public class FTPEditUploader_GUI extends JFrame implements options, options[1]); // 0=beenden, 1=abbrechen if (choice == 0) { - try { - client.DeleteFtpUser(user.userName); } catch (TException e1) { // TODO Auto-generated catch block @@ -124,8 +124,8 @@ public class FTPEditUploader_GUI extends JFrame implements con.closeThriftConnection(); System.exit(0); }// end if choice - }else { - //no upload running, close window + } else { + // no upload running, close window System.exit(0); }// end if taskrun }// end window closing @@ -164,7 +164,8 @@ public class FTPEditUploader_GUI extends JFrame implements "C:\\Users\\" + System.getProperty("user.name") + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - fc = new JFileChooser(ini.get("main", "Letzter Uploadpfad",String.class)); + fc = new JFileChooser(ini.get("main", + "Letzter Uploadpfad", String.class)); } catch (InvalidFileFormatException e2) { // TODO Auto-generated catch block e2.printStackTrace(); @@ -172,7 +173,7 @@ public class FTPEditUploader_GUI extends JFrame implements // TODO Auto-generated catch block e2.printStackTrace(); } - + fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.showOpenDialog(getParent()); @@ -197,12 +198,10 @@ 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)); + 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(); @@ -216,8 +215,8 @@ public class FTPEditUploader_GUI extends JFrame implements // wenn leer, dann upload button nicht freigeben btnUploadStarten.setEnabled(false); btnUploadStarten.setText("Bitte warten"); - } else { - // wenn leer, dann upload button nicht freigeben + } else if (lblPath.getText().endsWith(".vmdk")) { + // wenn leer, dann upload button freigeben btnUploadStarten.setEnabled(true); btnUploadStarten.setText("Upload auf Server starten"); } @@ -365,7 +364,13 @@ public class FTPEditUploader_GUI extends JFrame implements "C:\\Users\\" + System.getProperty("user.name") + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini")); - ini.put("main", "Letzter Uploadpfad", lblPath.getText().substring(0, lblPath.getText().lastIndexOf("\\"))); + ini.put("main", + "Letzter Uploadpfad", + lblPath.getText() + .substring( + 0, + lblPath.getText() + .lastIndexOf("\\"))); ini.store(); } catch (InvalidFileFormatException e2) { // TODO Auto-generated catch block @@ -399,12 +404,38 @@ public class FTPEditUploader_GUI extends JFrame implements }); btnZurck.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { - - // - dispose(); - PermissionEditImage_GUI ei = new PermissionEditImage_GUI(); - ei.setVisible(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) { + try { + client.DeleteFtpUser(user.userName); + } catch (TException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + task.cancel(true); + // not loading files, go back one page + dispose(); + PermissionEditImage_GUI ei = new PermissionEditImage_GUI(); + ei.setVisible(true); + + }// end if coice + } else { + dispose(); + PermissionEditImage_GUI ei = new PermissionEditImage_GUI(); + ei.setVisible(true); + }// end else + }// end action }); btnZurck.setActionCommand("Cancel"); @@ -516,25 +547,17 @@ public class FTPEditUploader_GUI extends JFrame implements } public void propertyChange(PropertyChangeEvent arg0) { + // set progressbar if ("progress" == arg0.getPropertyName()) { progress = (Integer) arg0.getNewValue(); progressBar.setValue(progress); + } - // Button zum Fertigstellen freischalten, wenn 100% erreicht sind - if (progress == 100) { - // not uploading currently - btnZurck.setEnabled(true); - } else { - // currently uploading, don't let user interact - btnZurck.setEnabled(false); - } - - // Fertigstellen erlauben wenn upload abgeschlossen - if (progress == 100) { - finishButton.setEnabled(true); - } else { - finishButton.setEnabled(false); - } + // Fertigstellen erlauben wenn upload abgeschlossen + if (isCurrentlyLoading() == true) { + finishButton.setEnabled(false); + } else { + finishButton.setEnabled(true); } if ("speed" == arg0.getPropertyName()) { @@ -611,16 +634,16 @@ public class FTPEditUploader_GUI extends JFrame implements return true; } - + 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); return isCurrentlyLoading; }// end isCurrentlyLoading() -}
\ No newline at end of file + +}// end class
\ No newline at end of file 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 |
