Project

General

Profile

restart_workaround_20151103.txt

Sergey Ivanovskiy, 11/03/2015 03:52 AM

Download (2.83 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java'
2
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java	2015-10-24 19:51:34 +0000
3
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java	2015-11-03 08:50:31 +0000
4
@@ -73,6 +73,8 @@
5
 **                  operations.  Removed save/restore of focus listeners and replaced it with
6
 **                  a global flag.
7
 ** 035 CA  20151024 Added support for WINDOW:SENSITIVE attribute.
8
+**     SBI 20151102 To check the ThinClient instance due to the default window survives
9
+**                  the client's restart.
10
 */
11
 
12
 package com.goldencode.p2j.ui.client.gui.driver.swing;
13
@@ -267,7 +269,12 @@
14
                if (toOS)
15
                {
16
                   // if focus is lost to a non-4GL window, the titlebar needs to be aware of this
17
-                  ThinClient.getInstance().postOSEvent(new WindowActivated(window, false, toOS));
18
+                  ThinClient tc = ThinClient.getInstance();
19
+                  // It needs to check since the default window survives the client's restart.
20
+                  if (tc != null)
21
+                  {
22
+                     ThinClient.getInstance().postOSEvent(new WindowActivated(window, false, toOS));
23
+                  }
24
                }
25
             }
26
          }
27

    
28
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java'
29
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java	2015-10-22 23:14:19 +0000
30
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java	2015-11-03 08:48:55 +0000
31
@@ -68,6 +68,8 @@
32
 **     HC  20151022 A fix for JWindow not able to receive focus when its owner window is not
33
 **                  visible. This resolves ALERT-BOX and DIALOG-BOX not receiving key input when
34
 **                  no main window visible.
35
+**     SBI 20151102 To save the keyboard reader in the application context owned by the main
36
+**                  thread group.
37
 */
38
 
39
 package com.goldencode.p2j.ui.client.gui.driver.swing;
40
@@ -78,6 +80,8 @@
41
 
42
 import javax.swing.*;
43
 
44
+import sun.awt.AppContext;
45
+
46
 import java.lang.reflect.*;
47
 import java.io.*;
48
 import java.util.*;
49
@@ -102,7 +106,16 @@
50
    {
51
       protected SwingKeyboardReader initialValue()
52
       {
53
-         return new WinKeyboardReader();
54
+         // the "main" thread of the gui client defines the thread group to which
55
+         // this application context belongs
56
+         AppContext appContext = AppContext.getAppContext();
57
+         Object keyboardReader = appContext.get(WinKeyboardReader.class);
58
+         if (keyboardReader == null)
59
+         {
60
+            keyboardReader = new WinKeyboardReader();
61
+            appContext.put(WinKeyboardReader.class, keyboardReader);
62
+         }
63
+         return (WinKeyboardReader) keyboardReader;
64
       };
65
    };
66
 
67