org.pietschy.command.file
Class AbstractRecentFileGroup
- CommandManagerListener, EventListener
public abstract class AbstractRecentFileGroup
Provides a custom group implementation that manages a list of recently used files. Subclasses
must override
openFile(File)
and implement the required behaviour.
The group also includes a command for clearing the list. The text for the clear command is
configured from the
clear-text property of the group. If the property isn't defined, the
value
Clear will be used. The clear command is hidden by default, to make it visible
simply call
getClearCommand()
.setVisible(true);
The methods
store(java.util.prefs.Preferences)
and
load(java.util.prefs.Preferences)
are
also provided to allow easy persistence of the groups file list.
void | add(File file) - Adds a file to the list.
|
void | addAll(File[] files) - Adds all the specified files to the list.
|
protected KeyStroke | getAcceleratorForIndex(int index)
|
int | getAcceleratorModifiers() - Gets the modifiers that are used to create the accelerators.
|
ActionCommand | getClearCommand() - Gets the ActionCommand that clears the files from the group.
|
protected org.pietschy.command.file.AbstractRecentFileGroup.OpenCommand | getCommandFor(File file) - Gets the command that opens the specified file.
|
int | getDisplaySize() - Gets the number of files the group will display at any one time.
|
File[] | getExcludedFile() - Gets the file that is currently excluded from the list or null if all the
files are included.
|
File[] | getFiles() - Gets all files in the group.
|
boolean | isAccelerated() - Checks if the list will have accelerator for each entry.
|
boolean | isIncludeNonExistentFiles() - Checks if the group should include files for which
java.io.File.exists() returns
false.
|
void | load(Preferences prefs) - Loads the groups file list from the specified preference node.
|
abstract void | openFile(File file) - Called to open the selected file.
|
void | refresh()
|
void | setAccelerated(boolean accelerated) - Configures the group to installFace accelerators for the list.
|
void | setAcceleratorModifiers(int acceleratorModifiers) - Sets the modifiers that are used to create the accelerators.
|
void | setDisplaySize(int displaySize) - Configures the number of files to display in the group.
|
void | setExcludedFile(File excludedFile) - Sets the file to exclude from the list.
|
void | setExcludedFiles(File[] excludedFiles) - Sets the file to exclude from the list.
|
void | setIncludeNonExistentFiles(boolean includeNonExistentFiles) - Configures if the group should include files for which
java.io.File.exists() returns
false.
|
void | store(Preferences prefs) - Stores the groups file list to the specified preference node.
|
acceptVisitor , add , add , addGlue , addGlue , addGroupListener , addInline , addInline , addSeparator , addSeparator , bindMembers , bindMembers , commandRegistered , contains , createButton , createButton , createMenuBar , createMenuBar , createMenuBar , createMenuBar , createMenuItem , createPopupMenu , createPopupMenu , createToolBar , createToolBar , createToolBar , createToolBar , fireMembersChanged , getMemberCount , getMemberFactory , getMemberList , isAllowableMember , isInlineMember , isMember , rebuildAllPopups , remove , remove , removeGroupListener , reset , reset , visit , visitChildren |
addFace , addHoverListener , addNewFace , addNotify , addPropertyChangeListener , addPropertyChangeListener , attach , buttonIterator , configureButtonAppearance , configureButtonAppearances , configureButtonAppearances , configureButtonStates , createButton , createButton , createButton , createButton , createMenuItem , createMenuItem , createMenuItem , createMenuItem , detach , export , faceExists , fireHoverEnded , fireHoverStarted , getAccelerator , getAlternativeFaceNames , getButtonFactory , getButtonIn , getCommandManager , getDefaultFace , getDefaultFace , getDescription , getFace , getFace , getIcon , getId , getLongDescription , getMenuFactory , getMnemonic , getMnemonicIndex , getProperty , getProperty , getPropertyNames , getSelectedIcon , getText , getTextPosition , getToolbarFactory , initCommandManager , installFace , isAnonymous , isAttachedTo , isEnabled , isVisible , putProperty , removeHoverListener , removeNotify , removePropertyChangeListener , removePropertyChangeListener , requestFocusIn , setAccelerator , setButtonFactory , setDescription , setEnabled , setIcon , setLongDescription , setMenuFactory , setMnemonic , setMnemonicIndex , setSelectedIcon , setText , setTextPosition , setToolbarFactory , setVisible , toString |
AbstractRecentFileGroup
protected AbstractRecentFileGroup(String id)
Constructs a new group with the specified Id that is bound to the default command manager.
id
- the id of the group.
AbstractRecentFileGroup
public AbstractRecentFileGroup(CommandManager commandManager)
Creates a new anonymous group.
AbstractRecentFileGroup
public AbstractRecentFileGroup(CommandManager commandManager,
String id)
Creates a new group with the specified id.
commandManager
- the CommandManager
to which the group will belong.id
- the commands id.
add
public void add(File file)
Adds a file to the list. The file will be added to the start of the list (in the most recent
position). If the file is already in the list it will be moved to the start.
file
- the file to add to the list.
addAll
public void addAll(File[] files)
Adds all the specified files to the list. The files are added to the start of the list
such that file[0] will be the first entry and files[files.length - 1] will proceed any
existing files. If any file is already in the list it will be moved to the new position.
files
- the files to add to the list.
getAcceleratorForIndex
protected KeyStroke getAcceleratorForIndex(int index)
getAcceleratorModifiers
public int getAcceleratorModifiers()
Gets the modifiers that are used to create the accelerators. This defaults to
java.awt.Toolkit.getMenuShortcutKeyMask()
.
- the modifiers that are used to create the accelerators.
getClearCommand
public ActionCommand getClearCommand()
Gets the ActionCommand that clears the files from the group.
- the ActionCommand that clears the files from the group.
getCommandFor
protected org.pietschy.command.file.AbstractRecentFileGroup.OpenCommand getCommandFor(File file)
Gets the command that opens the specified file.
file
- the file of interest.
- the command that will open the specified file, or null if the file isn't
in the list.
getDisplaySize
public int getDisplaySize()
Gets the number of files the group will display at any one time.
- the number of files the group will display at any one time
getExcludedFile
public File[] getExcludedFile()
Gets the file that is currently excluded from the list or null if all the
files are included.
- the file that is currently excluded from the list or null if all the
files are included.
getFiles
public File[] getFiles()
Gets all files in the group. The number of files may exceed the number displayed by
the group.
- all the files in the group.
isAccelerated
public boolean isAccelerated()
Checks if the list will have accelerator for each entry.
- true if the list will have accelerator for each entry, false
otherwise.
isIncludeNonExistentFiles
public boolean isIncludeNonExistentFiles()
Checks if the group should include files for which java.io.File.exists()
returns
false. The default value is false.
- true if the group is including non existant files, false otherwise.
load
public void load(Preferences prefs)
Loads the groups file list from the specified preference node.
prefs
- the preference node in which to retrieve the groups file list.
store(java.util.prefs.Preferences)
openFile
public abstract void openFile(File file)
Called to open the selected file. Subclasses must implement this method to provide
the file open behaviour.
file
- the file to be opened.
refresh
public void refresh()
setAccelerated
public void setAccelerated(boolean accelerated)
Configures the group to installFace accelerators for the list.
accelerated
- true to display accelerators, false to ommit them.
setAcceleratorModifiers
public void setAcceleratorModifiers(int acceleratorModifiers)
Sets the modifiers that are used to create the accelerators. This defaults to
java.awt.Toolkit.getMenuShortcutKeyMask()
.
acceleratorModifiers
- the modifiers that are used to create the accelerators.
setDisplaySize
public void setDisplaySize(int displaySize)
Configures the number of files to display in the group.
displaySize
- the number of files to display in the group.
setExcludedFile
public void setExcludedFile(File excludedFile)
Sets the file to exclude from the list. This typically used to exclude the file currently
being edited by the application. If set to null, all files will be included in the
list.
excludedFile
- the file to exclude from the list, or null.
setExcludedFiles
public void setExcludedFiles(File[] excludedFiles)
Sets the file to exclude from the list. This typically used to exclude the file currently
being edited by the application. If set to null, all files will be included in the
list.
excludedFiles
- the file to exclude from the list, or null.
setIncludeNonExistentFiles
public void setIncludeNonExistentFiles(boolean includeNonExistentFiles)
Configures if the group should include files for which java.io.File.exists()
returns
false. The default value is false.
includeNonExistentFiles
- true if the group is to include non existant files,
false otherwise.
store
public void store(Preferences prefs)
throws BackingStoreException
Stores the groups file list to the specified preference node.
prefs
- the preference node in which to save the groups file list.
load(java.util.prefs.Preferences)