public class UiUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static java.util.logging.Logger |
LOG
Logger.
|
Constructor and Description |
---|
UiUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkEventList(EventList list)
Checks the given event list for global events.
|
static boolean |
containsFrames(Frame<?> frame,
Rectangle r)
Check if there are other frames in specified area.
|
static WidgetConfig |
getConfig(Widget<?> w)
Returns config reference associated with the passed-in widget.
|
static <C extends WidgetConfig> |
getConfig(Widget<?> w,
java.lang.Class<C> clazz)
Returns config reference associated with the passed-in widget.
|
static Widget<?> |
getCurrentFocus()
Get the component which is in focus.
|
static byte[] |
getData(java.io.InputStream is)
Gets the data array from input stream.
|
static Color |
getDColor(Color dcolor,
Widget<?> widget)
Get DCOLOR attribute for specified widget taking into account color
inheritance from parent to child widgets.
|
static Color |
getDColor(Widget<?> widget)
Get DCOLOR attribute for specified widget taking into account color
inheritance from parent to child widgets.
|
static int[] |
getFrameIDs(TopLevelWindow wnd)
Get IDs of all frames in the current window.
|
static Frame<?>[] |
getFramesAbove(Frame<?> frame)
Get all frames which are visible, overlap given frame and are above it
in Z-order.
|
static java.util.List<java.lang.Integer> |
getParentFrames(int widgetId)
Returns all parent frames up the root frame starting from the provided widget.
|
static java.util.List<Frame<?>> |
getParentFrames(Widget<?> widget)
Returns all parent frames up the root frame starting from the provided widget.
|
static Widget<?>[] |
getTopLevelComponents(Window wnd)
Convenience method to retrieve top level frames and other components
from the default window.
|
static Widget[] |
getVisibleComponents(Frame frame,
UIStatement stmt)
Get the non-hidden components from this frame and all child frames.
|
static WidgetId |
getWidgetId(Widget<?> w)
Get ID of specified widget.
|
static int |
getWidgetIdAsInt(Widget<?> widget)
Get ID of specified widget.
|
static java.lang.String |
getWidgetIdAsString(Widget<?> widget,
java.lang.String ifNull)
Get ID of specified widget formatted to string.
|
static boolean |
hasConfig(Widget<?> widget)
Check if widget has config.
|
static void |
hideDialogs(Window wnd,
java.util.Collection<Frame> except)
Hide all dialog frames, if not in the specified list.
|
static boolean[] |
hideFrames(Frame<?> current,
boolean streamed)
Hide frames which are marked as such that can be hidden.
|
static boolean |
isAllShowing(Widget<?> comp,
Frame<?>[] above)
Returns
true if the whole widget is not even partially
obscured by any frame from the specified array. |
static boolean |
isFocusable(Widget<?> comp)
Check if widget is focusable.
|
static boolean |
isNeedPause()
Check if any visible frame has
needPause flag set. |
static AlertBox<?> |
locateAlertBox(Widget<?> widget)
Return the alert box which contains the specified widget.
|
static Frame<?> |
locateFrame(Widget<?> widget)
Return the frame which contains the specified widget.
|
static Frame<?> |
locateRootFrame(Widget<?> widget)
Return the root frame which contains the specified widget.
|
static WidgetId |
lookup4GLWidgetId(Widget<?> widget)
Get ID of the 4GL widget which has the input focus.
|
static int |
lookup4GLWidgetIdAsInt(Widget<?> widget)
Get ID of the 4GL widget which has the input focus.
|
static WidgetId |
lookupWidgetId(Widget<?> widget)
Get ID of the widget which has the input focus.
|
private static WidgetId |
lookupWidgetId(Widget<?> widget,
boolean progressOnly)
Get ID of the 4GL widget which has the input focus.
|
static int |
lookupWidgetIdAsInt(Widget<?> widget)
Get ID of the widget which has the input focus.
|
private static int |
lookupWidgetIdAsInt(Widget<?> widget,
boolean progressOnly)
Get ID of the 4GL widget which has the input focus.
|
static Widget<?> |
reconstructComponent(WidgetId id,
WidgetConfig cfg)
Instantiate component using type information provided in configuration.
|
static void |
resetNeedPause(TopLevelWindow<?> wnd)
Reset
needPause flag for all frames which are visible. |
static boolean |
showWindowForFrame(TopLevelWindow window,
Frame frame,
UIStatement stmt)
Check if the specified window can be implicitly shown by the UI statement targeting the
given frame.
|
public static Widget[] getVisibleComponents(Frame frame, UIStatement stmt)
frame
- The frame.stmt
- The current UI statement which uses this frame.public static boolean hasConfig(Widget<?> widget)
widget
- Widget to check.true
if widget is not null and has config.public static WidgetId getWidgetId(Widget<?> w)
w
- Component to for which ID is requested.null
if the widget doesn't have a config.public static int getWidgetIdAsInt(Widget<?> widget)
widget
- Component to for which ID is requested.public static java.lang.String getWidgetIdAsString(Widget<?> widget, java.lang.String ifNull)
widget
- Component to for which ID is requested.ifNull
- A value to be returned when the widget has no
assigned id.public static WidgetConfig getConfig(Widget<?> w)
w
- A widget reference or null
.null
if the widget has
no valid associated widget.public static <C extends WidgetConfig> C getConfig(Widget<?> w, java.lang.Class<C> clazz)
w
- A widget reference or null
.clazz
- The Java class representing the expected config type.null
if the widget has
no valid associated widget of the expected type.public static boolean containsFrames(Frame<?> frame, Rectangle r)
frame
- Frame to exclude.r
- Rectangle to check.true
if there are other frames in specified area.public static WidgetId lookupWidgetId(Widget<?> widget)
widget
- Event source.-1
public static WidgetId lookup4GLWidgetId(Widget<?> widget)
widget
- Event source.-1
public static int lookupWidgetIdAsInt(Widget<?> widget)
widget
- Event source.-1
if the widget doesn't have a config.public static int lookup4GLWidgetIdAsInt(Widget<?> widget)
widget
- Event source.-1
if the widget doesn't have a config.public static Widget<?> getCurrentFocus()
Component
instance which is in focus or
null
if there is no focused widget.public static boolean checkEventList(EventList list)
list
- event list to checktrue
if the list contains at least one global eventpublic static Frame<?> locateFrame(Widget<?> widget)
widget
- Widget for which to find the frame.null
if null
is passed as the parameter or the widget
is not placed in a frame.public static Frame<?> locateRootFrame(Widget<?> widget)
widget
- Widget for which to find the frame.null
if null
is passed as the paramete or the widget is
not placed in a frame.public static java.util.List<Frame<?>> getParentFrames(Widget<?> widget)
widget
- A widget. If null
an empty list is returned.public static java.util.List<java.lang.Integer> getParentFrames(int widgetId)
widgetId
- A widget id.public static AlertBox<?> locateAlertBox(Widget<?> widget)
widget
- Widget for which to find the alert box.null
if the widget is not contained in an
alert box or null
is passed as the parameter.public static boolean isAllShowing(Widget<?> comp, Frame<?>[] above)
true
if the whole widget is not even partially
obscured by any frame from the specified array.comp
- widget to testabove
- array of visible frames to test against; normally obtained by
Screen.getFramesAbove() helpertrue
if it is not obscuredpublic static boolean isFocusable(Widget<?> comp)
comp
- Widget to check.true
if widget us focusable.public static void hideDialogs(Window wnd, java.util.Collection<Frame> except)
wnd
- Containing window.except
- The list of dialogs which should not be hidden.public static int[] getFrameIDs(TopLevelWindow wnd)
wnd
- Window containing frames, current window.public static Widget<?> reconstructComponent(WidgetId id, WidgetConfig cfg)
WARNING: at this time, Window
and AlertBox
cannot be reconstructed via this mechanism.
id
- The widget's ID.cfg
- Configuration data.null
in case of
failure.public static Frame<?>[] getFramesAbove(Frame<?> frame)
frame
- Reference frame.public static void resetNeedPause(TopLevelWindow<?> wnd)
needPause
flag for all frames which are visible.wnd
- target window pause.public static boolean isNeedPause()
needPause
flag set.true
if any of the frames on the screen has
needPause
flag set to true
.public static boolean[] hideFrames(Frame<?> current, boolean streamed)
Note that if there is an old instance of given frame (not the same frame, but frame with the same name), then method returns false as if there were no frames hidden at all. Logically this is correct because new instance will replace old one at the screen.
current
- The frame for which frame hiding is performed.streamed
- true
hide streamed frames, false
-
hide frames from interactive terminal.true
if at least one
frame other than given one was hidden and there were no old
instances of given frame.true
if one of hidden
frames has the same row as current frame.public static Widget<?>[] getTopLevelComponents(Window wnd)
public static Color getDColor(Widget<?> widget)
widget
- Widget.public static Color getDColor(Color dcolor, Widget<?> widget)
null
.dcolor
- Initial color.widget
- Widget.public static byte[] getData(java.io.InputStream is)
is
- The input stream to be read.null
in case of error.public static boolean showWindowForFrame(TopLevelWindow window, Frame frame, UIStatement stmt)
If the frame is hidden, only the UIStatement.UPDATE
, UIStatement.SET
,
UIStatement.PROMPT_FOR
and UIStatement.VIEW
will show the window.
If the frame is not hidden, only the UIStatement.DISPLAY
, UIStatement.UPDATE
,
UIStatement.SET
, UIStatement.PROMPT_FOR
, UIStatement.VIEW
and
UIStatement.ENABLE
statements will show the window.
window
- The window which needs to be shown implicitly.frame
- The frame which targets this window.stmt
- The UI statement working with this frame.true
if the window needs to be shown implicitly.private static WidgetId lookupWidgetId(Widget<?> widget, boolean progressOnly)
widget
- Event source.progressOnly
- specifies if only 4GL widgets should be considered.-1
private static int lookupWidgetIdAsInt(Widget<?> widget, boolean progressOnly)
widget
- Event source.progressOnly
- specifies if only 4GL widgets should be considered.-1
if the widget doesn't have a config.