Class CtxMenuManager


  • public class CtxMenuManager
    extends java.lang.Object
    This manager provides a way to generate dynamically letters for specific new entries in contextual menus. Its provides also convenient methods to insert letters at the good place in ctx menu letters array.
    Since:
    jcms-6.1.0
    Author:
    dissert
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      char[] addEntry​(char[] letters, java.lang.Object id, char c, boolean after)
      Create a new char array with the letter associated to this id the place after or before the one of the letter c.
      char[] addEntry​(char[] letters, java.lang.Object id, int index)
      Create a new char array with the letter associated to this id at the given index.
      char[] addEntry​(char[] letters, java.lang.Object id, java.lang.Object idPreviousEntry, boolean after)
      Create a new char array with the letter associated to this id the place after or before the one of the letter bounds to the idPreviousEntry.
      char[] addEntryAtBottom​(char[] letters, java.lang.Object id)
      Create a new char array with the letter associated to this id at the end.
      char[] addEntryAtTop​(char[] letters, java.lang.Object id)
      Create a new char array with the letter associated to this id at the top.
      char createMenuEntry​(java.lang.Object id, java.lang.Class<? extends AbstractCtxMenu> ctxMenuClazz)
      Retrieve or create a letter and associates it with the id for this ctx menu.
      static CtxMenuManager getInstance()  
      boolean isCurrent​(java.lang.Object id, char letter)
      Tell if the given id corresponds to the given letter in the menu.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • createMenuEntry

        public char createMenuEntry​(java.lang.Object id,
                                    java.lang.Class<? extends AbstractCtxMenu> ctxMenuClazz)
        Retrieve or create a letter and associates it with the id for this ctx menu.
        Parameters:
        id - an object to handle the new entry
        ctxMenuClazz - the given ctx menu
        Returns:
        the letter that will be used in for this entry
      • isCurrent

        public boolean isCurrent​(java.lang.Object id,
                                 char letter)
        Tell if the given id corresponds to the given letter in the menu.
        Parameters:
        id -
        letter -
        Returns:
        true if the letter is bounds to this id
      • addEntryAtBottom

        public char[] addEntryAtBottom​(char[] letters,
                                       java.lang.Object id)
        Create a new char array with the letter associated to this id at the end.
        Parameters:
        letters - the previous char array
        id -
        Returns:
        a new char array
      • addEntryAtTop

        public char[] addEntryAtTop​(char[] letters,
                                    java.lang.Object id)
        Create a new char array with the letter associated to this id at the top.
        Parameters:
        letters - the previous char array
        id -
        Returns:
        a new char array
      • addEntry

        public char[] addEntry​(char[] letters,
                               java.lang.Object id,
                               int index)
        Create a new char array with the letter associated to this id at the given index.
        Parameters:
        letters - the previous char array
        id -
        index - the index (from 0 to letters.length) of the new letter
        Returns:
        a new char array
      • addEntry

        public char[] addEntry​(char[] letters,
                               java.lang.Object id,
                               char c,
                               boolean after)
        Create a new char array with the letter associated to this id the place after or before the one of the letter c.
        Parameters:
        letters - the previous char array
        id -
        c - the letter
        after - to place the new entry after the previous one (otherwise, before)
        Returns:
        a new char array
      • addEntry

        public char[] addEntry​(char[] letters,
                               java.lang.Object id,
                               java.lang.Object idPreviousEntry,
                               boolean after)
        Create a new char array with the letter associated to this id the place after or before the one of the letter bounds to the idPreviousEntry.
        Parameters:
        letters - the previous char array
        id -
        idPreviousEntry - the id that bounds to the letter
        after - to place the new entry after the previous one (otherwise, before)
        Returns:
        a new char array