Class TabViewActions


  • public final class TabViewActions
    extends Object
    Actions operating on a TabViewModel.
    Since:
    7.0.0
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • addTab

        public static TabModel addTab​(TabViewModel model,
                                      String tabId)
        Opens the given tab, adding it to the topbar menu.
        Parameters:
        model - Model to operate on.
        tabId - ID of the Tab to add.
        Returns:
        The tab with the given ID, or null when not such tab exists.
      • closeTab

        public static TabSwitchResult closeTab​(TabViewModel model,
                                               TabModel tab)
        Close the given tab, removing it from the topbar menu.
        Parameters:
        model - Model to operate on.
        tab - Tab to remove.
        Returns:
        Whether the current tab was switched.
      • computeActiveTab

        public static TabModel computeActiveTab​(TabViewModel model)
        Parameters:
        model - Model to operate on.
        Returns:
        The tab representing the currently active tab model.
      • computeAvailableTabs

        public static List<TabModel> computeAvailableTabs​(TabViewModel model)
        Parameters:
        model - Model to operate on.
        Returns:
        A list of all available tabs.
      • computeExtraTopMenuEntriesForActiveTab

        public static String computeExtraTopMenuEntriesForActiveTab​(TabViewModel model)
        Parameters:
        model - Model to operate on.
        Returns:
        XHTML page with the extra top menu items of the active tab.
      • computeIsHasMoreTabMenuEntries

        public static boolean computeIsHasMoreTabMenuEntries​(TabViewModel model)
        Parameters:
        model - Model to operate on.
        Returns:
        Whether any more tabs can be added to the menu bar.
      • computeMoreTabIds

        public static Set<String> computeMoreTabIds​(TabViewModel model)
        Parameters:
        model - Model to operate on.
        Returns:
        A set of all tab IDs corresponding to the tabs that can be added.
      • computeMoreTabMenuEntries

        public static org.primefaces.model.menu.MenuModel computeMoreTabMenuEntries​(TabViewModel model)
        Parameters:
        model - Model to operate on.
        Returns:
        A menu model entry with the tab that can be added.
      • computeOverlayStyleClass

        public static String computeOverlayStyleClass​(TabViewModel model,
                                                      TabModel tab)
        Parameters:
        model - Model to operate on.
        tab - An existing tab.
        Returns:
        The style class for the error overlay of the given tab in the main content area.
      • computeTabMenuCloseIconStyleClass

        public static String computeTabMenuCloseIconStyleClass​(TabViewModel model,
                                                               TabModel tab)
        Parameters:
        model - Model to operate on.
        tab - An existing tab.
        Returns:
        The style class for the close icon of the given tab in the main content area.
      • computeTabMenuItems

        public static List<TabModel> computeTabMenuItems​(TabViewModel model)
        Parameters:
        model - Model to operate on.
        Returns:
        All tabs currently shown in the top menu bar.
      • computeTabMenuStyleClass

        public static String computeTabMenuStyleClass​(TabViewModel model,
                                                      TabModel tab)
        Parameters:
        model - Model to operate on.
        tab - An existing tab.
        Returns:
        The style class for the menu entry of the given tab in the topbar menu.
      • computeTabStyleClass

        public static String computeTabStyleClass​(TabViewModel model,
                                                  TabModel tab)
        Parameters:
        model - Model to operate on.
        tab - An existing tab.
        Returns:
        The style class for the iframe of the given tab in the main content area.
      • findAvailableTabBy

        public static TabModel findAvailableTabBy​(TabViewModel model,
                                                  EContentView contentView)
        Parameters:
        model - Model to operate on.
        contentView - Content view to search for.
        Returns:
        The tab for the given content view (whether open or closed), or null if no such tab exists.
      • isAnyTabShownInTopMenu

        public static boolean isAnyTabShownInTopMenu​(TabViewModel model)
        Parameters:
        model - Model to operate on.
        Returns:
        Whether any tab is shown in the top menu, regardless of whether is is opened.
      • isAnyTabVisible

        public static boolean isAnyTabVisible​(TabViewModel model)
        Parameters:
        model - Model to operate on.
        Returns:
        true if any tab is shown, false if no tab is shown.
      • isTabClosed

        public static boolean isTabClosed​(TabViewModel model,
                                          EContentView contentView)
        Parameters:
        model - Model to operate on.
        contentView - Content view to check.
        Returns:
        Whether the tab corresponding to the content view is currently close (e.g. its iframe / DOM element / browser tab does not exist).
      • isTabClosed

        public static boolean isTabClosed​(TabViewModel model,
                                          String tabId)
        Parameters:
        model - Model to operate on.
        tabId - ID of the tab to check.
        Returns:
        Whether the tab corresponding to the content view is currently close (e.g. its iframe / DOM element / browser tab does not exist).
      • isTabOpen

        public static boolean isTabOpen​(TabViewModel model,
                                        EContentView contentView)
        Parameters:
        model - Model to operate on.
        contentView - Content view to check.
        Returns:
        Whether the tab corresponding to the content view is currently opened (e.g. its iframe / DOM element / browser tab exists).
      • isTabOpen

        public static boolean isTabOpen​(TabViewModel model,
                                        String tabId)
        Parameters:
        model - Model to operate on.
        tabId - ID of the tab to check.
        Returns:
        Whether the tab corresponding to the content view is currently opened (e.g. its iframe / DOM element / browser tab exists).
      • markError

        public static TabModel markError​(TabViewModel model,
                                         String tabId,
                                         TabError error)
        Marks the given tab as erroneous, and adds the given error details.
        Parameters:
        model - Model to operate on.
        tabId - ID of an existing tab.
        error - Error to set on the tab.
        Returns:
        The tab with the given ID, or null when no such tab exists.
      • markUnsavedChanges

        public static void markUnsavedChanges​(TabViewModel model,
                                              String tabId,
                                              boolean hasUnsavedChanges)
        Sets the flag whether the given tab has unsaved changes. When a tab has unsaved changes, this is usually shown with a small asterisk next to the tab.
        Parameters:
        model - Model to operate on.
        tabId - ID of the tab to mark as having unsaved changes or not.
        hasUnsavedChanges - Whether the tab has unsaved changes.
      • showTabs

        public static void showTabs​(TabViewModel model,
                                    List<String> tabIds)
        Adds the given tabs to the list of tabs that are shown in the tab menu. The tab that is currently open is not changed.
        Parameters:
        model - Model to operate on.
        tabIds - IDs of tabs to show.
      • switchToTab

        public static boolean switchToTab​(TabViewModel model,
                                          String tabId)
        Switches to the given tab, and set TabModel.isOpen() to true.
        Parameters:
        model - Model to operate on.
        tabId - ID of a tab representing the tab to switch to.
        Returns:
        Whether the tab was switched to (i.e. whether it exists and isn't disabled).
      • switchToTab

        public static boolean switchToTab​(TabViewModel model,
                                          String tabId,
                                          boolean openNewTab)
        Switches to the given tab, and set TabModel.isOpen() to true.
        Parameters:
        model - Model to operate on.
        tabId - ID of a tab representing the tab to switch to.
        openNewTab - Whether to open a new tab if not already opened.
        Returns:
        Whether the tab was switched to (i.e. whether it exists and isn't disabled).
      • switchToTab

        public static boolean switchToTab​(TabViewModel model,
                                          String tabId,
                                          String fallbackTabId)
        Switches to the given tab, and set TabModel.isOpen() to true. When no tab with the given ID exists, switches to the fallback tab ID.
        Parameters:
        model - Model to operate on.
        tabId - ID of a tab representing the tab to switch to.
        fallbackTabId - ID of a tab representing the tab to switch to when no tab with the given tabId exists.
        Returns:
        Whether the tab was switched to (i.e. whether it exists).
      • updatePlaceholderLibraryFor

        public static void updatePlaceholderLibraryFor​(String tabId)
        Adds / removes the placeholder library groups for the given tab, which shold be the active tab.
        Parameters:
        tabId - Currently active tab ID.
      • updatePlaceholderLibraryFor

        public static void updatePlaceholderLibraryFor​(TabViewModel tabViewModel)
        Updates the placeholder library so that it shows the placeholders that are available within the context of the given tab.
        Parameters:
        tabViewModel - The model of the tab for which to update the placeholders.