/** * Register a component with the container. The container will control the visibility of the * component according to when it is active/inactive. * * @param component BaseComponent to register. */ public void registerComponent(BaseUIComponent component) { if (registeredComponents == null) { registeredComponents = new ArrayList<>(); } registeredComponents.add(component); component.setAttribute(Constants.ATTR_CONTAINER, this); component.setAttribute(Constants.ATTR_VISIBLE, component.isVisible()); component.setVisible(isVisible()); }
@Override public Listitem render(String data) { Listitem item = new Listitem(data); item.setData(new LayoutIdentifier(data, shared)); if (pnlSelect.isVisible()) { item.addEventForward(DblclickEvent.TYPE, btnOK, ClickEvent.TYPE); } return item; }
/** * Returns the first visible child of a given class, if any. * * @param <T> The child class. * @param clazz The child class to consider. * @param recurse If true, all descendant levels are also searched using a breadth first * strategy. * @return The first visible child encountered, or null if not found. */ public <T extends BaseUIComponent> T getFirstVisibleChild(Class<T> clazz, boolean recurse) { for (T child : getChildren(clazz)) { if (child.isVisible()) { return child; } } if (recurse) { for (T child : getChildren(clazz)) { T comp = child.getFirstVisibleChild(clazz, recurse); if (comp != null) { return comp; } } } return null; }
/** * Sets the visibility of the contained resource and any registered components. * * @param visible Visibility state to set */ @Override protected void updateVisibility(boolean visible, boolean activated) { super.updateVisibility(visible, activated); if (registeredComponents != null) { for (BaseUIComponent component : registeredComponents) { if (!visible) { component.setAttribute(Constants.ATTR_VISIBLE, component.isVisible()); component.setVisible(false); } else { component.setVisible((Boolean) component.getAttribute(Constants.ATTR_VISIBLE)); } } } if (visible) { checkBusy(); } }