1
|
=== modified file 'src/com/goldencode/p2j/ui/client/WindowManager.java'
|
2
|
--- src/com/goldencode/p2j/ui/client/WindowManager.java 2015-10-16 12:11:54 +0000
|
3
|
+++ src/com/goldencode/p2j/ui/client/WindowManager.java 2015-11-03 14:07:35 +0000
|
4
|
@@ -310,7 +310,7 @@
|
5
|
w.hide();
|
6
|
if (w instanceof Window)
|
7
|
{
|
8
|
- removeWindow(w.getId().asInt());
|
9
|
+ remove(w);
|
10
|
}
|
11
|
else
|
12
|
{
|
13
|
|
14
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java'
|
15
|
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java 2015-10-24 19:51:34 +0000
|
16
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java 2015-11-03 15:39:09 +0000
|
17
|
@@ -73,6 +73,7 @@
|
18
|
** operations. Removed save/restore of focus listeners and replaced it with
|
19
|
** a global flag.
|
20
|
** 035 CA 20151024 Added support for WINDOW:SENSITIVE attribute.
|
21
|
+** SBI 20151103 Added the drivers keyboard focus manager to fix the lost keys input.
|
22
|
*/
|
23
|
|
24
|
package com.goldencode.p2j.ui.client.gui.driver.swing;
|
25
|
@@ -104,6 +105,7 @@
|
26
|
import com.goldencode.p2j.ui.client.event.*;
|
27
|
import com.goldencode.p2j.ui.client.gui.*;
|
28
|
import com.goldencode.p2j.ui.client.gui.driver.*;
|
29
|
+
|
30
|
import sun.java2d.*;
|
31
|
import sun.java2d.loops.*;
|
32
|
|
33
|
@@ -213,7 +215,7 @@
|
34
|
SwingEmulatedWindow.this.graphics = null;
|
35
|
}
|
36
|
};
|
37
|
-
|
38
|
+ KeyboardFocusManager.setCurrentKeyboardFocusManager(new SwingEmulatedKeyboardFocusManager());
|
39
|
// let the app above handle the decoration itself
|
40
|
if (window instanceof JFrame)
|
41
|
{
|
42
|
@@ -302,7 +304,22 @@
|
43
|
}
|
44
|
}
|
45
|
});
|
46
|
-
|
47
|
+
|
48
|
+ window.addComponentListener(new ComponentAdapter()
|
49
|
+ {
|
50
|
+
|
51
|
+ @Override
|
52
|
+ public void componentShown(ComponentEvent e)
|
53
|
+ {
|
54
|
+ KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
55
|
+ if (kfm instanceof SwingEmulatedKeyboardFocusManager)
|
56
|
+ {
|
57
|
+ ((SwingEmulatedKeyboardFocusManager) kfm).setWindowFocused(window);
|
58
|
+ }
|
59
|
+ }
|
60
|
+
|
61
|
+ });
|
62
|
+
|
63
|
// setup mouse listeners
|
64
|
pane.addMouseListener(mouseHandler);
|
65
|
pane.addMouseMotionListener(mouseHandler);
|
66
|
@@ -375,37 +392,63 @@
|
67
|
@Override
|
68
|
public void quit()
|
69
|
{
|
70
|
- for (MouseListener l : pane.getMouseListeners())
|
71
|
- {
|
72
|
- pane.removeMouseListener(l);
|
73
|
- }
|
74
|
- for (MouseMotionListener l : pane.getMouseMotionListeners())
|
75
|
- {
|
76
|
- pane.removeMouseMotionListener(l);
|
77
|
- }
|
78
|
- for (MouseWheelListener l : pane.getMouseWheelListeners())
|
79
|
- {
|
80
|
- pane.removeMouseWheelListener(l);
|
81
|
- }
|
82
|
- for (WindowListener l : window.getWindowListeners())
|
83
|
- {
|
84
|
- window.removeWindowListener(l);
|
85
|
- }
|
86
|
- for (WindowFocusListener l : window.getWindowFocusListeners())
|
87
|
- {
|
88
|
- window.removeWindowFocusListener(l);
|
89
|
- }
|
90
|
- for (WindowStateListener l : window.getWindowStateListeners())
|
91
|
- {
|
92
|
- window.removeWindowStateListener(l);
|
93
|
- }
|
94
|
- for (KeyListener l : window.getKeyListeners())
|
95
|
- {
|
96
|
- window.removeKeyListener(l);
|
97
|
- }
|
98
|
-
|
99
|
- // cleanup window resources
|
100
|
- pane.quit();
|
101
|
+ Runnable r = new Runnable()
|
102
|
+ {
|
103
|
+
|
104
|
+ @Override
|
105
|
+ public void run()
|
106
|
+ {
|
107
|
+ for (MouseListener l : pane.getMouseListeners())
|
108
|
+ {
|
109
|
+ pane.removeMouseListener(l);
|
110
|
+ }
|
111
|
+ for (MouseMotionListener l : pane.getMouseMotionListeners())
|
112
|
+ {
|
113
|
+ pane.removeMouseMotionListener(l);
|
114
|
+ }
|
115
|
+ for (MouseWheelListener l : pane.getMouseWheelListeners())
|
116
|
+ {
|
117
|
+ pane.removeMouseWheelListener(l);
|
118
|
+ }
|
119
|
+ for (WindowListener l : window.getWindowListeners())
|
120
|
+ {
|
121
|
+ window.removeWindowListener(l);
|
122
|
+ }
|
123
|
+ for (WindowFocusListener l : window.getWindowFocusListeners())
|
124
|
+ {
|
125
|
+ window.removeWindowFocusListener(l);
|
126
|
+ }
|
127
|
+ for (WindowStateListener l : window.getWindowStateListeners())
|
128
|
+ {
|
129
|
+ window.removeWindowStateListener(l);
|
130
|
+ }
|
131
|
+ for (KeyListener l : window.getKeyListeners())
|
132
|
+ {
|
133
|
+ window.removeKeyListener(l);
|
134
|
+ }
|
135
|
+ for (ComponentListener l : window.getComponentListeners())
|
136
|
+ {
|
137
|
+ window.removeComponentListener(l);
|
138
|
+ }
|
139
|
+
|
140
|
+ // cleanup window resources
|
141
|
+ pane.quit();
|
142
|
+ }
|
143
|
+ };
|
144
|
+ if (SwingUtilities.isEventDispatchThread())
|
145
|
+ {
|
146
|
+ r.run();
|
147
|
+ }
|
148
|
+ else
|
149
|
+ {
|
150
|
+ try
|
151
|
+ {
|
152
|
+ SwingUtilities.invokeAndWait(r);
|
153
|
+ }
|
154
|
+ catch (InvocationTargetException | InterruptedException e)
|
155
|
+ {
|
156
|
+ }
|
157
|
+ }
|
158
|
}
|
159
|
|
160
|
/**
|
161
|
@@ -1448,4 +1491,28 @@
|
162
|
|
163
|
highlightRestoreBuffer = null;
|
164
|
}
|
165
|
+
|
166
|
+ /**
|
167
|
+ * The driver level keyboard focus manager.
|
168
|
+ */
|
169
|
+ class SwingEmulatedKeyboardFocusManager extends DefaultKeyboardFocusManager
|
170
|
+ {
|
171
|
+ /**
|
172
|
+ * Sets the target window to be able to receive keys input.
|
173
|
+ *
|
174
|
+ * @param focusedWindow
|
175
|
+ * The target clients window
|
176
|
+ * @throws SecurityException
|
177
|
+ * if this KeyboardFocusManager is not the current KeyboardFocusManager
|
178
|
+ * for the calling thread's context and if the calling thread does not have
|
179
|
+ * "replaceKeyboardFocusManager" permission.
|
180
|
+ */
|
181
|
+ public void setWindowFocused(Window focusedWindow) throws SecurityException
|
182
|
+ {
|
183
|
+ setGlobalFocusOwner(focusedWindow);
|
184
|
+ setGlobalFocusedWindow(focusedWindow);
|
185
|
+ setGlobalActiveWindow(focusedWindow);
|
186
|
+ }
|
187
|
+ };
|
188
|
+
|
189
|
}
|
190
|
|
191
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java'
|
192
|
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java 2015-10-22 23:14:19 +0000
|
193
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java 2015-11-03 08:48:55 +0000
|
194
|
@@ -68,6 +68,8 @@
|
195
|
** HC 20151022 A fix for JWindow not able to receive focus when its owner window is not
|
196
|
** visible. This resolves ALERT-BOX and DIALOG-BOX not receiving key input when
|
197
|
** no main window visible.
|
198
|
+** SBI 20151102 To save the keyboard reader in the application context owned by the main
|
199
|
+** thread group.
|
200
|
*/
|
201
|
|
202
|
package com.goldencode.p2j.ui.client.gui.driver.swing;
|
203
|
@@ -78,6 +80,8 @@
|
204
|
|
205
|
import javax.swing.*;
|
206
|
|
207
|
+import sun.awt.AppContext;
|
208
|
+
|
209
|
import java.lang.reflect.*;
|
210
|
import java.io.*;
|
211
|
import java.util.*;
|
212
|
@@ -102,7 +106,16 @@
|
213
|
{
|
214
|
protected SwingKeyboardReader initialValue()
|
215
|
{
|
216
|
- return new WinKeyboardReader();
|
217
|
+ // the "main" thread of the gui client defines the thread group to which
|
218
|
+ // this application context belongs
|
219
|
+ AppContext appContext = AppContext.getAppContext();
|
220
|
+ Object keyboardReader = appContext.get(WinKeyboardReader.class);
|
221
|
+ if (keyboardReader == null)
|
222
|
+ {
|
223
|
+ keyboardReader = new WinKeyboardReader();
|
224
|
+ appContext.put(WinKeyboardReader.class, keyboardReader);
|
225
|
+ }
|
226
|
+ return (WinKeyboardReader) keyboardReader;
|
227
|
};
|
228
|
};
|
229
|
|
230
|
|