summaryrefslogtreecommitdiffstats
path: root/Dozentenmodul
diff options
context:
space:
mode:
authorunknown2014-04-08 09:47:17 +0200
committerunknown2014-04-08 09:47:17 +0200
commit6e3f6c95b83252b9f5969524ded68f3f31e27f4a (patch)
tree3b895c21d56ef3b62882929eaae06c411a8f2435 /Dozentenmodul
parentDiverse Bugfixes und neue Grafik (diff)
downloadtutor-module-6e3f6c95b83252b9f5969524ded68f3f31e27f4a.tar.gz
tutor-module-6e3f6c95b83252b9f5969524ded68f3f31e27f4a.tar.xz
tutor-module-6e3f6c95b83252b9f5969524ded68f3f31e27f4a.zip
FTP-Upload Benutzerfreundlicher gemacht
Diffstat (limited to 'Dozentenmodul')
-rw-r--r--Dozentenmodul/src/GUI/FTPUploader_GUI.java50
-rw-r--r--Dozentenmodul/src/gui/FTPUploader_GUI.java50
2 files changed, 62 insertions, 38 deletions
diff --git a/Dozentenmodul/src/GUI/FTPUploader_GUI.java b/Dozentenmodul/src/GUI/FTPUploader_GUI.java
index eaaf9544..93ea12e7 100644
--- a/Dozentenmodul/src/GUI/FTPUploader_GUI.java
+++ b/Dozentenmodul/src/GUI/FTPUploader_GUI.java
@@ -67,6 +67,9 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
ThriftConnection thrift = new ThriftConnection();
Client client = thrift.getThriftConnection();
JButton finishButton = new JButton("Fertigstellen");
+ JButton btnUploadStarten = new JButton("Upload auf Server starten");
+ JButton btnZurck = new JButton("Zur\u00FCck");
+ int progress = 0; // progress of upload
/**
* Launch the application.
@@ -136,7 +139,7 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
fc.showOpenDialog(getParent());
File file = fc.getSelectedFile();
- //check if a file is selected and exists
+ // check if a file is selected and exists
if (file != null) {
System.out.println("File to upload exists");
uploadFile = file;
@@ -145,7 +148,7 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
} else {
System.out.println("No file selected");
lblNewLabel.setText("");
- }//end if
+ }// end if
}
});
@@ -155,11 +158,22 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
}
lblNewLabel = new JLabel("");
+ lblNewLabel.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent arg0) {
+ if (lblNewLabel.getText().isEmpty()) {
+ // wenn leer, dann upload button nicht freigeben
+ btnUploadStarten.setEnabled(false);
+ } else {
+ // wenn leer, dann upload button nicht freigeben
+ btnUploadStarten.setEnabled(true);
+ }
+ }
+ });
lblNewLabel.setHorizontalAlignment(SwingConstants.LEFT);
lblNewLabel.setBounds(285, 124, 302, 23);
contentPanel.add(lblNewLabel);
- JButton btnUploadStarten = new JButton("Upload auf Server starten");
+ btnUploadStarten.setEnabled(false);
btnUploadStarten.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
buttonUploadActionPerformed(arg0);
@@ -271,10 +285,12 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
contentPanel.add(separator_1);
JButton btnCopyFileTo = new JButton("Copy File to Prod");
+ btnCopyFileTo.setEnabled(false);
btnCopyFileTo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
- System.out.println("Copying file to "+ user.path + "/" + uploadFile.getName());
+ System.out.println("Copying file to " + user.path + "/"
+ + uploadFile.getName());
client.startFileCopy(user.path + "/" + uploadFile.getName());
} catch (TException e1) {
// TODO Auto-generated catch block
@@ -330,17 +346,6 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
}
});
- // Button for going back to Main Menu
- JButton cancelButton = new JButton("Hauptmen\u00FC");
- cancelButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- dispose();
- MainMenue_GUI m = new MainMenue_GUI();
- m.setVisible(true);
- }
- });
-
- JButton btnZurck = new JButton("Zur\u00FCck");
btnZurck.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
@@ -350,9 +355,6 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
});
btnZurck.setActionCommand("Cancel");
buttonPane.add(btnZurck);
-
- cancelButton.setActionCommand("Cancel");
- buttonPane.add(cancelButton);
finishButton.setActionCommand("Cancel");
buttonPane.add(finishButton);
}
@@ -387,6 +389,8 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
// System.out.println("OK");
// }
progressBar.setValue(0);
+ btnUploadStarten.setEnabled(false); // verhindert einen weiteren klick
+ // und
try {
user = client.getFtpUser();
@@ -420,7 +424,7 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
}
public void propertyChange(PropertyChangeEvent arg0) {
- int progress = 0;
+ progress = 0;
if ("progress" == arg0.getPropertyName()) {
progress = (Integer) arg0.getNewValue();
progressBar.setValue(progress);
@@ -428,6 +432,14 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
// Button zum Fertigstellen freischalten, wenn 100% erreicht sind
if (progress == 100) {
finishButton.setEnabled(true);
+
+ }
+ if (progress == 0 || progress == 100) {
+ // not uploading currently
+ btnZurck.setEnabled(true);
+ } else {
+ // currently uploading, don't let user interact
+ btnZurck.setEnabled(false);
}
}
diff --git a/Dozentenmodul/src/gui/FTPUploader_GUI.java b/Dozentenmodul/src/gui/FTPUploader_GUI.java
index 05cfbd34..24323cfb 100644
--- a/Dozentenmodul/src/gui/FTPUploader_GUI.java
+++ b/Dozentenmodul/src/gui/FTPUploader_GUI.java
@@ -67,6 +67,9 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
ThriftConnection thrift = new ThriftConnection();
Client client = thrift.getThriftConnection();
JButton finishButton = new JButton("Fertigstellen");
+ JButton btnUploadStarten = new JButton("Upload auf Server starten");
+ JButton btnZurck = new JButton("Zur\u00FCck");
+ int progress = 0; // progress of upload
/**
* Launch the application.
@@ -136,7 +139,7 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
fc.showOpenDialog(getParent());
File file = fc.getSelectedFile();
- //check if a file is selected and exists
+ // check if a file is selected and exists
if (file != null) {
System.out.println("File to upload exists");
uploadFile = file;
@@ -145,7 +148,7 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
} else {
System.out.println("No file selected");
lblNewLabel.setText("");
- }//end if
+ }// end if
}
});
@@ -155,11 +158,22 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
}
lblNewLabel = new JLabel("");
+ lblNewLabel.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent arg0) {
+ if (lblNewLabel.getText().isEmpty()) {
+ // wenn leer, dann upload button nicht freigeben
+ btnUploadStarten.setEnabled(false);
+ } else {
+ // wenn leer, dann upload button nicht freigeben
+ btnUploadStarten.setEnabled(true);
+ }
+ }
+ });
lblNewLabel.setHorizontalAlignment(SwingConstants.LEFT);
lblNewLabel.setBounds(285, 124, 302, 23);
contentPanel.add(lblNewLabel);
- JButton btnUploadStarten = new JButton("Upload auf Server starten");
+ btnUploadStarten.setEnabled(false);
btnUploadStarten.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
buttonUploadActionPerformed(arg0);
@@ -271,10 +285,12 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
contentPanel.add(separator_1);
JButton btnCopyFileTo = new JButton("Copy File to Prod");
+ btnCopyFileTo.setEnabled(false);
btnCopyFileTo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
- System.out.println("Copying file to "+ user.path + "/" + uploadFile.getName());
+ System.out.println("Copying file to " + user.path + "/"
+ + uploadFile.getName());
client.startFileCopy(user.path + "/" + uploadFile.getName());
} catch (TException e1) {
// TODO Auto-generated catch block
@@ -330,17 +346,6 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
}
});
- // Button for going back to Main Menu
- JButton cancelButton = new JButton("Hauptmen\u00FC");
- cancelButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- dispose();
- MainMenue_GUI m = new MainMenue_GUI();
- m.setVisible(true);
- }
- });
-
- JButton btnZurck = new JButton("Zur\u00FCck");
btnZurck.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
@@ -350,9 +355,6 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
});
btnZurck.setActionCommand("Cancel");
buttonPane.add(btnZurck);
-
- cancelButton.setActionCommand("Cancel");
- buttonPane.add(cancelButton);
finishButton.setActionCommand("Cancel");
buttonPane.add(finishButton);
}
@@ -387,6 +389,8 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
// System.out.println("OK");
// }
progressBar.setValue(0);
+ btnUploadStarten.setEnabled(false); // verhindert einen weiteren klick
+ // und
try {
user = client.getFtpUser();
@@ -420,7 +424,7 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
}
public void propertyChange(PropertyChangeEvent arg0) {
- int progress = 0;
+ progress = 0;
if ("progress" == arg0.getPropertyName()) {
progress = (Integer) arg0.getNewValue();
progressBar.setValue(progress);
@@ -428,6 +432,14 @@ public class FTPUploader_GUI extends JFrame implements PropertyChangeListener {
// Button zum Fertigstellen freischalten, wenn 100% erreicht sind
if (progress == 100) {
finishButton.setEnabled(true);
+
+ }
+ if (progress == 0 || progress == 100) {
+ // not uploading currently
+ btnZurck.setEnabled(true);
+ } else {
+ // currently uploading, don't let user interact
+ btnZurck.setEnabled(false);
}
}