=== modified file 'src/com/goldencode/p2j/ui/chui/ThinClient.java' --- src/com/goldencode/p2j/ui/chui/ThinClient.java 2015-11-03 15:54:27 +0000 +++ src/com/goldencode/p2j/ui/chui/ThinClient.java 2015-11-03 19:46:38 +0000 @@ -2177,6 +2177,7 @@ ** SVL 20151029 Added queryRepositioned. ** EVL 20151103 Adding handing image names without extensions while loading from ** client file system. +** SBI 20151103 Changed terminate() to reset windows for gui as for chui. */ package com.goldencode.p2j.ui.chui; @@ -2879,11 +2880,7 @@ ClientConfigManager mgr = ConfigManager.getInstance(); mgr.deactivateConfigUpdates(); - if (tc.isChui()) - { - // this is needed only for chui... - WindowManager.resetWindow(); - } + WindowManager.resetWindow(); } /** === modified file 'src/com/goldencode/p2j/ui/client/WindowManager.java' --- src/com/goldencode/p2j/ui/client/WindowManager.java 2015-10-16 12:11:54 +0000 +++ src/com/goldencode/p2j/ui/client/WindowManager.java 2015-11-04 21:26:19 +0000 @@ -45,6 +45,8 @@ ** 020 HC 20151013 Changes to extend GUI multi-window focus management and ACTIVE-WINDOW system ** handle processing to modal windows. ** 021 GES 20151015 moveToTop()/moveToBottom() forces the driver to move the specified window. +** SBI 20151103 Changed clearWindowList() to dispose the default window and to clear windows +** following the reverse order of their creations. */ package com.goldencode.p2j.ui.client; @@ -301,16 +303,16 @@ synchronized (wa.windows) { - wins.addAll(wa.windows); + wins.addAll(wa.fixedOrderWindows); } - - // notify the windows are being destroyed + Collections.reverse(wins); + // notify the windows are being destroyed in the reverse to their creations for (TitledWindow w : wins) { w.hide(); if (w instanceof Window) { - removeWindow(w.getId().asInt()); + remove(w); } else { === added file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedKeyboardFocusManager.java' --- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedKeyboardFocusManager.java 1970-01-01 00:00:00 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedKeyboardFocusManager.java 2015-11-04 21:28:15 +0000 @@ -0,0 +1,40 @@ +/* +** Module : SwingEmulatedKeyboardFocusManager.java +** Abstract : The application driver's level keyboard focus manager +** +** Copyright (c) 2014-2015, Golden Code Development Corporation. +** ALL RIGHTS RESERVED. Use is subject to license terms. +** +** Golden Code Development Corporation +** CONFIDENTIAL +** +** -#- -I- --Date-- ---------------------------------Description--------------------------------- +** 001 SBI 20151104 Added the driver's level keyboard focus manager. +*/ + +package com.goldencode.p2j.ui.client.gui.driver.swing; + +import java.awt.*; + +/** + * The driver level keyboard focus manager. + */ +class SwingEmulatedKeyboardFocusManager extends DefaultKeyboardFocusManager +{ + /** + * Sets the target window to be able to receive keys input. + * + * @param focusedWindow + * The target clients window + * @throws SecurityException + * if this KeyboardFocusManager is not the current KeyboardFocusManager + * for the calling thread's context and if the calling thread does not have + * "replaceKeyboardFocusManager" permission. + */ + public void setWindowFocused(Window focusedWindow) throws SecurityException + { + setGlobalFocusOwner(focusedWindow); + setGlobalFocusedWindow(focusedWindow); + setGlobalActiveWindow(focusedWindow); + } +} === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java' --- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java 2015-10-24 19:51:34 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java 2015-11-04 20:07:33 +0000 @@ -73,6 +73,7 @@ ** operations. Removed save/restore of focus listeners and replaced it with ** a global flag. ** 035 CA 20151024 Added support for WINDOW:SENSITIVE attribute. +** SBI 20151103 Added the on show component listener to fix the lost keys input. */ package com.goldencode.p2j.ui.client.gui.driver.swing; @@ -104,6 +105,7 @@ import com.goldencode.p2j.ui.client.event.*; import com.goldencode.p2j.ui.client.gui.*; import com.goldencode.p2j.ui.client.gui.driver.*; + import sun.java2d.*; import sun.java2d.loops.*; @@ -302,7 +304,22 @@ } } }); - + + window.addComponentListener(new ComponentAdapter() + { + + @Override + public void componentShown(ComponentEvent e) + { + KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); + if (kfm instanceof SwingEmulatedKeyboardFocusManager) + { + ((SwingEmulatedKeyboardFocusManager) kfm).setWindowFocused(window); + } + } + + }); + // setup mouse listeners pane.addMouseListener(mouseHandler); pane.addMouseMotionListener(mouseHandler); @@ -403,6 +420,10 @@ { window.removeKeyListener(l); } + for (ComponentListener l : window.getComponentListeners()) + { + window.removeComponentListener(l); + } // cleanup window resources pane.quit(); @@ -1448,4 +1469,5 @@ highlightRestoreBuffer = null; } + } === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiClient.java' --- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiClient.java 2015-10-22 22:00:01 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiClient.java 2015-11-04 21:27:24 +0000 @@ -23,11 +23,13 @@ ** 008 CA 20150921 Mouse and focus fixes. ** 009 HC 20151022 A fix for JWindow not able to receive focus when its owner window is not ** visible. This resolves ALERT-BOX and DIALOG-BOX not receiving key input when -** no main window visible. +** no main window visible. +** SBI 20151104 Setup the driver's level keyboard focus manager. */ package com.goldencode.p2j.ui.client.gui.driver.swing; +import java.awt.KeyboardFocusManager; import java.lang.reflect.*; import javax.swing.*; @@ -50,13 +52,15 @@ * Construct the new frame by instantiating the {@link SwingEmulatedWindow} as the * content pane and initializing it using the given options. * + * @param focusManager + * The driver's level keyboard focus manager. * @param keyReader * The {@link SwingKeyboardReader key reader} which listens for incoming keys. * @param showOnTaskbar * If true, the window backed by this emulator will be displayed * on OS task bar. */ - private SwingGuiClient(SwingKeyboardReader keyReader, boolean showOnTaskbar) + private SwingGuiClient(KeyboardFocusManager focusManager, SwingKeyboardReader keyReader, boolean showOnTaskbar) { super(WindowGuiImpl.DEFAULT_TITLE); @@ -64,7 +68,7 @@ { setType(javax.swing.JFrame.Type.POPUP); } - + KeyboardFocusManager.setCurrentKeyboardFocusManager(focusManager); // common initialization sew = new SwingEmulatedWindow(this, keyReader); init(sew.getContentPane(), false); @@ -74,6 +78,8 @@ * Initialize the application frame by creating a new instance of this class * and of the content pane which is an instance of {@link SwingEmulatedWindow}. * + * @param focusManager + * The driver's level keyboard focus manager. * @param keyReader * The {@link SwingKeyboardReader key reader} which listens for incoming keys. * @param showOnTaskbar @@ -82,7 +88,8 @@ * * @return The simulator instance. */ - public static EmulatedWindowState load(final SwingKeyboardReader keyReader, + public static EmulatedWindowState load(final KeyboardFocusManager focusManager, + final SwingKeyboardReader keyReader, final boolean showOnTaskbar) throws InterruptedException, InvocationTargetException @@ -95,7 +102,7 @@ { public void run() { - client[0] = new SwingGuiClient(keyReader, showOnTaskbar); + client[0] = new SwingGuiClient(focusManager, keyReader, showOnTaskbar); } }); === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java' --- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java 2015-10-22 23:14:19 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java 2015-11-04 21:29:39 +0000 @@ -68,6 +68,8 @@ ** HC 20151022 A fix for JWindow not able to receive focus when its owner window is not ** visible. This resolves ALERT-BOX and DIALOG-BOX not receiving key input when ** no main window visible. +** SBI 20151102 To do the keyboard reader a final driver's field, added the driver's level +** keyboard focus manager. */ package com.goldencode.p2j.ui.client.gui.driver.swing; @@ -82,7 +84,6 @@ import java.io.*; import java.util.*; -import com.goldencode.p2j.security.*; import com.goldencode.p2j.ui.client.*; import com.goldencode.p2j.ui.client.gui.driver.*; import com.goldencode.p2j.ui.client.driver.swing.*; @@ -97,14 +98,12 @@ * The key reader. This is global per the entire application, no matter how many frames are * alive. */ - private static final ContextLocal keyReader = - new ContextLocal() - { - protected SwingKeyboardReader initialValue() - { - return new WinKeyboardReader(); - }; - }; + private final SwingKeyboardReader keyReader = new WinKeyboardReader(); + + /** + * The driver's level keyboard focus manager. + */ + private final KeyboardFocusManager keyboardFocusManager = new SwingEmulatedKeyboardFocusManager(); /** A special map containing the attributes of a underlined font. */ static Map UNDERLINE_FONT = new HashMap<>(); @@ -246,7 +245,7 @@ @Override public int readKey() { - return keyReader.get().read(); + return keyReader.read(); } /** @@ -264,7 +263,7 @@ try { - ews = SwingGuiClient.load(keyReader.get(), true); + ews = SwingGuiClient.load(keyboardFocusManager, keyReader, true); // the real window size is unknown at this time; it will be set later, when the layout // is performed @@ -304,14 +303,14 @@ { ews = GuiWindowContainer.load((SwingEmulatedWindow) owner, windowTitle, - keyReader.get()); + keyReader); } else { // GuiWindowContainer is backed by JWindow Swing component which // requires a visible owner window in order to be focusable. // So if no visible owner, use SwingGuiClient backed by JFrame. - ews = SwingGuiClient.load(keyReader.get(), false); + ews = SwingGuiClient.load(keyboardFocusManager, keyReader, false); } // the real window size is unknown at this time; it will be set later, when the layout