Class UISwapContainer

    • Field Detail

      • PN_OPEN_VIEW

        protected static final java.lang.String PN_OPEN_VIEW
        Property name: current open view.
        See Also:
        Constant Field Values
      • OPEN_VIEW_ATOM

        protected static final Atom OPEN_VIEW_ATOM
        Property atom: current open view.
      • TRANSITION_TYPE_PROP_NAME

        public static final java.lang.String TRANSITION_TYPE_PROP_NAME
        The transition type property name.
        See Also:
        Constant Field Values
      • TRANSITION_DIR_PROP_NAME

        public static final java.lang.String TRANSITION_DIR_PROP_NAME
        The transition property name.
        See Also:
        Constant Field Values
    • Constructor Detail

      • UISwapContainer

        public UISwapContainer()
        Creates the container without name with a null value.
      • UISwapContainer

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

        public UISwapContainer​(Atom propertyAtom,
                               GProp<?>[] properties)
                        throws PropException
        Creates a swap container with the specified name and properties.
        Parameters:
        propertyAtom - the property atom.
        properties - the property array value for the container.
        Throws:
        PropException - when properties are not correctly defined.
    • Method Detail

      • getPredefinedProps

        public void getPredefinedProps()
        Gets potential references to predefined properties for this container. This method is called once just after cloning of the property container.

        The method should get reference to using the getProp(...) methods. This allows the subclass to be able to retrieve the new instances to the properties created during addPredefinedProps() if stored in instance variables.

        Subclasses must override this method to do the appropriate initialization, as this method does nothing for the PropCnr class implementation.

        Overrides:
        getPredefinedProps in class UIContainer
      • clone

        public UISwapContainer 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 UIContainer
      • mustHaveWidth

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

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

        public boolean mustHaveExplicitWidth()
        Does this component require an explicitly defined width?
        Overrides:
        mustHaveExplicitWidth in class UIComp
        Returns:
        true if the width must be defined and non-zero, false otherwise.
      • mustHaveExplicitHeight

        public boolean mustHaveExplicitHeight()
        Does this component require an explicitly defined height?
        Overrides:
        mustHaveExplicitHeight in class UIComp
        Returns:
        true if the height must be defined and non-zero, false otherwise.
      • hasImplicitAlignFillX

        public boolean hasImplicitAlignFillX()
        Returns if the component has implicit component horizontal fill.
        Overrides:
        hasImplicitAlignFillX in class UIContainer
        Returns:
        Always true: true means component will always fill the space in X.
      • hasImplicitAlignFillY

        public boolean hasImplicitAlignFillY()
        Returns if the component has implicit component vertical fill.
        Overrides:
        hasImplicitAlignFillY in class UIContainer
        Returns:
        Always: true means component will always fill the space in Y.
      • canAlignX

        public boolean canAlignX()
        Returns if the component can be aligned left, right, center, or horizontal fill.
        Overrides:
        canAlignX in class UIComp
        Returns:
        false, swap container takes up entire width.
      • canAlignY

        public boolean canAlignY()
        Returns if the component can be aligned top, bottom, middle or vertical fill.
        Overrides:
        canAlignY in class UIComp
        Returns:
        false, swap container takes up entire height.
      • getSelectionPropAtom

        public Atom getSelectionPropAtom()
        Returns the selection property atom for verification of selection changes.

        This method is used by the framework in UIComp to fire selection events when the property value changes.

        Specified by:
        getSelectionPropAtom in interface IUISelectionComp
        Returns:
        The atom of the selection property.
      • onEventSelf

        public void onEventSelf​(GEvent event)
        Event checking to update the VSField from selection index or combobox text.
        Specified by:
        onEventSelf in interface IGProp<GProp<?>[]>
        Overrides:
        onEventSelf in class UIComp
        Parameters:
        event - The property event.
      • isContextMenuSupported

        public boolean isContextMenuSupported()
        Returns if the context menu is supported for this component or not.
        Specified by:
        isContextMenuSupported in interface IUIContextMenuOwner
        Returns:
        false as the Swap Container does not support context menus.
      • getGroupID

        public int getGroupID​(GroupNameProp groupName)
        Gets the unique ID for a group name.
        Specified by:
        getGroupID in interface IUIGroupSeparator
        Parameters:
        groupName - The group name. Return The unique for the group name.
      • getSelectionType

        public int getSelectionType()
        Gets the selection type of the component.
        Specified by:
        getSelectionType in interface IUISelectionComp
        Returns:
        A value indicating the selection capability as the SELECTION_TYPE_* values define.
      • setSelection

        public java.lang.String setSelection​(int index,
                                             boolean isAnimated)
        Sets the selection as a single selected item at specified index.
        Specified by:
        setSelection in interface IUIAnimatedSingleIndexedSelectionComp
        Parameters:
        index - The single item to select at index, -1 to clear the selection.
        isAnimated - The animation flag.
        Returns:
        null for success, otherwise an error message why the selection failed.
      • isSelected

        public boolean isSelected()
        Returns the selection of state of the component.

        For a multiple-selection capable component, this indicates any selection, i.e. true is returned as soon as at least one element is selected, false for none.

        The checkbox for example has two "selected states": checked and third state: in this case, true is returned for the third state as well as the checked state.

        Specified by:
        isSelected in interface IUISelectionComp
        Returns:
        true if the component is selected, false otherwise.
      • clearSelection

        public java.lang.String clearSelection()
        Clear the selection.
        Specified by:
        clearSelection in interface IUIIndexedSelectionComp
        Returns:
        Always "Swap container cannot clear selection".
      • setTransition

        public boolean setTransition​(Transition type)
        Sets the animation transition type to use from now on when a view is changed or swapped programmatically or through a focus change.

        Default type is SLIDE.

        Parameters:
        type - The transition type.
        Returns:
        true if animation type was changed, false for no change.
      • setTransition

        public boolean setTransition​(int dir)
        Sets the animation transition direction to use from now on when a view is changed or swapped programmatically or through a focus change.
        Parameters:
        dir - The transition direction. If 1, transition forward. If 0, automatic transition forward or backward depending on view ordering when switching, If -1, transition backward. For example, the slide transition slides the view from right to left when dir == 1, and from left to right when dir == -1.
        Returns:
        true if animation direction was changed, false for no change.
        Throws:
        java.lang.IllegalArgumentException - If dir is not -1, 0 or 1.
      • getTransitionType

        public Transition getTransitionType()
        Gets the transition type currently used.

        The default transition is SLIDE.

        Returns:
        The Transition.
      • getTransitionDir

        public int getTransitionDir()
        Gets the transition direction.
        Returns:
        The transition direction: 1 = forward, 0 = automatic (default), -1 = backward.
      • 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 UIContainer
        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.
      • onPrepare

        protected void onPrepare​(ClassReference cr,
                                 java.util.List<java.lang.Throwable> errors)
        Called to resolve methods for the component from main "onPrepare" once the ClassReference has been found.

        Components should override this method to load it's required methods.

        Overrides:
        onPrepare in class UIComp
        Parameters:
        cr - The class reference with a valid reference.
        errors - The list of errors that is returned to the caller in case resolving fails.
      • getOnUISelectionMethod

        public java.lang.reflect.Method getOnUISelectionMethod()
        Returns the method to use for onUISelection notifications that is attached to this selection component. The method name is not important, but must have the annotation and signature:

        @OnUISelection(name = "some/property")
        public void onUISelection(UISelectionEvent event)

        Specified by:
        getOnUISelectionMethod in interface IUISelectionComp
        Returns:
        The method, or null if none is registered.