Package org.apache.pivot.wtk
Class FileBrowser
- java.lang.Object
-
- org.apache.pivot.wtk.Component
-
- org.apache.pivot.wtk.Container
-
- org.apache.pivot.wtk.FileBrowser
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
FileBrowser.Skin
File browser skin interface.-
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Container
Container.EDTChecker
-
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Component
Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
-
Nested classes/interfaces inherited from interface org.apache.pivot.collections.Sequence
Sequence.Tree<T>
-
-
Constructor Summary
Constructors Constructor Description FileBrowser()
Creates a new FileBrowser with the root directory set to the"user.home"
value.FileBrowser(java.io.File initialRootDirectory)
Creates a new FileBrowserFileBrowser(java.lang.String rootDirectoryName)
Creates a new FileBrowser
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addSelectedFile(java.io.File file)
Adds a file to the file selection.void
clearSelection()
Clears the selection.Filter<java.io.File>
getDisabledFileFilter()
Returns the current file filter.java.io.File
getFileAt(int x, int y)
Call the skin and return the file at the given position.ListenerList<FileBrowserListener>
getFileBrowserListeners()
java.io.File
getRootDirectory()
java.io.File
getSelectedFile()
When in single-select mode, returns the currently selected file.ImmutableList<java.io.File>
getSelectedFiles()
Returns the currently selected files.boolean
isFileSelected(java.io.File file)
boolean
isMultiSelect()
boolean
removeSelectedFile(java.io.File file)
Removes a file from the file selection.void
setDisabledFileFilter(Filter<java.io.File> disabledFilter)
Sets the file filter.void
setMultiSelect(boolean selectState)
Sets the file browser's multi-select state.void
setRootDirectory(java.io.File rootDir)
Sets the root directory.void
setSelectedFile(java.io.File file)
Sets the selection to a single file.Sequence<java.io.File>
setSelectedFiles(Sequence<java.io.File> files)
Sets the selected files.-
Methods inherited from class org.apache.pivot.wtk.Container
add, assertEventDispatchThread, assertEventDispatchThread, clear, containsFocus, descendantAdded, descendantGainedFocus, descendantLostFocus, descendantRemoved, get, getComponentAt, getContainerListeners, getContainerMouseListeners, getDescendantAt, getFocusTraversalPolicy, getGraphics, getLength, getNamedComponent, indexOf, insert, invalidate, isAncestor, isDoubleBuffered, iterator, layout, load, mouseClick, mouseDown, mouseMove, mouseOut, mouseUp, mouseWheel, move, paint, remove, remove, removeAll, repaint, requestFocus, setDoubleBuffered, setEventDispatchThreadChecker, setFocusTraversalPolicy, setParent, setVisible, store, transferFocus, update
-
Methods inherited from class org.apache.pivot.wtk.Component
checkSkin, clearFocus, contains, copyStyle, copyStyle, getAncestor, getAncestor, getAttribute, getAutomationID, getBaseline, getBaseline, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentKeyListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponentStateListeners, getComponentStyleListeners, getComponentTooltipListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getHeight, getHeightLimits, getLocation, getMaximumHeight, getMaximumWidth, getMenuHandler, getMinimumHeight, getMinimumWidth, getMouseLocation, getName, getNamedStyles, getParent, getPreferredHeight, getPreferredHeight, getPreferredSize, getPreferredWidth, getPreferredWidth, getScreenBounds, getSize, getSkin, getStyle, getStyle, getStyleBoolean, getStyleBoolean, getStyleColor, getStyleColor, getStyleFont, getStyleFont, getStyleInt, getStyleInt, getStyles, getTextInputMethodListener, getTooltipDelay, getTooltipText, getTooltipWrapText, getTypedStyles, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWidthLimits, getWindow, getX, getY, indexBoundsCheck, installSkin, isBlocked, isEnabled, isFocusable, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, mapPointFromAncestor, mapPointFromAncestor, mapPointToAncestor, mapPointToAncestor, mouseOver, offsetToScreen, putStyle, putStyle, reenterMouse, repaint, repaint, repaint, repaint, repaint, scrollAreaToVisible, scrollAreaToVisible, setAttribute, setAutomationID, setAutomationID, setCursor, setDragSource, setDropTarget, setEnabled, setFocused, setHeight, setHeightLimits, setHeightLimits, setLocation, setLocation, setMaximumHeight, setMaximumWidth, setMenuHandler, setMinimumHeight, setMinimumWidth, setName, setPreferredHeight, setPreferredSize, setPreferredSize, setPreferredWidth, setSize, setSize, setSkin, setStyleName, setStyleNames, setStyleNames, setStyles, setStyles, setTooltipDelay, setTooltipText, setTooltipWrapText, setWidth, setWidthLimits, setWidthLimits, setX, setY, toString, transferFocus, validate
-
-
-
-
Constructor Detail
-
FileBrowser
public FileBrowser()
Creates a new FileBrowser with the root directory set to the"user.home"
value.Note that this version sets the mode to "open".
-
FileBrowser
public FileBrowser(java.lang.String rootDirectoryName)
Creates a new FileBrowserNote that this version of the constructor must be used when a custom root directory has to be set.
- Parameters:
rootDirectoryName
- The root directory full name.
-
FileBrowser
public FileBrowser(java.io.File initialRootDirectory)
Creates a new FileBrowserNote that this version of the constructor must be used when a custom root directory has to be set.
- Parameters:
initialRootDirectory
- The initial root directory.
-
-
Method Detail
-
getRootDirectory
public java.io.File getRootDirectory()
- Returns:
- The current root directory.
-
setRootDirectory
public void setRootDirectory(java.io.File rootDir)
Sets the root directory. Clears any existing file selection.- Parameters:
rootDir
- The new root directory to browse in.- Throws:
java.lang.IllegalArgumentException
- if the argument isnull
or is not a directory.
-
addSelectedFile
public boolean addSelectedFile(java.io.File file)
Adds a file to the file selection.- Parameters:
file
- The new file to add to the selection.- Returns:
true
if the file was added;false
if it was already selected.- Throws:
java.lang.IllegalArgumentException
- if the file argument isnull
or if the file is not in the current root directory.
-
removeSelectedFile
public boolean removeSelectedFile(java.io.File file)
Removes a file from the file selection.- Parameters:
file
- The previously selected file to be removed from the selection.- Returns:
true
if the file was removed;false
if it was not already selected.- Throws:
java.lang.IllegalArgumentException
- if the file argument isnull
.
-
getSelectedFile
public java.io.File getSelectedFile()
When in single-select mode, returns the currently selected file.- Returns:
- The currently selected file.
-
setSelectedFile
public void setSelectedFile(java.io.File file)
Sets the selection to a single file.- Parameters:
file
- The only file to select, ornull
to select nothing.
-
getSelectedFiles
public ImmutableList<java.io.File> getSelectedFiles()
Returns the currently selected files.- Returns:
- An immutable list containing the currently selected files. Note that the returned list is a wrapper around the actual selection, not a copy. Any changes made to the selection state will be reflected in the list, but events will not be fired.
-
setSelectedFiles
public Sequence<java.io.File> setSelectedFiles(Sequence<java.io.File> files)
Sets the selected files.- Parameters:
files
- The files to select.- Returns:
- The files that were selected, with duplicates eliminated.
- Throws:
java.lang.IllegalArgumentException
- if the selected files sequence isnull
or if the sequence is longer than one file and multi-select is not enabled, or if any entry is the sequence isnull
or whose parent is not the current root directory.
-
clearSelection
public void clearSelection()
Clears the selection.
-
isFileSelected
public boolean isFileSelected(java.io.File file)
- Parameters:
file
- The file to test.- Returns:
- Whether or not the given file is selected.
-
isMultiSelect
public boolean isMultiSelect()
- Returns:
- The file browser's multi-select state.
-
setMultiSelect
public void setMultiSelect(boolean selectState)
Sets the file browser's multi-select state.- Parameters:
selectState
-true
if multi-select is enabled;false
, otherwise.
-
getDisabledFileFilter
public Filter<java.io.File> getDisabledFileFilter()
Returns the current file filter.- Returns:
- The current file filter, or
null
if no filter is set.
-
setDisabledFileFilter
public void setDisabledFileFilter(Filter<java.io.File> disabledFilter)
Sets the file filter.- Parameters:
disabledFilter
- The file filter to use, ornull
for no filter.
-
getFileAt
public java.io.File getFileAt(int x, int y)
Call the skin and return the file at the given position.- Parameters:
x
- The mouse X-position.y
- The mouse Y-position.- Returns:
- The file displayed at those coordinates.
-
getFileBrowserListeners
public ListenerList<FileBrowserListener> getFileBrowserListeners()
- Returns:
- The file browser listeners.
-
-