Interface WidgetContainer<T extends Widget>
-
- All Known Implementing Classes:
DefaultWidgetContainer,PortalWidgetContainer
public interface WidgetContainer<T extends Widget>A WidgetContainer is used to group widgets together. It provides functionality for creating widgets (seeinitialize(Map)) as well as managing widget focus and cleanup process. Example: Creating and loading aWidget.
-
// widget creation map
Map<String, WidgetConfig> widgetCreationMap = new HashMap<String, Widget>();
// widget 1
final String widgetCode1 = "widget1"; // code of the soon-to-be-created widget
final WidgetConfig widgetConfig1 = // ... get widget config somehow e.g. load bean from Spring context
widgetCreationMap.put(widgetCode1, widgetConfig1); // add to map
// widget 2
final String widgetCode2 = "widget2";
final WidgetConfig widgetConfig2 = // ...
widgetCreationMap.put(widgetCode2, widgetConfig2);
// create widgets
final Map<String, Widget> widgetMap = widgetContainer.initialize(widgetMap);
- See Also:
WidgetConfig,Widget,WidgetFactory
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddCockpitEventAcceptor(CockpitEventAcceptor acceptor)Registers theCockpitEventAcceptoracceptor with this widget container.voidcleanup()Performs widget cleanup i.e.voidfocusWidget(java.lang.String widgetCode)Focuses the widget associated with the specified widget code.java.lang.StringgetFocusedWidgetCode()Returns the widget code of the currently focused widget.TgetWidget(java.lang.String widgetCode)Returns the widget associated with the specified widget code.WidgetFactorygetWidgetFactory()Returns theWidgetFactoryused for creating widgets.java.util.Map<java.lang.String,T>initialize(java.util.Map<java.lang.String,WidgetConfig> widgetMap)Initializes this container i.e.voidremoveCockpitEventAcceptor(CockpitEventAcceptor acceptor)Unregisters theCockpitEventAcceptoracceptor with this widget container.voidsetWidgetFactory(WidgetFactory widgetFactory)Sets theWidgetFactoryused for creating widgets.
-
-
-
Method Detail
-
initialize
java.util.Map<java.lang.String,T> initialize(java.util.Map<java.lang.String,WidgetConfig> widgetMap)
Initializes this container i.e. creates widgets based on the suppliedWidgetConfigmap.- Parameters:
widgetMap- map containing widget codes and configurations used when creating the widgets- Returns:
- map containing the created widgets mapped to their widget code
-
cleanup
void cleanup()
Performs widget cleanup i.e. unregisters any listeners etc. Note: It is very important that this method is called when the widgets are invalidated e.g. when the widgets' parent view component has been detached from the ZK desktop.
-
getWidget
T getWidget(java.lang.String widgetCode)
Returns the widget associated with the specified widget code.- Parameters:
widgetCode- widget code- Returns:
- widget mapped to the code or null if no widget is mapped to the supplied key
-
getFocusedWidgetCode
java.lang.String getFocusedWidgetCode()
Returns the widget code of the currently focused widget.- Returns:
- code of the focused widget or null if no widget has focus
-
focusWidget
void focusWidget(java.lang.String widgetCode)
Focuses the widget associated with the specified widget code.- Parameters:
widgetCode- widget code
-
setWidgetFactory
void setWidgetFactory(WidgetFactory widgetFactory)
Sets theWidgetFactoryused for creating widgets.- Parameters:
widgetFactory- the widget factory
-
getWidgetFactory
WidgetFactory getWidgetFactory()
Returns theWidgetFactoryused for creating widgets.- Returns:
- the widget factory
-
addCockpitEventAcceptor
void addCockpitEventAcceptor(CockpitEventAcceptor acceptor)
Registers theCockpitEventAcceptoracceptor with this widget container.- Parameters:
acceptor- the event acceptor to register
-
removeCockpitEventAcceptor
void removeCockpitEventAcceptor(CockpitEventAcceptor acceptor)
Unregisters theCockpitEventAcceptoracceptor with this widget container.- Parameters:
acceptor- the event acceptor to unregister
-
-