Package adams.core
Class AbstractFileBasedHistory<T extends File>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.AbstractHistory<T>
-
- adams.core.AbstractPersistentHistory<T>
-
- adams.core.AbstractFileBasedHistory<T>
-
- All Implemented Interfaces:
LoggingSupporter
,SizeOfHandler
,Serializable
- Direct Known Subclasses:
FileHistory
,PlaceholderDirectoryHistory
,PlaceholderFileHistory
public abstract class AbstractFileBasedHistory<T extends File> extends AbstractPersistentHistory<T>
History for file objects.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
m_MinNumParentDirs
the minimum number of parent directories to use.-
Fields inherited from class adams.core.AbstractPersistentHistory
m_HistoryFile
-
Fields inherited from class adams.core.AbstractHistory
m_History, MAX_HISTORY_COUNT, MAX_HISTORY_LENGTH
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractFileBasedHistory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected T
copy(T obj)
Creates a copy of the object.void
customizePopupMenu(JPopupMenu menu, Object current, HistorySelectionListener listener)
Adds a menu item with the history to the popup menu.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 String
generateMenuItemCaption(T obj)
Generates an HTML caption for the an entry in the history menu.protected boolean
load()
Loads the history from disk.protected abstract T
newInstance(String path)
Creates a new file object from the string.protected boolean
save()
Saves the history to disk.-
Methods inherited from class adams.core.AbstractPersistentHistory
add, clear, getHistoryFile, initialize, setHistoryFile
-
Methods inherited from class adams.core.AbstractHistory
getHistory, size
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Method Detail
-
newInstance
protected abstract T newInstance(String path)
Creates a new file object from the string.- Parameters:
path
- the path to create the object from
-
copy
protected T copy(T obj)
Creates a copy of the object.- Specified by:
copy
in classAbstractHistory<T extends File>
- Parameters:
obj
- the object to copy
-
save
protected boolean save()
Saves the history to disk.- Specified by:
save
in classAbstractPersistentHistory<T extends File>
- Returns:
- true if successfully saved
-
load
protected boolean load()
Loads the history from disk.- Specified by:
load
in classAbstractPersistentHistory<T extends File>
- Returns:
- true if successfully loaded
-
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
-
generateMenuItemCaption
protected String generateMenuItemCaption(T obj)
Generates an HTML caption for the an entry in the history menu.- Parameters:
obj
- the object to create the caption for- Returns:
- the generated HTML captiopn
-
customizePopupMenu
public void customizePopupMenu(JPopupMenu menu, Object current, HistorySelectionListener listener)
Adds a menu item with the history to the popup menu.- Parameters:
menu
- the menu to add the history tocurrent
- the current objectlistener
- the listener to attach to the menu items' ActionListener
-
-