Package adams.gui.core
Class RecentFilesHandlerWithCommandline<M>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.gui.core.AbstractRecentItemsHandler<M,RecentFilesHandlerWithCommandline.Setup>
-
- adams.gui.core.RecentFilesHandlerWithCommandline<M>
-
- All Implemented Interfaces:
LoggingSupporter
,SizeOfHandler
,Serializable
public class RecentFilesHandlerWithCommandline<M> extends AbstractRecentItemsHandler<M,RecentFilesHandlerWithCommandline.Setup>
Recent files handler that stores a commandline alongside the file.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RecentFilesHandlerWithCommandline.Setup
Container class for storing file and optionhandler alongside.
-
Field Summary
Fields Modifier and Type Field Description protected int
m_MinNumParentDirs
the minimum number of parent directories to use.static String
RECENTFILES_COUNT
the property for storing the number of recent files.static String
RECENTFILES_PREFIX
the property prefix for a recent file.-
Fields inherited from class adams.gui.core.AbstractRecentItemsHandler
m_AddShortcuts, m_IgnoreChanges, m_Listeners, m_MaxCount, m_Menu, m_PropertiesFile, m_PropertyPrefix, m_RecentItems
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description RecentFilesHandlerWithCommandline(String propsFile, int maxCount, M menu)
Initializes the handler.RecentFilesHandlerWithCommandline(String propsFile, String propPrefix, int maxCount, M menu)
Initializes the handler.RecentFilesHandlerWithCommandline(String propsFile, M menu)
Initializes the handler with a maximum of 5 items.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
check(RecentFilesHandlerWithCommandline.Setup item)
Checks the item after obtaining from the props file.protected String
createMenuItemText(int index, RecentFilesHandlerWithCommandline.Setup item)
Generates the text for the menuitem.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.protected RecentFilesHandlerWithCommandline.Setup
fromString(String s)
Turns the string obtained from the props into an object again.protected String
getCountKey()
Returns the key to use for the counts in the props file.protected String
getItemPrefix()
Returns the key prefix to use for the items in the props file.protected void
preUpdateMenu()
Hook method which gets executed just before updating the menu.protected String
toString(RecentFilesHandlerWithCommandline.Setup obj)
Turns an object into a string for storing in the props.-
Methods inherited from class adams.gui.core.AbstractRecentItemsHandler
addRecentItem, addRecentItemListener, doUpdateMenu, expand, getAddShortcuts, getMaxCount, getMenu, getPropertiesFile, getPropertyPrefix, getRecentItems, loadProps, notifyRecentItemListenersOfAdd, notifyRecentItemListenersOfSelect, postUpdateMenu, readProps, removeAll, removeRecentItem, removeRecentItemListener, setAddShortcuts, size, updateMenu, writeProps
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
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
-
RecentFilesHandlerWithCommandline
public RecentFilesHandlerWithCommandline(String propsFile, M menu)
Initializes the handler with a maximum of 5 items.- Parameters:
propsFile
- the props file to store the files inmenu
- the menu to add the recent files as subitems to
-
RecentFilesHandlerWithCommandline
public RecentFilesHandlerWithCommandline(String propsFile, int maxCount, M menu)
Initializes the handler.- Parameters:
propsFile
- the props file to store the files inmaxCount
- the maximum number of files to keep in menumenu
- the menu to add the recent files as subitems to
-
RecentFilesHandlerWithCommandline
public RecentFilesHandlerWithCommandline(String propsFile, String propPrefix, int maxCount, M menu)
Initializes the handler.- Parameters:
propsFile
- the props file to store the files inpropPrefix
- the properties prefix, use null to ignoremaxCount
- the maximum number of files to keep in menumenu
- the menu to add the recent files as subitems to
-
-
Method Detail
-
check
protected boolean check(RecentFilesHandlerWithCommandline.Setup item)
Checks the item after obtaining from the props file.
File must exist and handler not null.- Overrides:
check
in classAbstractRecentItemsHandler<M,RecentFilesHandlerWithCommandline.Setup>
- Parameters:
item
- the item to check- Returns:
- true if checks passed
- See Also:
RecentFilesHandlerWithCommandline.Setup.check()
-
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
-
getCountKey
protected String getCountKey()
Returns the key to use for the counts in the props file.- Specified by:
getCountKey
in classAbstractRecentItemsHandler<M,RecentFilesHandlerWithCommandline.Setup>
- Returns:
- the key
-
getItemPrefix
protected String getItemPrefix()
Returns the key prefix to use for the items in the props file.- Specified by:
getItemPrefix
in classAbstractRecentItemsHandler<M,RecentFilesHandlerWithCommandline.Setup>
- Returns:
- the prefix
-
toString
protected String toString(RecentFilesHandlerWithCommandline.Setup obj)
Turns an object into a string for storing in the props.- Specified by:
toString
in classAbstractRecentItemsHandler<M,RecentFilesHandlerWithCommandline.Setup>
- Parameters:
obj
- the object to convert- Returns:
- the string representation
-
fromString
protected RecentFilesHandlerWithCommandline.Setup fromString(String s)
Turns the string obtained from the props into an object again.- Specified by:
fromString
in classAbstractRecentItemsHandler<M,RecentFilesHandlerWithCommandline.Setup>
- Parameters:
s
- the string representation- Returns:
- the parsed object
-
preUpdateMenu
protected void preUpdateMenu()
Hook method which gets executed just before updating the menu.- Overrides:
preUpdateMenu
in classAbstractRecentItemsHandler<M,RecentFilesHandlerWithCommandline.Setup>
-
createMenuItemText
protected String createMenuItemText(int index, RecentFilesHandlerWithCommandline.Setup item)
Generates the text for the menuitem.- Specified by:
createMenuItemText
in classAbstractRecentItemsHandler<M,RecentFilesHandlerWithCommandline.Setup>
- Parameters:
index
- the index of the itemitem
- the item itself- Returns:
- the generated text
-
-