O
- OutputManaget typepublic class WidgetRegistry<O extends OutputManager<?>>
extends java.lang.Object
This class holds all widgets (frames and their inner widgets) which were pushed from server to client. Also, this class is responsible for building client side widgets from widget definition.
Modifier and Type | Class and Description |
---|---|
static class |
WidgetRegistry.IdRange
Container class to store the minimum and maximum widget IDs.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
batchMode
Flag indicating the UI client is in batch mode.
|
private java.util.Set<WidgetDownId> |
downWidgetIds
The set of registered widgets in a DOWN frame.
|
private java.util.Map<Frame<O>,java.util.Set<WidgetId>> |
editableFramesList
We need to maintain the list of currently editable frames.
|
private static java.util.logging.Logger |
LOG
Logger.
|
private java.util.concurrent.ConcurrentMap<WidgetId,Widget<O>> |
widgetList
The list of the widgets in the current screen.
|
Constructor and Description |
---|
WidgetRegistry()
Constructor.
|
WidgetRegistry(boolean batchMode)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addEditableFrameForWidget(Widget<?> widToCheck)
Possibly add the frame with given widget to the editable frames list if it is not already
there.
|
void |
addFrame(Frame<O> frame)
Add pre-built frame.
|
void |
addWidget(Widget<O> widget)
Add the specified widget to the registry.
|
void |
addWidget(WidgetId id,
Widget<O> widget)
Add the widget with the specified ID to the registry.
|
void |
addWidgetsRecursive(java.lang.Iterable<Widget<O>> widgets)
Add the specified widgets and all the children recursively to the
registry, immediately.
|
void |
addWidgetsRecursive(Widget<O> widget)
Add the specified widget and all its children recursively to the
registry, immediately.
|
void |
addWidgetsRecursive(Widget<O>[] widgets)
Add the specified widgets and all the children recursively to the
registry, immediately.
|
private void |
addWidgetsToFrame(int frameID,
ScreenDefinition screen)
Add widgets to the frame which is identified by the given frame ID.
|
private void |
addWidgetsToMenu(int menuID,
MenuDescription descr)
Add widgets to the menu which is identified by the given menu ID.
|
void |
attachRuntimeWidget(Frame<O> frame,
int wid,
WidgetConfig cfg)
Attach a widget to a frame, at runtime.
|
private void |
attachWidgetToFrame(Frame<O> frame,
Widget<O> widget,
WidgetConfig config)
Attach a widget to a frame, at runtime.
|
void |
clear()
Clear the registry.
|
static Widget<?> |
findAncestor(Widget<?> w,
boolean system,
java.util.function.Predicate<Widget<?>> filter)
Returns a nearest widget's ancestor that satisfies the target filter condition.
|
static Widget<?> |
findAncestor(Widget<?> w,
java.util.function.Predicate<Widget<?>> filter)
Returns a nearest widget's ancestor that satisfies the target filter condition.
|
static Widget<?> |
findDescendant(Widget<?> w,
java.lang.Class<?> type)
Returns a nearest widget's descendant having a given type.
|
Widget<O> |
getComponent(int id)
Return
Component instance for the given ID. |
Widget<O> |
getComponent(WidgetId id)
Return
Component instance for the given ID. |
Frame<O>[] |
getEditableFrames()
Get all currently existed editable frames in the screen.
|
java.util.Set<WidgetId> |
getEditableWidgets(Frame<O> frame)
Get the editable widgets for this frame.
|
Widget<O>[] |
getWidgets(Frame<O> frame,
WidgetRegistry.IdRange range)
Get all widgets in the current screen belonging to the given frame.
|
int |
lookupFrameIdFromWidgetId(int widgetId)
Retrieve the ID of the frame containing the widget with a given ID.
|
void |
pushDefinition(ScreenDefinition[] sd)
Instantiate screen from the given array of definitions.
|
void |
pushMenuDescription(MenuDescription[] md)
Instantiate menus from the given array of descriptions.
|
private void |
reconstructSideLabel(WidgetConfig config)
Reconstruct the side-label with the specified config.
|
void |
reconstructWidget(WidgetConfig config)
Recreates the widget based on the information can be taken from the
source widget snapshot.
|
void |
removeEditableFrameForWidget(Widget<?> widToCheck)
Possibly remove the frame with given widget from the editable frames list if there is no
more enabled focused widgets in a frame left.
|
void |
removeFrame(Frame<O> frame)
Remove the given frame and all contained components from the master
list of components.
|
Widget<O> |
removeWidget(WidgetId id)
Remove the specified widget from the registry, immediately.
|
void |
removeWidgetsRecursive(java.lang.Iterable<Widget<O>> widgets)
Remove the specified widgets and all the children recursively from the
registry, immediately.
|
void |
removeWidgetsRecursive(Widget<O> widget)
Remove the specified widget and all its children recursively from
the registry, immediately.
|
void |
removeWidgetsRecursive(Widget<O>[] widgets)
Remove the specified widgets and all the children recursively from the
registry, immediately.
|
void |
removeWidgetsRecursive(Widget<O> widget,
java.util.function.Predicate<Widget<O>> check)
Remove the specified widget and all its children recursively from the registry, immediately.
|
private static final java.util.logging.Logger LOG
private java.util.concurrent.ConcurrentMap<WidgetId,Widget<O extends OutputManager<?>>> widgetList
private java.util.Set<WidgetDownId> downWidgetIds
private java.util.Map<Frame<O extends OutputManager<?>>,java.util.Set<WidgetId>> editableFramesList
private boolean batchMode
public WidgetRegistry()
public WidgetRegistry(boolean batchMode)
batchMode
- Flag indicating if the UI client is in batch mode.public static Widget<?> findAncestor(Widget<?> w, java.util.function.Predicate<Widget<?>> filter)
w
- The target widget that can have an ancestor of a given type.filter
- The target filter condition.public static Widget<?> findAncestor(Widget<?> w, boolean system, java.util.function.Predicate<Widget<?>> filter)
w
- The target widget that can have an ancestor of a given type.filter
- The target filter condition.system
- Set to true
to search the system-level widget hierarchy. See
BaseEntity.setSystemParent(GenericWidget)
for more info.public static Widget<?> findDescendant(Widget<?> w, java.lang.Class<?> type)
w
- The target widget that can have a descendant of a given type.type
- The specified type condition.public void clear()
public void reconstructWidget(WidgetConfig config)
config
- Widget snapshot taken from the server.public void addFrame(Frame<O> frame)
frame
- Frame reference.public void removeFrame(Frame<O> frame)
frame
- The frame to remove.public void addEditableFrameForWidget(Widget<?> widToCheck)
widToCheck
- The widget to check.public void removeEditableFrameForWidget(Widget<?> widToCheck)
widToCheck
- The widget to check.public Frame<O>[] getEditableFrames()
public java.util.Set<WidgetId> getEditableWidgets(Frame<O> frame)
frame
- The target frame.editableFramesList
value for this frame.public Widget<O> getComponent(WidgetId id)
Component
instance for the given ID.id
- Component ID.Component
or null
if no such component exists.public Widget<O> getComponent(int id)
Component
instance for the given ID.
If the widget is part of a frame and the frame's down body is initialized, then return the widget associated with the current frame line.
id
- Component ID.Component
or null
if no such component exists.public int lookupFrameIdFromWidgetId(int widgetId)
widgetId
- The widget ID.public void attachRuntimeWidget(Frame<O> frame, int wid, WidgetConfig cfg)
frame
- The parent frame.wid
- The widget ID.cfg
- The widget's configuration.public void pushDefinition(ScreenDefinition[] sd)
sd
- Array of data containers.public void pushMenuDescription(MenuDescription[] md)
md
- Array of data containers.public Widget<O>[] getWidgets(Frame<O> frame, WidgetRegistry.IdRange range)
frame
- Frame whose widget info should be returned.range
- A container in which to store the minimum and maximum ID range, if non-null.public void addWidget(Widget<O> widget)
widget
- The new widget which needs to be registered.public void addWidget(WidgetId id, Widget<O> widget)
id
- The widget ID.widget
- The new widget which needs to be registered.public Widget<O> removeWidget(WidgetId id)
id
- The widget ID.public void addWidgetsRecursive(Widget<O> widget)
widget
- The root widget.public void addWidgetsRecursive(Widget<O>[] widgets)
widgets
- The root widgets.public void addWidgetsRecursive(java.lang.Iterable<Widget<O>> widgets)
widgets
- The root widgets.public void removeWidgetsRecursive(Widget<O>[] widgets)
widgets
- The root widgets.public void removeWidgetsRecursive(Widget<O> widget)
widget
- The root widget.public void removeWidgetsRecursive(Widget<O> widget, java.util.function.Predicate<Widget<O>> check)
The widgets are filtered and removed based on the specified predicate.
widget
- The root widget.check
- Condition to be satisfied by a widget, so that it will be removed.public void removeWidgetsRecursive(java.lang.Iterable<Widget<O>> widgets)
widgets
- The root widgets.private void addWidgetsToFrame(int frameID, ScreenDefinition screen)
frameID
- The index of the frame to be populated.screen
- List of widget configurations.private void attachWidgetToFrame(Frame<O> frame, Widget<O> widget, WidgetConfig config)
frame
- The parent frame.widget
- The widget.config
- The widget's configuration.private void addWidgetsToMenu(int menuID, MenuDescription descr)
menuID
- The index of the menu to be populated.descr
- List of widget configurations.private void reconstructSideLabel(WidgetConfig config)
This will not create a new ClientDrivenLabel
instance. It will only register the widget
configuration with the ConfigManager
, so that changes to the label instance can be
tracked and sent back to the server.
Note that the registered widget configuration must be "linked" to the related label widget.
This is because the widget takes care of unregistering the label configuration. The link
is established in ClientDrivenLabel.linkTo(int, int)
.
config
- Widget snapshot taken from the server.