-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLgsGui.java.local
More file actions
263 lines (244 loc) · 7.56 KB
/
LgsGui.java.local
File metadata and controls
263 lines (244 loc) · 7.56 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ConnectException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.List;
import java.util.Vector;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.TransferHandler;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class LgsGui extends TransferHandler implements ActionListener {
public static void main(String[] args) {
// Schedule a job for the event-dispatching thread:
// creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
LgsGui lgsGui = new LgsGui();
lgsGui.createAndShowGUI();
} catch (RuntimeException e) {
e.printStackTrace();
}
}
});
}
private JFrame frame;
private JTextField masterDirectory;
private JComboBox masterAlbum;
private void createAndShowGUI() {
this.setLAF();
this.frame = new JFrame("lgsGUI");
this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.frame.setPreferredSize(new Dimension(600, 200));
Container contentPane = this.frame.getContentPane();
GridBagLayout gbl = new GridBagLayout();
contentPane.setLayout(gbl);
double lWeight = 0.1;
GridBagConstraints gc = new GridBagConstraints();
gc.fill = GridBagConstraints.BOTH;
gc.anchor = GridBagConstraints.WEST;
gc.insets = new Insets(1, 3, 1, 3);
gc.gridx = 0;
gc.gridy = 0;
gc.weightx = lWeight;
contentPane.add(new JLabel("master"), gc);
gc.gridx++;
JRadioButton dirRadioButton = new JRadioButton("verzeichnis", true);
dirRadioButton.setActionCommand("dir");
dirRadioButton.addActionListener(this);
contentPane.add(dirRadioButton, gc);
gc.gridx++;
gc.gridwidth = 5;
gc.weightx = 1;
this.masterDirectory = new JTextField();
this.masterDirectory.setTransferHandler(this);
contentPane.add(this.masterDirectory, gc);
gc.gridwidth = 1;
gc.gridy++;
gc.gridx = 1;
gc.weightx = lWeight;
JRadioButton dbRadioButton = new JRadioButton("db-album");
dbRadioButton.setActionCommand("db");
dbRadioButton.addActionListener(this);
contentPane.add(dbRadioButton, gc);
gc.gridx++;
gc.weightx = 1;
gc.gridwidth = 5;
this.masterAlbum = new JComboBox(this.GetAlbumInfo());
this.masterAlbum.setEnabled(false);
contentPane.add(this.masterAlbum, gc);
ButtonGroup bgroup = new ButtonGroup();
bgroup.add(dirRadioButton);
bgroup.add(dbRadioButton);
gc.gridx = 0;
gc.gridy++;
gc.gridwidth = 1;
gc.weightx = lWeight;
contentPane.add(new JLabel("slave"), gc);
gc.gridx++;
gc.weightx = 1;
gc.gridwidth = 6;
JTextField slaveDirectory = new JTextField();
slaveDirectory.setTransferHandler(this);
contentPane.add(slaveDirectory, gc);
gc.gridy++;
gc.gridx = 0;
gc.gridwidth = 1;
gc.weightx = lWeight;
contentPane.add(new JLabel("ziel"), gc);
gc.gridx++;
gc.weightx = 1;
gc.gridwidth = 6;
JTextField targetDirectory = new JTextField();
targetDirectory.setTransferHandler(this);
contentPane.add(targetDirectory, gc);
gc.gridy++;
gc.gridx = 3;
gc.gridwidth = 2;
gc.weightx = lWeight;
JButton startButton = new JButton("start");
startButton.setActionCommand("start");
startButton.addActionListener(this);
contentPane.add(startButton, gc);
gc.gridx += 2;
JButton endButton = new JButton("ende");
endButton.setActionCommand("end");
endButton.addActionListener(this);
contentPane.add(endButton, gc);
this.frame.pack();
this.frame.setVisible(true);
}
private void setLAF() {
Toolkit.getDefaultToolkit().setDynamicLayout(true);
System.setProperty("sun.awt.noerasebackground", "true");
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try {
UIManager.setLookAndFeel("de.muntjak.tinylookandfeel.TinyLookAndFeel");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private Vector<String> GetAlbumInfo() {
Vector<String> ret = new Vector<String>();
String err;
try {
// get last version info from internet
URL updateURL = new URL("http://www.lichtographie.de/lgsFuncs.php");
BufferedReader in = new BufferedReader(new InputStreamReader(updateURL.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
ret.add(inputLine);
}
// close stream
in.close();
} catch (FileNotFoundException e) {
err = "Kein Zugang zum Internet gefunden.";
// e.printStackTrace();
} catch (UnknownHostException e) {
err = "Kein Zugang zum Internet gefunden.";
// e.printStackTrace();
} catch (ConnectException e) {
err = "Kein Zugang zum Internet gefunden.";
// e.printStackTrace();
} catch (MalformedURLException e) {
err = "Kein Zugang zum Internet gefunden.";
// MyLog.exceptionError(e);
e.printStackTrace();
} catch (IOException e) {
err = "Kein Zugang zum Internet gefunden.";
// MyLog.exceptionError(e);
e.printStackTrace();
}
return ret;
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("start")) {
this.startLGS();
} else if (e.getActionCommand().equals("end")) {
this.frame.dispose();
} else if (e.getActionCommand().equals("db")) {
this.masterAlbum.setEnabled(true);
this.masterDirectory.setEnabled(false);
} else if (e.getActionCommand().equals("dir")) {
this.masterAlbum.setEnabled(false);
this.masterDirectory.setEnabled(true);
}
}
@Override
public boolean importData(JComponent comp, Transferable t) {
// Make sure we have the right starting points
if (!(comp instanceof JTextField)) {
return false;
}
if (!t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
return false;
}
// Grab the tree, its model and the root node
JTextField textField = (JTextField) comp;
try {
List data = (List) t.getTransferData(DataFlavor.javaFileListFlavor);
for (Object object : data) {
File f = (File) object;
textField.setText(f.getAbsolutePath());
}
return true;
} catch (UnsupportedFlavorException ufe) {
System.err.println("Ack! we should not be here.\nBad Flavor.");
} catch (IOException ioe) {
System.out.println("Something failed during import:\n" + ioe);
}
return false;
}
@Override
public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
if (comp instanceof JTextField) {
for (DataFlavor transferFlavor : transferFlavors) {
if (transferFlavor.equals(DataFlavor.javaFileListFlavor)) {
return true;
}
}
return false;
}
return false;
}
private void startLGS() {
// TODO Auto-generated method stub
}
}