blob: a150235653292de2cf94769c262d2f21b67478f1 (
plain) (
blame)
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
|
package org.openslx.dozmod.gui.window;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.apache.log4j.Logger;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.helper.MessageType;
import org.openslx.dozmod.gui.helper.UiFeedback;
import org.openslx.dozmod.gui.window.layout.VmxEditorWindowLayout;
@SuppressWarnings("serial")
public class VmxEditorWindow extends VmxEditorWindowLayout implements UiFeedback {
private final static Logger LOGGER = Logger.getLogger(VmxEditorWindow.class);
public interface VmxChangedCallback {
public void vmxChanged(String newVmx);
}
private final String originalVmx;
private final VmxEditorWindow me = this;
protected VmxEditorWindow(Window modalParent, final VmxChangedCallback cb, String vmx) {
super(modalParent, vmx);
originalVmx = vmx;
btnSave.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO callback to the main window to save the contents
cb.vmxChanged(pnlEditor.getText());
}
});
btnCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String newData = pnlEditor.getText();
if (newData == null) {
LOGGER.debug("Error while getting the text from the editor...");
return;
}
if (originalVmx != pnlEditor.getText()) {
if (Gui.showMessageBox(me, "Ihre Änderungen werden verloren gehen, wollen Sie trotzdem fortfahren?", MessageType.QUESTION_YESNO,
LOGGER, null))
dispose();
}
}
});
}
public static void open(Window modalParent, final VmxChangedCallback cb, String vmx) {
VmxEditorWindow win = new VmxEditorWindow(modalParent, cb, vmx);
win.setVisible(true);
}
@Override
public boolean wantConfirmQuit() {
return false;
}
@Override
public void escapePressed() {
dispose();
}
}
|