7
7
import ca .odell .glazedlists .EventList ;
8
8
import ca .odell .glazedlists .swing .DefaultEventListModel ;
9
9
import ca .odell .glazedlists .swing .GlazedListsSwing ;
10
+ import mediathek .tool .ApplicationConfiguration ;
10
11
import mediathek .tool .SVGIconUtilities ;
12
+ import org .apache .commons .configuration2 .sync .LockMode ;
11
13
12
14
import javax .swing .*;
13
15
import javax .swing .border .EmptyBorder ;
20
22
* @author christianfranzke
21
23
*/
22
24
public class EditHistoryDialog extends JDialog {
25
+ private static final String CONFIG_X = "edit_history.x" ;
26
+ private static final String CONFIG_Y = "edit_history.y" ;
27
+ private static final String CONFIG_HEIGHT = "edit_history.height" ;
28
+ private static final String CONFIG_WIDTH = "edit_history.width" ;
29
+
23
30
public EditHistoryDialog (Window owner , JMenuItem menuItem , EventList <String > eventList ) {
24
31
super (owner );
25
32
initComponents ();
@@ -29,6 +36,7 @@ public EditHistoryDialog(Window owner, JMenuItem menuItem, EventList<String> eve
29
36
@ Override
30
37
public void windowClosed (WindowEvent e ) {
31
38
menuItem .setEnabled (true );
39
+ savePosition ();
32
40
}
33
41
});
34
42
@@ -38,7 +46,6 @@ public void windowClosed(WindowEvent e) {
38
46
if (l .getValueIsAdjusting ())
39
47
return ;
40
48
adjustDeleteButton ();
41
-
42
49
});
43
50
adjustDeleteButton ();
44
51
@@ -50,6 +57,41 @@ public void windowClosed(WindowEvent e) {
50
57
changeList .forEach (eventList ::remove );
51
58
changeList .clear ();
52
59
});
60
+
61
+ restorePosition ();
62
+ }
63
+
64
+ private void restorePosition () {
65
+ var config = ApplicationConfiguration .getConfiguration ();
66
+ try {
67
+ config .lock (LockMode .READ );
68
+ int x = config .getInt (CONFIG_X );
69
+ int y = config .getInt (CONFIG_Y );
70
+ int width = config .getInt (CONFIG_WIDTH );
71
+ int height = config .getInt (CONFIG_HEIGHT );
72
+
73
+ setSize (width , height );
74
+ setLocation (x , y );
75
+ } catch (Exception ignored ) {
76
+ System .out .println ("COULD NOT FIND CONFIGURATION" );
77
+ } finally {
78
+ config .unlock (LockMode .READ );
79
+ }
80
+ }
81
+
82
+ private void savePosition () {
83
+ var config = ApplicationConfiguration .getConfiguration ();
84
+ try {
85
+ config .lock (LockMode .WRITE );
86
+ var size = getSize ();
87
+ var location = getLocation ();
88
+ config .setProperty (CONFIG_WIDTH , size .width );
89
+ config .setProperty (CONFIG_HEIGHT , size .height );
90
+ config .setProperty (CONFIG_X , location .x );
91
+ config .setProperty (CONFIG_Y , location .y );
92
+ } finally {
93
+ config .unlock (LockMode .WRITE );
94
+ }
53
95
}
54
96
55
97
private void adjustDeleteButton () {
0 commit comments