Class UIContainer

    • Field Detail

      • UICOMP_CLASS

        public static final java.lang.Class<?>[] UICOMP_CLASS
        Accepted children components array: UIComp class.
      • VS_STATE_FOCUS_PROP_NAME

        public static final java.lang.String VS_STATE_FOCUS_PROP_NAME
        The property name for VS connection for state and focus.
        See Also:
        Constant Field Values
    • Constructor Detail

      • UIContainer

        public UIContainer()
        Creates an UI container with the specified name with a null value.
      • UIContainer

        public UIContainer​(Atom propertyAtom)
        Creates an UI container with the specified name with a null value.
        Parameters:
        propertyAtom - the property atom.
      • UIContainer

        public UIContainer​(Atom propertyAtom,
                           GProp<?>[] properties)
                    throws PropException
        Creates an UI container with the specified name and properties.
        Parameters:
        propertyAtom - the property atom.
        properties - the property array value for the property.
        Throws:
        PropException - as structural changes in containers on client is prohibited.
    • Method Detail

      • clone

        public UIContainer clone()
        Creates a clone out of this property. The cloning is overridden by the subclasses in order to handle cloning of its class variables appropriately.

        Cloning is used for "virtualization" of a property tree in the server. Client property classes will therefore throw CloneNotSupportedException.

        Once a tree has been cloned, the change-flag is reset, and the create-flag is set. All listeners are also removed! The new cloned property is an orphan, i.e. has no parent set. All children properties are also (deep) cloned.

        Note that the cloning process is done WITHOUT thread synchronization for performance reasons, thus no modifications should be done to the tree!

        Overrides:
        clone in class UIComp
      • addPredefinedProps

        protected void addPredefinedProps()
                                   throws PropException
        Adds the predefined properties for this container. This method is called once just after construction of the property container and sometimes population of it.

        This implementation creates the UIComps property named Atom.COMPONENTS for the UI components, and saves the reference to it for fast access.

        Overrides:
        addPredefinedProps in class PropCnr
        Throws:
        PropException - For property exceptions.
      • addPredefinedPropsImpl

        protected void addPredefinedPropsImpl()
                                       throws PropException
        Adds the predefined containers for identifications, fields and actions. This method is overridden fully by the Editor versions of the class.
        Throws:
        PropException - For property exceptions.
      • getPredefinedProps

        public void getPredefinedProps()
        Adds the predefined containers for identifications, fields and actions. This method is overridden fully by the Editor versions of the class.
        Overrides:
        getPredefinedProps in class UIComp
      • updateUICompsReference

        protected void updateUICompsReference()
        Updates the reference to the UIComps instance named Atom.COMPONENTS, used when cloning and for the panel part container (or any time the UIComps instance has been changed).
      • resetComponentID

        public void resetComponentID()
        Resets the component ID, typically when copied or saved in order to add make copies of the (some) component data. The operation is recursive.
        Overrides:
        resetComponentID in class UIComp
      • hasImplicitAlignFillX

        public boolean hasImplicitAlignFillX()
        Returns if the container has implicit component horizontal fill.

        The default behavior is to forward the reply to LayoutMgr.hasImplicitAlignFillX().

        Overrides:
        hasImplicitAlignFillX in class UIComp
        Returns:
        true means component will always fill the space in X, false otherwise.
      • hasImplicitAlignFillY

        public boolean hasImplicitAlignFillY()
        Returns if the container has implicit component vertical fill.

        The default behavior is to forward the reply to LayoutMgr.hasImplicitAlignFillY().

        Overrides:
        hasImplicitAlignFillY in class UIComp
        Returns:
        true means component will always fill the space in Y, false otherwise.
      • getDeviceType

        public int getDeviceType()
        Gets the device type: -1=mobile, 0=both, 1=desktop.
        Specified by:
        getDeviceType in interface IUIComp
      • isMobileContextMenuSupported

        public boolean isMobileContextMenuSupported()
        Returns if the component can show the context menu in mobile mode.
        Specified by:
        isMobileContextMenuSupported in interface IUIContextMenuOwner
        Returns:
        Container component does not by default supports context menus for mobile.
      • createCompsCnr

        public UIComps createCompsCnr()
        Creates the components for the Editor.
      • getCompsCnr

        public UIComps getCompsCnr()
        Gets the container associated with this layout manager and the UI container.
        Specified by:
        getCompsCnr in interface IUIContainer
        Returns:
        The UI components container.
      • getComponents

        public UIComp[] getComponents()
        Gets the UI components of the container.
        Specified by:
        getComponents in interface IUIContainer
        Returns:
        The array of components, always non-null.
      • getComponentCount

        public int getComponentCount()
        Gets the UI component count.
        Specified by:
        getComponentCount in interface IUIContainer
        Returns:
        The UI component count.
      • isEmptyContainerAllowed

        public boolean isEmptyContainerAllowed()
        Returns whether the container should have children in a normal conditions, i.e. a warning message should be displayed in the Designer when it is empty. This is intended to be used to avoid use of empty containers. Some containers, e.g. the mobile heading is allowed to be empty.
        Returns:
        false (default) not to allow empty container, true otherwise.
      • getRadioSelectionComponents

        public UIComp[] getRadioSelectionComponents​(java.lang.String groupName)
        Gets the components being part of the selection group specified. Each component returned implements the this IRadioComponent interface.
        Specified by:
        getRadioSelectionComponents in interface IUIContainer
        Parameters:
        groupName - The group name, possibly null (for default).
        Returns:
        An array of the selection components.
      • getSelectedRadioComponent

        public UIComp getSelectedRadioComponent​(java.lang.String groupName)
        Gets the currently selected radio component in the group.
        Specified by:
        getSelectedRadioComponent in interface IUIContainer
        Parameters:
        groupName - The group name, possibly null.
        Returns:
        The selected radio component, null for none.
      • setRadioSelectionComponent

        public boolean setRadioSelectionComponent​(IUIRadioComponent radioComponent,
                                                  boolean isSelected)
        Sets the selection to the specified radio component.
        Specified by:
        setRadioSelectionComponent in interface IUIContainer
        Parameters:
        radioComponent - The radio-interface-implementing (interface IUIRadioComponent component.
        isSelected - The selection state.
        Returns:
        true if at least one change occurred, false for none.
      • canAcceptUIContainerFocus

        public java.lang.String canAcceptUIContainerFocus()
        Returns if this container can accept focus itself or for one of its children components. If this is a component and not a container, this request is redirected to the parent container.

        This method recurses up to the topmost UI container, and all containers must return null for this method to return null.

        Typically, a container returns itself as instance if it is disabled or hidden.

        Specified by:
        canAcceptUIContainerFocus in interface IUIComp
        Overrides:
        canAcceptUIContainerFocus in class UIComp
        Returns:
        null if this container (or parent container if this is a component) and all containers up to the topmost level returns null, otherwise the container that did not accept focus.
      • setUIContainerFocus

        public java.lang.String setUIContainerFocus​(UIComp requestor,
                                                    boolean doAnimate)
        Sets the focus to the UI container and all its parents. This method is called when focus is to be set to a component, making it possible for containers such as accordion/swap/tab to change its main container into view.

        Subclasses must override this method to process it, but make sure to call super.setUIContainerFocus(requestor) first!

        Specified by:
        setUIContainerFocus in interface IUIComp
        Overrides:
        setUIContainerFocus in class UIComp
        Parameters:
        requestor - The requestor is a child to this container.
        doAnimate - Flag to enable animation when selection is changed for e.g. accordion, swap or tab containers.
        Returns:
        null for success, otherwise an error message why it failed.
      • getVSStateFocus

        public final VSComponent getVSStateFocus()
        Gets the VS component for state and focus of this container.
        Overrides:
        getVSStateFocus in class UIComp
        Returns:
        The component (generally a VS Group), null if none is set.
      • getFirstContainerVSStateFocus

        public VSComponent getFirstContainerVSStateFocus()
        Gets the first VS component encountered for state and focus of this container or in the parent tree up to the panel level.
        Overrides:
        getFirstContainerVSStateFocus in class UIComp
        Returns:
        The component (generally a VS Group), null if none is set.
      • onResolved

        public void onResolved​(VSComponentReference reference,
                               VSComponent component)
        Called when the property reference has been resolved. UI components use this method to set its state according to the VS component.
        Specified by:
        onResolved in interface IVSGenericComponentListener
        Parameters:
        reference - The VSComponentReference instance holding the component reference.
        component - The VS component reference that is now resolved.
      • onBroken

        public void onBroken​(VSComponentReference reference,
                             VSComponent component)
        Called when the property reference has been broken, i.e. unresolved.
        Specified by:
        onBroken in interface IVSGenericComponentListener
        Parameters:
        reference - The VSComponentReference instance holding the component reference.
        component - The VS component reference that is now unresolved.
      • onVSComponentSelectionChanged

        protected void onVSComponentSelectionChanged​(boolean on)
        Called when the VS component has its selected state changed. By default, the parent container is verified for selection support. These are typically accordion, swap, tab containers.
        Parameters:
        on - The selected state.
      • onComponentSelectedInParent

        public void onComponentSelectedInParent​(boolean on)
        Called by the parent container to inform that this component has been selected in its container. The containers that call this method are typically accordion, swap and tab containers.

        The container processes this method by selecting the VSComponent for state and focus that may be connected.

        Overrides:
        onComponentSelectedInParent in class UIComp
        Parameters:
        on - The selection state.
      • onSelectionChanged

        protected void onSelectionChanged​(GEvent event)
        Method called when the selection of the component changed due to a property change (value changed, property added or removed).
        Overrides:
        onSelectionChanged in class UIComp
        Parameters:
        event - The event that causes the selection change.
      • onSelectionChanged

        protected void onSelectionChanged​(boolean on)
        Called when the container is selected as the current container in an index-based single-selection container such as accordion, swap and tab containers.
      • verify

        public boolean verify​(PropVerification verification)
        Verifies this property container. The check performed is the extension of classes and that no circular reference is present.
        Specified by:
        verify in interface IGProp<GProp<?>[]>
        Overrides:
        verify in class UIComp
        Parameters:
        verification - The property verification class.
        Returns:
        true if verification should proceed, false if disposed of and verification should not take place.
      • verifyComponentScope

        protected boolean verifyComponentScope​(UIContainer scopeContainer,
                                               java.lang.String what,
                                               PropVerification verification,
                                               VSComponent vsOuter)
        Verifies that this component has it's VS references inside the outer VS reference.
        Overrides:
        verifyComponentScope in class UIComp
        Parameters:
        scopeContainer - The scope container.
        what - What the scope container is.
        verification - The property verification class.
        vsOuter - The outer VS parent.
        Returns:
        true if OK, false if somehow outside.
      • getUIComponent

        public <COMP extends UIComp> COMP getUIComponent​(@UIRef java.lang.String uiPath,
                                                         java.lang.Class<COMP> uiClass)
                                                  throws NotFoundException
        Gets a UI component with relative reference from this container.

        Note: A UI path is not the same as a property path, it omits the UI container UIComps instance from the path.

        Note 2: If the path is empty, "this" component is returned if the component class uiClass matches, otherwise NotFoundException is thrown.

        Parameters:
        uiPath - The UI path for the component.
        uiClass - The UI class of the component.
        Returns:
        The component, never null.
        Throws:
        NotFoundException - The not-found exception is thrown if the component is not found instead of returning null.
      • getUIComponentNull

        public <COMP extends UIComp> COMP getUIComponentNull​(@UIRef java.lang.String uiPath,
                                                             java.lang.Class<COMP> uiClass)
        Gets a UI component with relative reference from this container.

        Note: A UI path is not the same as a property path, it omits the UI container UIComps instance from the path.

        Note 2: If the path is empty, "this" component is returned if the component class uiClass matches, otherwise null is returned.

        Parameters:
        uiPath - The UI path for the component.
        uiClass - The UI class of the component.
        Returns:
        The component, or null if not found.
      • getFirstUIComponent

        public <COMP extends UIComp> COMP getFirstUIComponent​(java.lang.String name,
                                                              java.lang.Class<COMP> uiClass)
                                                       throws NotFoundException
        Gets the first UI component of the specified name and UI class. The search for the component is done from this container and its children containers.
        Specified by:
        getFirstUIComponent in interface IUIComp
        Parameters:
        name - The name of the component.
        uiClass - The UI class of the component.
        Returns:
        The component, never null.
        Throws:
        NotFoundException - The not-found exception is thrown if the component is not found instead of returning null.
      • getFirstUIComponentNull

        public <COMP extends UIComp> COMP getFirstUIComponentNull​(java.lang.String name,
                                                                  java.lang.Class<COMP> uiClass)
        Gets the first UI component of the specified name and UI class. The search for the component is done from this container and its children containers.
        Specified by:
        getFirstUIComponentNull in interface IUIComp
        Parameters:
        name - The name of the component.
        uiClass - The UI class of the component.
        Returns:
        The component, or null if not found.
      • mustHaveWidth

        public boolean mustHaveWidth()
        Does this component requires a width?
        Overrides:
        mustHaveWidth in class UIComp
        Returns:
        true if the width must be defined and non-zero, false otherwise.
      • mustHaveHeight

        public boolean mustHaveHeight()
        Does this component requires a height.
        Overrides:
        mustHaveHeight in class UIComp
        Returns:
        true if the height must be defined and non-zero, false otherwise.
      • getApproximateSize

        public Size getApproximateSize()
        Returns the size of the component in pixels. The size is a calculation and does not exactly reflect the real size that may be different due to additional styles not taken into account by this method. The size is calculated from the font of the component and default or defined values (such as character length or number of lines for text area).
        Specified by:
        getApproximateSize in class UIComp
        Returns:
        The size of the component: 300x200.