-
Notifications
You must be signed in to change notification settings - Fork 0
/
GUI.java
104 lines (76 loc) · 2.5 KB
/
GUI.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GUI extends JFrame implements ActionListener, UI {
private static final long serialVersionUID = 1L;
private JTextField dvdpath, destinationpath;
private JProgressBar progress;
private JButton install, close;
final String os = System.getProperty("os.name");
public GUI() {
super("Edna bricht aus");
setDefaultCloseOperation(EXIT_ON_CLOSE);
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
JPanel paths = new JPanel(new GridLayout(2,2));
JLabel dvdlabel = new JLabel("Pfad zur DVD:");
paths.add(dvdlabel);
dvdpath = new JTextField();
if (os.equals("Mac OS X"))
dvdpath.setText("/Volumes/EDNABRICHTAUS");
else
dvdpath.setText("/mnt/cdrom");
paths.add(dvdpath);
JLabel destinationlabel = new JLabel("Installationspfad:");
paths.add(destinationlabel);
destinationpath = new JTextField(System.getProperty("user.home")+"/Edna bricht aus");
paths.add(destinationpath);
getContentPane().add(paths);
progress = new JProgressBar();
progress.setMaximum(27578); // TODO maybe we can get this from the file list?
getContentPane().add(progress);
JPanel buttonpanel = new JPanel(new FlowLayout());
install = new JButton("Installieren");
install.addActionListener(this);
buttonpanel.add(install);
close = new JButton("Beenden");
close.addActionListener(this);
buttonpanel.add(close);
getContentPane().add(buttonpanel);
setSize(500, 150);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == install) {
Unpack unpack = new Unpack(this);
unpack.start();
enableFields(false);
} else if (e.getSource() == close) {
System.exit(0);
}
}
private void enableFields(boolean enable) {
install.setEnabled(enable);
dvdpath.setEnabled(enable);
destinationpath.setEnabled(enable);
}
public static void main(String[] args) {
new GUI();
}
public synchronized void increaseProgress() {
progress.setValue(progress.getValue()+1);
}
public void showError(String text) {
JOptionPane.showMessageDialog(new JFrame(), text, "Error", JOptionPane.ERROR_MESSAGE);
enableFields(true);
}
public void showSuccess() {
JOptionPane.showMessageDialog(new JFrame(), "Installation abgeschlossen!", "Fertig", JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
public synchronized String getDVDPath() {
return dvdpath.getText();
}
public synchronized String getDestinationPath() {
return destinationpath.getText();
}
}