summaryrefslogtreecommitdiffstats
path: root/Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java
diff options
context:
space:
mode:
authorMichael Wilson2014-08-25 13:35:56 +0200
committerMichael Wilson2014-08-25 13:35:56 +0200
commitb06e2710fa3461302773ab5f1cad959d5e5cad57 (patch)
tree8828cf947667b19c6e47af1cce7c3e04bbe8f158 /Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java
parentAnleitung zur Nutzung einer VMDK hinzugefügt (diff)
downloadtutor-module-b06e2710fa3461302773ab5f1cad959d5e5cad57.tar.gz
tutor-module-b06e2710fa3461302773ab5f1cad959d5e5cad57.tar.xz
tutor-module-b06e2710fa3461302773ab5f1cad959d5e5cad57.zip
Abfrage bei Schließen währen Up-Download
Diffstat (limited to 'Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java')
-rw-r--r--Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java126
1 files changed, 74 insertions, 52 deletions
diff --git a/Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java b/Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java
index ca3ac268..66f0890a 100644
--- a/Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java
+++ b/Dozentenmodul/src/gui/image/FTPSearchDownloader_GUI.java
@@ -50,7 +50,8 @@ import gui.intro.About_GUI;
import gui.intro.MainMenue_GUI;
@SuppressWarnings("serial")
-public class FTPSearchDownloader_GUI extends JFrame implements PropertyChangeListener {
+public class FTPSearchDownloader_GUI extends JFrame implements
+ PropertyChangeListener {
@SuppressWarnings("unused")
private JPanel contentPane;
@@ -80,33 +81,47 @@ public class FTPSearchDownloader_GUI extends JFrame implements PropertyChangeLis
JButton btnMainMenu = new JButton("Hauptmen\u00FC");
private JLabel lblAnleitung;
-
/**
* Create the frame.
*/
public FTPSearchDownloader_GUI() {
+
+ final Object[] options = { "Beenden", "Abbrechen" };
+
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
if (taskrun == true) {
- try {
- client.DeleteFtpUser(user.userName);
- con.closeThriftConnection();
- } catch (TException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- JOptionPane.showMessageDialog(null,
- e1.getCause()+"\n"+e1.getStackTrace(),
- "Debug-Message", JOptionPane.ERROR_MESSAGE);
- }
- task.cancel(true);
- }
- //dispose();
- System.exit(0);
- }//end window closing
+ // check if user wants to quit.
+ int choice = JOptionPane
+ .showOptionDialog(
+ null,
+ "Aktuell ist ein Download aktiv. Wollen Sie diesen Abbrechen und das Programm beenden?",
+ "Upload aktiv",
+ JOptionPane.YES_NO_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE, null,
+ options, options[1]);
+ // 0=beenden, 1=abbrechen
+ if (choice == 0) {
+
+ try {
+ client.DeleteFtpUser(user.userName);
+ con.closeThriftConnection();
+ } catch (TException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ JOptionPane.showMessageDialog(null, e1.getCause()
+ + "\n" + e1.getStackTrace(),
+ "Debug-Message", JOptionPane.ERROR_MESSAGE);
+ }
+ task.cancel(true);
+
+ System.exit(0);
+ }// end if choice
+ }// end if taskrun
+ }// end window closing
});
setResizable(false);
- // setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
@@ -118,10 +133,11 @@ public class FTPSearchDownloader_GUI extends JFrame implements PropertyChangeLis
setBackground(Color.WHITE);
setTitle("Dozentenmodul - Image herunterladen");
-
+ // Aktion die beim Schliessen durchgefuehrt werden soll
+ setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
setBounds(0, 0, 603, 722);
GuiOrganizer.centerGUI(this);
-
+
getContentPane().setLayout(new BorderLayout());
contentPanel.setBackground(SystemColor.menu);
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
@@ -240,7 +256,8 @@ public class FTPSearchDownloader_GUI extends JFrame implements PropertyChangeLis
panel.add(lblImageDownloader);
JTextPane txtpnWhlenSieEinen = new JTextPane();
- txtpnWhlenSieEinen.setText("W\u00E4hlen Sie einen Ort aus, um das von Ihnen gw\u00E4hlte Image erunter zu laden.");
+ txtpnWhlenSieEinen
+ .setText("W\u00E4hlen Sie einen Ort aus, um das von Ihnen gw\u00E4hlte Image erunter zu laden.");
txtpnWhlenSieEinen.setEditable(false);
txtpnWhlenSieEinen.setBackground(SystemColor.menu);
txtpnWhlenSieEinen.setBounds(10, 36, 509, 32);
@@ -292,60 +309,60 @@ public class FTPSearchDownloader_GUI extends JFrame implements PropertyChangeLis
"Klicken Sie auf \"Fertigstellen\".");
lblKlickenSieAuf.setBounds(102, 423, 241, 14);
contentPanel.add(lblKlickenSieAuf);
-
+
JMenuBar menuBar = new JMenuBar();
menuBar.setBounds(0, 0, 597, 21);
contentPanel.add(menuBar);
-
+
JMenu menu = new JMenu("Hilfe");
menuBar.add(menu);
-
+
JMenuItem menuItem = new JMenuItem("FAQ");
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();
}
-
+
}
});
menu.add(menuItem);
-
+
JMenuItem menuItem_1 = new JMenuItem("OTRS");
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);
-
+
JMenuItem mntmAbout = new JMenuItem("About");
mntmAbout.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@@ -354,17 +371,18 @@ public class FTPSearchDownloader_GUI extends JFrame implements PropertyChangeLis
}
});
menu.add(mntmAbout);
-
- lblAnleitung = new JLabel("<HTML><U>Anleitung zum erstellen einer virtuellen Maschine herunterladen</U></HTML>");
+
+ lblAnleitung = new JLabel(
+ "<HTML><U>Anleitung zum erstellen einer virtuellen Maschine herunterladen</U></HTML>");
lblAnleitung.setForeground(Color.BLUE);
lblAnleitung.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
OpenLinks open = new OpenLinks();
-
+
URI anleitung;
try {
- anleitung = new URI(Links.getAnleitungVMDK());
+ anleitung = new URI(Links.getAnleitungVMDK());
open.openWebpage(anleitung);
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
@@ -374,7 +392,7 @@ public class FTPSearchDownloader_GUI extends JFrame implements PropertyChangeLis
});
lblAnleitung.setBounds(102, 448, 311, 14);
contentPanel.add(lblAnleitung);
-
+
{
JPanel buttonPane = new JPanel();
buttonPane.setBackground(UIManager.getColor("Button.background"));
@@ -390,12 +408,15 @@ public class FTPSearchDownloader_GUI extends JFrame implements PropertyChangeLis
} catch (TException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
- JOptionPane.showMessageDialog(null,
- e1.getCause()+"\n"+e1.getStackTrace(),
- "Debug-Message", JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showMessageDialog(
+ null,
+ e1.getCause() + "\n"
+ + e1.getStackTrace(),
+ "Debug-Message",
+ JOptionPane.ERROR_MESSAGE);
}
}
-
+
SearchImage_GUI se = new SearchImage_GUI();
se.setVisible(true);
dispose();
@@ -404,11 +425,10 @@ public class FTPSearchDownloader_GUI extends JFrame implements PropertyChangeLis
btnZurck.setActionCommand("Cancel");
buttonPane.add(btnZurck);
}
-
-
+
btnMainMenu.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
-
+
MainMenue_GUI mm = new MainMenue_GUI();
mm.setVisible(true);
dispose();
@@ -430,15 +450,17 @@ public class FTPSearchDownloader_GUI extends JFrame implements PropertyChangeLis
try {
user = client.getFtpUser();
- downloadFile = user.path+"/"+client.getPathOfImage(Image.image.getImageId(),
- Image.image.getVersion());
+ downloadFile = user.path
+ + "/"
+ + client.getPathOfImage(Image.image.getImageId(),
+ Image.image.getVersion());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
JOptionPane.showMessageDialog(null,
- e.getCause()+"\n"+e.getStackTrace(),
- "Debug-Message", JOptionPane.ERROR_MESSAGE);
+ e.getCause() + "\n" + e.getStackTrace(), "Debug-Message",
+ JOptionPane.ERROR_MESSAGE);
}
task = new DownloadTask(host, port, user.userName, user.password,
@@ -455,7 +477,7 @@ public class FTPSearchDownloader_GUI extends JFrame implements PropertyChangeLis
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