=== 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-03 19:46:38 +0000 @@ -45,6 +45,7 @@ ** 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. */ package com.goldencode.p2j.ui.client; @@ -310,7 +311,7 @@ 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 18:48:08 +0000 @@ -0,0 +1,41 @@ +/* +** 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.DefaultKeyboardFocusManager; +import java.awt.Window; + +/** + * 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); + } +} \ No newline at end of file === 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 18:44:47 +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); @@ -375,37 +392,63 @@ @Override public void quit() { - for (MouseListener l : pane.getMouseListeners()) - { - pane.removeMouseListener(l); - } - for (MouseMotionListener l : pane.getMouseMotionListeners()) - { - pane.removeMouseMotionListener(l); - } - for (MouseWheelListener l : pane.getMouseWheelListeners()) - { - pane.removeMouseWheelListener(l); - } - for (WindowListener l : window.getWindowListeners()) - { - window.removeWindowListener(l); - } - for (WindowFocusListener l : window.getWindowFocusListeners()) - { - window.removeWindowFocusListener(l); - } - for (WindowStateListener l : window.getWindowStateListeners()) - { - window.removeWindowStateListener(l); - } - for (KeyListener l : window.getKeyListeners()) - { - window.removeKeyListener(l); - } - - // cleanup window resources - pane.quit(); + Runnable r = new Runnable() + { + + @Override + public void run() + { + for (MouseListener l : pane.getMouseListeners()) + { + pane.removeMouseListener(l); + } + for (MouseMotionListener l : pane.getMouseMotionListeners()) + { + pane.removeMouseMotionListener(l); + } + for (MouseWheelListener l : pane.getMouseWheelListeners()) + { + pane.removeMouseWheelListener(l); + } + for (WindowListener l : window.getWindowListeners()) + { + window.removeWindowListener(l); + } + for (WindowFocusListener l : window.getWindowFocusListeners()) + { + window.removeWindowFocusListener(l); + } + for (WindowStateListener l : window.getWindowStateListeners()) + { + window.removeWindowStateListener(l); + } + for (KeyListener l : window.getKeyListeners()) + { + window.removeKeyListener(l); + } + for (ComponentListener l : window.getComponentListeners()) + { + window.removeComponentListener(l); + } + + // cleanup window resources + pane.quit(); + } + }; + if (SwingUtilities.isEventDispatchThread()) + { + r.run(); + } + else + { + try + { + SwingUtilities.invokeAndWait(r); + } + catch (InvocationTargetException | InterruptedException e) + { + } + } } /** @@ -1448,4 +1491,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 18:43:44 +0000 @@ -28,6 +28,7 @@ package com.goldencode.p2j.ui.client.gui.driver.swing; +import java.awt.KeyboardFocusManager; import java.lang.reflect.*; import javax.swing.*; @@ -50,13 +51,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 +67,7 @@ { setType(javax.swing.JFrame.Type.POPUP); } - + KeyboardFocusManager.setCurrentKeyboardFocusManager(focusManager); // common initialization sew = new SwingEmulatedWindow(this, keyReader); init(sew.getContentPane(), false); @@ -74,6 +77,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 +87,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 +101,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 18:48:24 +0000 @@ -68,6 +68,7 @@ ** 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. */ package com.goldencode.p2j.ui.client.gui.driver.swing; @@ -82,7 +83,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 +97,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 +244,7 @@ @Override public int readKey() { - return keyReader.get().read(); + return keyReader.read(); } /** @@ -264,7 +262,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 +302,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 @@ -515,5 +513,6 @@ public void setCurrentSelection(String txt) { // not needed for clipboard support in Swing - } + }; + }