|
@@ -33,12 +33,12 @@ import static com.dmdirc.addons.ui_swing.SwingPreconditions.checkOnEDT;
|
33
|
33
|
|
34
|
34
|
/**
|
35
|
35
|
* Provider for {@link StandardDialog} based windows that correspond to some key.
|
36
|
|
- *
|
37
|
|
- * <p>This provider will cache instances that are created until the windows are closed. Once a
|
38
|
|
- * window has been closed, the next call to {@link #get()} or {@link #displayOrRequestFocus()} will
|
39
|
|
- * result in a new instance being created.
|
40
|
|
- *
|
41
|
|
- * <p>Dialogs with different keys may be open simultaneously, and are treated independently.
|
|
36
|
+ * <p>
|
|
37
|
+ * This provider will cache instances that are created until the windows are closed. Once a window
|
|
38
|
+ * has been closed, the next call to {@link #get()} or {@link #displayOrRequestFocus()} will result
|
|
39
|
+ * in a new instance being created.
|
|
40
|
+ * <p>
|
|
41
|
+ * Dialogs with different keys may be open simultaneously, and are treated independently.
|
42
|
42
|
*
|
43
|
43
|
* @param <K> The type of key that dialogs are associated with.
|
44
|
44
|
* @param <T> The type of dialog that will be managed.
|
|
@@ -50,13 +50,13 @@ public abstract class KeyedDialogProvider<K, T extends StandardDialog> {
|
50
|
50
|
|
51
|
51
|
/**
|
52
|
52
|
* Gets an instance of the dialog provided by this class.
|
53
|
|
- *
|
54
|
|
- * <p>If there is an existing instance with the same key that hasn't been closed, it will be
|
|
53
|
+ * <p>
|
|
54
|
+ * If there is an existing instance with the same key that hasn't been closed, it will be
|
55
|
55
|
* returned. Otherwise a new instance will be created and returned. New instances will not be
|
56
|
|
- * automatically be * displayed to the user - use
|
57
|
|
- * {@link #displayOrRequestFocus(java.lang.Object)} to do so.
|
58
|
|
- *
|
59
|
|
- * <p>This method <em>must</em> be called on the Event Despatch Thread.
|
|
56
|
+ * automatically be displayed to the user - use {@link #displayOrRequestFocus(java.lang.Object)}
|
|
57
|
+ * to do so.
|
|
58
|
+ * <p>
|
|
59
|
+ * This method <em>must</em> be called on the Event Despatch Thread.
|
60
|
60
|
*
|
61
|
61
|
* @param key The key associated with the dialog to get.
|
62
|
62
|
*
|
|
@@ -74,8 +74,8 @@ public abstract class KeyedDialogProvider<K, T extends StandardDialog> {
|
74
|
74
|
|
75
|
75
|
/**
|
76
|
76
|
* Disposes of the dialog associated with the given key, if it exists.
|
77
|
|
- *
|
78
|
|
- * <p>This method <em>must</em> be called on the Event Despatch Thread.
|
|
77
|
+ * <p>
|
|
78
|
+ * This method <em>must</em> be called on the Event Despatch Thread.
|
79
|
79
|
*
|
80
|
80
|
* @param key The key associated with the dialog to close.
|
81
|
81
|
*/
|
|
@@ -88,12 +88,12 @@ public abstract class KeyedDialogProvider<K, T extends StandardDialog> {
|
88
|
88
|
|
89
|
89
|
/**
|
90
|
90
|
* Ensures the dialog is visible to the user.
|
91
|
|
- *
|
92
|
|
- * <p>If no dialog currently exists with the same key, a new one will be created and displayed
|
93
|
|
- * to the user. If a dialog existed prior to this method being invoked, it will request focus to
|
|
91
|
+ * <p>
|
|
92
|
+ * If no dialog currently exists with the same key, a new one will be created and displayed to
|
|
93
|
+ * the user. If a dialog existed prior to this method being invoked, it will request focus to
|
94
|
94
|
* bring it to the user's attention.
|
95
|
|
- *
|
96
|
|
- * <p>This method <em>must</em> be called on the Event Despatch Thread.
|
|
95
|
+ * <p>
|
|
96
|
+ * This method <em>must</em> be called on the Event Despatch Thread.
|
97
|
97
|
*
|
98
|
98
|
* @param key The key associated with the dialog to display.
|
99
|
99
|
*/
|
|
@@ -112,19 +112,19 @@ public abstract class KeyedDialogProvider<K, T extends StandardDialog> {
|
112
|
112
|
protected abstract T getInstance(final K key);
|
113
|
113
|
|
114
|
114
|
/**
|
115
|
|
- * Listens to window closing events to remove the cached instance of the dialog.
|
|
115
|
+ * Listens to window closed events to remove the cached instance of the dialog.
|
116
|
116
|
*/
|
117
|
117
|
private class Listener extends WindowAdapter {
|
118
|
118
|
|
119
|
119
|
private final K key;
|
120
|
120
|
|
121
|
|
- public Listener(final K key) {
|
|
121
|
+ Listener(final K key) {
|
122
|
122
|
this.key = key;
|
123
|
123
|
}
|
124
|
124
|
|
125
|
125
|
@Override
|
126
|
|
- public void windowClosing(final WindowEvent e) {
|
127
|
|
- super.windowClosing(e);
|
|
126
|
+ public void windowClosed(final WindowEvent e) {
|
|
127
|
+ super.windowClosed(e);
|
128
|
128
|
instances.remove(key);
|
129
|
129
|
}
|
130
|
130
|
|