=== 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 18:12:23 +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 18:10:07 +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 { === 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-03 18:43:00 +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 drivers keyboard focus manager 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.*; @@ -213,7 +215,7 @@ SwingEmulatedWindow.this.graphics = null; } }; - + KeyboardFocusManager.setCurrentKeyboardFocusManager(new SwingEmulatedKeyboardFocusManager()); // let the app above handle the decoration itself if (window instanceof JFrame) { @@ -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,28 @@ highlightRestoreBuffer = null; } + + /** + * 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/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-03 16:17:30 +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,7 @@ * 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(); /** A special map containing the attributes of a underlined font. */ static Map UNDERLINE_FONT = new HashMap<>(); @@ -246,7 +239,7 @@ @Override public int readKey() { - return keyReader.get().read(); + return keyReader.read(); } /** @@ -264,7 +257,7 @@ try { - ews = SwingGuiClient.load(keyReader.get(), true); + ews = SwingGuiClient.load(keyReader, true); // the real window size is unknown at this time; it will be set later, when the layout // is performed @@ -304,14 +297,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(keyReader, false); } // the real window size is unknown at this time; it will be set later, when the layout