Class RecentFilesHandler<M>

    • Field Detail

      • RECENTFILES_COUNT

        public static final String RECENTFILES_COUNT
        the property for storing the number of recent files.
        See Also:
        Constant Field Values
      • RECENTFILES_PREFIX

        public static final String RECENTFILES_PREFIX
        the property prefix for a recent file.
        See Also:
        Constant Field Values
      • m_MinNumParentDirs

        protected int m_MinNumParentDirs
        the minimum number of parent directories to use.
    • Constructor Detail

      • RecentFilesHandler

        public RecentFilesHandler​(String propsFile,
                                  M menu)
        Initializes the handler with a maximum of 5 items.
        Parameters:
        propsFile - the props file to store the files in
        menu - the menu to add the recent files as subitems to
      • RecentFilesHandler

        public RecentFilesHandler​(String propsFile,
                                  int maxCount,
                                  M menu)
        Initializes the handler.
        Parameters:
        propsFile - the props file to store the files in
        maxCount - the maximum number of files to keep in menu
        menu - the menu to add the recent files as subitems to
      • RecentFilesHandler

        public RecentFilesHandler​(String propsFile,
                                  String propPrefix,
                                  int maxCount,
                                  M menu)
        Initializes the handler.
        Parameters:
        propsFile - the props file to store the files in
        propPrefix - the properties prefix, use null to ignore
        maxCount - the maximum number of files to keep in menu
        menu - the menu to add the recent files as subitems to
    • Method Detail

      • check

        protected boolean check​(File item)
        Checks the item after obtaining from the props file.

        File must exist.
        Overrides:
        check in class AbstractRecentItemsHandler<M,​File>
        Parameters:
        item - the item to check
        Returns:
        true if checks passed
      • determineMinimumNumberOfParentDirs

        protected int determineMinimumNumberOfParentDirs()
        Determines the minimum number of parent directories that need to be included in the filename to make the filenames in the menu distinguishable.
        Returns:
        the minimum number of parent directories, -1 means full path
      • toString

        protected String toString​(File obj)
        Turns an object into a string for storing in the props.
        Specified by:
        toString in class AbstractRecentItemsHandler<M,​File>
        Parameters:
        obj - the object to convert
        Returns:
        the string representation
      • fromString

        protected File fromString​(String s)
        Turns the string obtained from the props into an object again.
        Specified by:
        fromString in class AbstractRecentItemsHandler<M,​File>
        Parameters:
        s - the string representation
        Returns:
        the parsed object
      • createMenuItemText

        protected String createMenuItemText​(int index,
                                            File item)
        Generates the text for the menuitem.
        Specified by:
        createMenuItemText in class AbstractRecentItemsHandler<M,​File>
        Parameters:
        index - the index of the item
        item - the item itself
        Returns:
        the generated text