public class WindowManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
WindowManager.WorkArea
Stores global data relating to the state of the current context.
|
Modifier and Type | Field and Description |
---|---|
private static ContextLocal<TopLevelWindow<?>> |
activeDriverWindow
The active window as reported by the driver.
|
private static ContextLocal<Window<?>> |
activeWnd
The window referenced as the ACTIVE-WINDOW, in other words the last window
to receive ENTRY event.
|
private static ContextLocal<Window<?>> |
currentWnd
Context local instance of this class.
|
private static ContextLocal<Window<?>> |
defaultWnd
Context local instance of this class.
|
private static ContextLocal<TopLevelWindow<?>> |
focusWnd
Context local instance of this class.
|
private static ContextLocal<WindowManager.WorkArea> |
work
Stores context-local state variables.
|
Modifier | Constructor and Description |
---|---|
private |
WindowManager()
Prevent creation from outside of this class.
|
Modifier and Type | Method and Description |
---|---|
static void |
activateWindow(TitledWindow<?> window)
Activates the specified window with the driver.
|
static void |
addWindow(TitledWindow window)
Add top level window.
|
static boolean |
checkRectangle(Rectangle bounds,
Widget ancestor)
Check if specified rectangle intersects at least partially with any of
the windows located above specified one in the Z-order.
|
static void |
clearWindowList()
Delete all windows.
|
static void |
demodalizeWindow(TitledWindow<?> window)
Restores modality of the passed-in window.
|
static java.util.List<TitledWindow<?>> |
findChildren(int parentId,
boolean reverse)
Compute the child hierarchy for the specified window.
|
static Window<?> |
findSiblingWindow(Window<?> window,
boolean next)
Find the next visible window, in the specified direction.
|
static <T extends TitledWindow> |
findWindow(int windowId)
Find the window with the given ID.
|
static void |
forceActivateWindow(TitledWindow<?> window)
Activates the specified window with the driver.
|
private static void |
forEachActiveWindow(TopLevelWindow<?> activeDriverWnd,
java.util.function.Predicate<TopLevelWindow<?>> predicate)
The method enumerates all app-active windows and executes
predicate
for each until all windows are enumerated or predicate returns
false . |
static Window<?> |
getActiveWindow()
Get the main window to be reported by the
ACTIVE-WINDOW
system handle, in other words the last window to receive ENTRY event. |
static java.util.List<TopLevelWindow<?>> |
getActiveWindows()
Returns list of active top-level windows.
|
static <O extends OutputManager<?>> |
getCurrentWindow()
Returns current window handle.
|
static <O extends OutputManager<?>> |
getDefaultWindow()
Returns default window handle.
|
static java.util.List<DialogBoxWindow> |
getDialogsOwnedBy(int ownerWindowId,
boolean includeInvisible)
Returns the dialogs owned by the supplied window.
|
static <O extends OutputManager<?>> |
getFocusWindow()
Get the window owning the focus.
|
private static java.util.List<TopLevelWindow<?>> |
getModals(boolean includeInvisible)
Returns all visible modal windows in z-order with the top window
being the last in the returned list.
|
static java.util.List<TopLevelWindow<?>> |
getModalsOwnedBy(int ownerWindowId,
boolean includeInvisible)
Returns the modal windows owned by the supplied window.
|
static TopLevelWindow<?> |
getNextActiveWindow()
The window calculates the next main window that should eventually
become active after the currently active window is deactivated.
|
static boolean |
isDisplayed(Widget window)
Check if specified window is displayed, i.e.
|
static boolean |
isSharedActivationState(TopLevelWindow<?> owner,
TopLevelWindow<?> ownee)
Returns
true when ownee shares its activation state with
owner . |
static boolean |
isWindowActive(TopLevelWindow<?> window)
The method returns
true if the supplied
window is the active window. |
static void |
modalizeWindow(TopLevelWindow<?> window)
Turn the passed-in window into a modal window.
|
static void |
moveToBottom(TitledWindow window)
Move the specified window to the bottom, behind any other windows.
|
static void |
moveToTop(TitledWindow window)
Move the specified window to the top, above any other windows.
|
static void |
placeWindow(Window<?> window)
Place the new window on the screen, in its default location.
|
private static void |
processWindowActivated(TopLevelWindow<?> activated,
boolean fromNative)
The method implements the core window activation logic.
|
static void |
remove(TitledWindow<?> window)
Remove specified window from window list.
|
static void |
removeNoDestroy(TitledWindow<?> window)
Remove specified window from window list.
|
static void |
removeWindow(int window)
Remove the window instance from the client.
|
static void |
resetWindow()
Resets the default window.
|
static TopLevelWindow<?> |
resolveTopLevelWindow(AbstractWidget<?> widget)
Resolve the top-level window associated with the specified widget.
|
static Window<?> |
resolveWindow()
Resolve the window targeted by the current UI statements.
|
static Window<?> |
resolveWindow(AbstractWidget<?> widget)
Resolve the window associated with the specified widget.
|
static void |
restackWindows()
Force the list of all windows to be stacked as in the order of the currently
registered windows.
|
static void |
setActiveWindow(Window<?> window)
Set ACTIVE-WINDOW to the specified window.
|
static void |
setCurrentWindow(Window<?> wnd)
Set the current window handle.
|
static void |
setDefaultDimension(int rows,
int cols)
Set the default window dimension.
|
static void |
setFocusWindow(TopLevelWindow<?> window)
Set the focus owner to the specified window.
|
static void |
setInitialDimension(Window<?> window)
Set the initial dimension for this window.
|
static void |
setPlacementDeltas(int dx,
int dy)
Set the window placement deltas.
|
static <O extends OutputManager<?>> |
topLevelWindow()
Get the top top-level window.
|
static int[] |
topLevelWindowIds()
Get the list of all visible top-level window IDs.
|
static <O extends OutputManager<?>> |
topLevelWindowOptional()
Get the top top-level window.
|
static TitledWindow |
topWindow()
Return top window in Z-order.
|
static void |
windowActivated(int windowId,
boolean fromNativeWindow)
Called by the UI subsystem (GUI driver for example) when a top-leve window
is activated.
|
static void |
windowDeactivated(int windowId,
boolean toNativeWindow)
Called by the driver when a top-leve window is deactivated.
|
static int[] |
windowIds()
Get the list of all window IDs.
|
static java.util.List<TitledWindow<?>> |
windowList()
Get the list of registered windows.
|
static java.util.List<TitledWindow<?>> |
windowList(int underWindowId)
Get the list of windows that are positioned under
the specified
underWindowId window in the Z-order. |
private static final ContextLocal<WindowManager.WorkArea> work
private static final ContextLocal<Window<?>> defaultWnd
private static final ContextLocal<Window<?>> currentWnd
private static final ContextLocal<Window<?>> activeWnd
private static final ContextLocal<TopLevelWindow<?>> focusWnd
private static final ContextLocal<TopLevelWindow<?>> activeDriverWindow
private WindowManager()
public static Window<?> findSiblingWindow(Window<?> window, boolean next)
window
- The reference window.next
- When true
, search to the right; otherwise, search to the left of the
reference window.null
if
none exists.public static java.util.List<TitledWindow<?>> findChildren(int parentId, boolean reverse)
parentId
- The ID of the parent window.reverse
- When true
, the window list is walked in reverse order.public static void addWindow(TitledWindow window)
window
- Window to add.public static void moveToBottom(TitledWindow window)
window
- The window to be moved.public static void moveToTop(TitledWindow window)
window
- The window to be moved.public static void forceActivateWindow(TitledWindow<?> window)
WindowActivated
event.window
- The window to be activated.public static void activateWindow(TitledWindow<?> window)
WindowActivated
event.
The method will ignore the activation request if there is another visible modal window higher in the z-order.
window
- The window to be activated.public static <T extends TitledWindow> T findWindow(int windowId)
windowId
- The window ID.public static void clearWindowList()
public static TitledWindow topWindow()
null
if no windows are present.public static java.util.List<TitledWindow<?>> windowList()
public static java.util.List<TitledWindow<?>> windowList(int underWindowId)
underWindowId
window in the Z-order.
If the window underWindowId
is not registered with
WindowManager the result is an empty list.public static void removeWindow(int window)
window
- The window ID.public static Window<?> getActiveWindow()
ACTIVE-WINDOW
system handle, in other words the last window to receive ENTRY event.
In case there is not active window yet, the method returns the default
window.
Do not use the result of this method (or ACTIVE-WINDOW) as indication of the active OS window! It is a valid situation to have no P2J windows active at the OS while a valid window in ACTIVE-WINDOW.
public static void setActiveWindow(Window<?> window)
window
- The new window.public static java.util.List<TopLevelWindow<?>> getActiveWindows()
Note that there may exist multiple active top-level windows at a time.
Consider the COMBO-BOX drop-down window or menu window cases.
For more information of the concept of active windows, see
forEachActiveWindow(TopLevelWindow, Predicate)
.
public static boolean isWindowActive(TopLevelWindow<?> window)
true
if the supplied
window
is the active window.
For more information of the concept of active windows, see
forEachActiveWindow(TopLevelWindow, Predicate)
.
window
- A valid top-level window.public static <O extends OutputManager<?>> TopLevelWindow<O> topLevelWindow()
Note that this window may not be the same as the focus owner window - if the active window doesn't have any enabled/focusable widgets, focus window remains on the previous owner.
The method will return null
if no visible top-level
window exists.
public static <O extends OutputManager<?>> java.util.Optional<TopLevelWindow<O>> topLevelWindowOptional()
Note that this window may not be the same as the focus owner window - if the active window doesn't have any enabled/focusable widgets, focus window remains on the previous owner.
The method will return an empty Optional if no visible top-level window exists.
public static Window<?> resolveWindow(AbstractWidget<?> widget)
widget
- The widget.public static TopLevelWindow<?> resolveTopLevelWindow(AbstractWidget<?> widget)
widget
- The widget.public static Window<?> resolveWindow()
public static <O extends OutputManager<?>> TopLevelWindow<O> getFocusWindow()
public static void setFocusWindow(TopLevelWindow<?> window)
window
- The window owning the focus. Pass null
if no
window should hold the focus.public static <O extends OutputManager<?>> Window<O> getDefaultWindow()
public static <O extends OutputManager<?>> Window<O> getCurrentWindow()
public static void setCurrentWindow(Window<?> wnd)
wnd
- The window which is assigned to CURRENT-WINDOW.public static void resetWindow()
public static boolean isDisplayed(Widget window)
window
- Window to check.true
if window is displayed.public static void remove(TitledWindow<?> window)
Widget.destroy()
on
the supplied window reference.window
- Window to remove.public static void removeNoDestroy(TitledWindow<?> window)
If the passed in window is a modal window, it will be demodalized
with demodalizeWindow(TitledWindow)
.
window
- Window to remove.public static boolean checkRectangle(Rectangle bounds, Widget ancestor)
bounds
- Source rectangle.ancestor
- Window to check.true
if there is an intersection.public static int[] windowIds()
public static int[] topLevelWindowIds()
public static void placeWindow(Window<?> window)
The window placement algorithm replicates the algorithm used by WIN32 default window placement. More details can be found in note 615 of Redmine task #2252.
window
- The window to be placed.public static void setInitialDimension(Window<?> window)
window
- The window.public static void setDefaultDimension(int rows, int cols)
rows
- The number of rows (character units).cols
- The number of columns (character units).public static void setPlacementDeltas(int dx, int dy)
dx
- The X-axis advancement.dy
- The Y-axis advancement.public static void modalizeWindow(TopLevelWindow<?> window)
window
- The subjected window reference.public static void demodalizeWindow(TitledWindow<?> window)
modalizeWindow(TopLevelWindow)
.
When the owner window of the passed window is a modal window events will be enabled only for this owner window. This is to preserve modality.
If the passed in window is not registered with WindowManager
this
method is a no-op.
If the passed in window is silenced this method is a no-op.
window
- The subjected window reference.public static java.util.List<DialogBoxWindow> getDialogsOwnedBy(int ownerWindowId, boolean includeInvisible)
ownerWindowId
- The owner window.includeInvisible
- The flag indicating whether invisible windows should be included
in the result.DialogBoxWindow
instances or empty list if no such
window exists.public static java.util.List<TopLevelWindow<?>> getModalsOwnedBy(int ownerWindowId, boolean includeInvisible)
"owned by" in this case means the owner relationship established during frame creation, i.e. the value returned by FRAME:WINDOW rather than the actual z-ordering of the windows. The side-effect of the above and the way 4GL works also means the following. DIALOG-BOX is displayed while a main window is active. The actual owner (FRAME:WINDOW) of the dialog is hidden. When the previously active main window is made active by the OS (for example by Alt+Tab) the dialog window is NOT activated.
ownerWindowId
- The owner window.includeInvisible
- The flag indicating whether invisible windows should be included
in the result.TopLevelWindow
instances or empty list if no such
window exists.public static void restackWindows()
public static void windowActivated(int windowId, boolean fromNativeWindow)
For more information of the concept of active windows, see
forEachActiveWindow(TopLevelWindow, Predicate)
.
windowId
- The window being activated.fromNativeWindow
- If true
the window losing activated state is not a P2J window.public static void windowDeactivated(int windowId, boolean toNativeWindow)
For more information of the concept of active windows, see
forEachActiveWindow(TopLevelWindow, Predicate)
.
windowId
- The window being deactivated.toNativeWindow
- If true
the window gaining activated state is not a P2J window.public static boolean isSharedActivationState(TopLevelWindow<?> owner, TopLevelWindow<?> ownee)
true
when ownee
shares its activation state with
owner
. owner
may be an indirect owner of ownee
.owner
- The owner window.ownee
- The ownee window.public static TopLevelWindow<?> getNextActiveWindow()
private static java.util.List<TopLevelWindow<?>> getModals(boolean includeInvisible)
includeInvisible
- Indicates whether the method should include invisible
windows in its search.private static void processWindowActivated(TopLevelWindow<?> activated, boolean fromNative)
windowActivated(int, boolean)
and windowDeactivated(int, boolean)
as a result of driver window activation change.
When activated
is passed null
the method will deactivate
the currently active windows but will not activate any new window.
Also fromNative
is ignored in this case.
For more information of the concept of active windows, see
forEachActiveWindow(TopLevelWindow, Predicate)
.
activated
- The window being activated.fromNative
- If true
the window losing activated state is not a P2J window.private static void forEachActiveWindow(TopLevelWindow<?> activeDriverWnd, java.util.function.Predicate<TopLevelWindow<?>> predicate)
predicate
for each until all windows are enumerated or predicate
returns
false
.
At the application level there may exist multiple active windows simultaneously. For example when COMBO-BOX drop-down window or menu window is visible. In these cases the main window doesn't lose its activated state (its title bar is always painted as active). In contrast, there is always one active window and the driver level. So for the example above, when a menu window is displayed the driver deactivates the main window and activates the menu window.
activeDriverWnd
- The currently driver-active window.predicate
- The predicated being executed for each app-active window.