de.matthiasmann.twl
Class FileSelector

java.lang.Object
  extended by de.matthiasmann.twl.Widget
      extended by de.matthiasmann.twl.DialogLayout
          extended by de.matthiasmann.twl.FileSelector

public class FileSelector
extends DialogLayout

A File selector widget using FileSystemModel


Nested Class Summary
static interface FileSelector.Callback
           
static interface FileSelector.Callback2
           
static class FileSelector.NamedFileFilter
           
static class FileSelector.NameSorter
          A file object comparator which delegates to a String comprataor to sort based on the name of the file objects.
 
Nested classes/interfaces inherited from class de.matthiasmann.twl.DialogLayout
DialogLayout.Gap, DialogLayout.Group
 
Nested classes/interfaces inherited from class de.matthiasmann.twl.Widget
Widget.OffscreenMouseAdjustments, Widget.RenderOffscreen
 
Field Summary
static FileSelector.NamedFileFilter AllFilesFilter
           
 
Fields inherited from class de.matthiasmann.twl.DialogLayout
addDefaultGaps, blockInvalidateLayoutTree, DEFAULT_GAP, defaultGap, includeInvisibleWidgets, isPrepared, LARGE_GAP, largeGap, MEDIUM_GAP, mediumGap, namedGaps, redoDefaultGaps, SMALL_GAP, smallGap, warnOnIncomplete
 
Fields inherited from class de.matthiasmann.twl.Widget
STATE_DISABLED, STATE_HAS_FOCUSED_CHILD, STATE_HAS_OPEN_POPUPS, STATE_KEYBOARD_FOCUS
 
Constructor Summary
FileSelector()
          Create a FileSelector without persistent state
FileSelector(java.util.prefs.Preferences prefs, java.lang.String prefsKey)
           
 
Method Summary
 void acceptSelection()
           
 void addCallback(FileSelector.Callback callback)
           
 void addFileFilter(FileSelector.NamedFileFilter filter)
          Adds a named file filter to the FileSelector.
protected  void afterAddToGUI(GUI gui)
          Called after this widget has been added to a GUI tree.
 void clearSelection()
           
protected  void createLayout()
           
 boolean getAllowFolderSelection()
           
 boolean getAllowHorizontalScrolling()
           
 boolean getAllowMultiSelection()
           
 java.lang.Object getCurrentFolder()
           
 FileSelector.NamedFileFilter getFileFilter()
           
 FileSystemModel getFileSystemModel()
           
 FileTable getFileTable()
           
 boolean getShowFolders()
           
 boolean getShowHidden()
           
 Widget getUserWidgetBottom()
           
 Widget getUserWidgetRight()
           
 boolean goHome()
           
 void goOneLevelUp()
           
 void removeAllFileFilters()
           
 void removeCallback(FileSelector.Callback callback)
           
 void removeFileFilter(FileSelector.NamedFileFilter filter)
           
 boolean selectFile(java.lang.Object file)
           
 void setAllowFolderSelection(boolean allowFolderSelection)
          Controls if folders can be selected.
 void setAllowHorizontalScrolling(boolean allowHorizontalScrolling)
          Controls if the file table allows horizontal scrolling or not.
 void setAllowMultiSelection(boolean allowMultiSelection)
          Controls if multi selection is allowed.
 boolean setCurrentFolder(java.lang.Object folder)
           
protected  void setCurrentNode(TreeTableNode node)
           
protected  void setCurrentNode(TreeTableNode node, TreeTableNode childToSelect)
           
 void setFileFilter(FileSelector.NamedFileFilter filter)
           
 void setFileSystemModel(FileSystemModel fsm)
           
 void setOkButtonEnabled(boolean enabled)
           
 void setShowFolders(boolean showFolders)
           
 void setShowHidden(boolean showHidden)
           
 void setUserWidgetBottom(Widget userWidgetBottom)
           
 void setUserWidgetRight(Widget userWidgetRight)
           
 
Methods inherited from class de.matthiasmann.twl.DialogLayout
addDefaultGaps, adjustSize, applyTheme, applyThemeDialogLayout, childVisibilityChanged, createParallelGroup, createParallelGroup, createParallelGroup, createSequentialGroup, createSequentialGroup, createSequentialGroup, doLayout, getDefaultGap, getHorizontalGroup, getLargeGap, getMediumGap, getMinHeight, getMinWidth, getPreferredInnerHeight, getPreferredInnerWidth, getSmallGap, getVerticalGroup, insertChild, invalidateLayout, isAddDefaultGaps, isIncludeInvisibleWidgets, layout, layoutGroupsChanged, maybeInvalidateLayoutTree, paintWidget, prepare, recheckWidgets, removeAllChildren, removeChild, removeDefaultGaps, setAddDefaultGaps, setDefaultGap, setHorizontalGroup, setIncludeInvisibleWidgets, setLargeGap, setMediumGap, setSmallGap, setVerticalGroup, setWidgetAlignment, sizeChanged
 
Methods inherited from class de.matthiasmann.twl.Widget
add, addActionMapping, addPropertyChangeListener, addPropertyChangeListener, allChildrenRemoved, applyThemeBackground, applyThemeBorder, applyThemeInputMap, applyThemeMaxSize, applyThemeMinSize, applyThemeMouseCursor, applyThemeOffscreenExtra, applyThemeOverlay, applyThemeTooltip, beforeRemoveFromGUI, borderChanged, canAcceptKeyboardFocus, childAdded, childInvalidateLayout, childRemoved, computeSize, destroy, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, focusFirstChild, focusLastChild, focusNextChild, focusPrevChild, getActionMap, getAnimationState, getBackground, getBorderBottom, getBorderHorizontal, getBorderLeft, getBorderRight, getBorderTop, getBorderVertical, getBottom, getChild, getChildAt, getChildIndex, getGUI, getHeight, getInnerBottom, getInnerHeight, getInnerRight, getInnerWidth, getInnerX, getInnerY, getInputMap, getKeyboardFocusOrder, getMaxHeight, getMaxWidth, getMouseCursor, getMouseCursor, getNumChildren, getOffscreenExtraBottom, getOffscreenExtraLeft, getOffscreenExtraRight, getOffscreenExtraTop, getOrCreateActionMap, getOverlay, getParent, getPreferredHeight, getPreferredWidth, getRenderOffscreen, getRight, getRootWidget, getTheme, getThemePath, getThemeTooltipContent, getTintAnimator, getTooltipContent, getTooltipContentAt, getWidgetAt, getWidth, getX, getY, giveupKeyboardFocus, handleEvent, handleKeyStrokeAction, hasKeyboardFocus, hasOpenPopups, hasSharedAnimationState, invalidateLayoutLocally, isAbsoluteTheme, isClip, isDepthFocusTraversal, isEnabled, isFocusKeyEnabled, isInside, isLocallyEnabled, isMouseInside, isVisible, keyboardFocusChildChanged, keyboardFocusGained, keyboardFocusGained, keyboardFocusLost, layoutChildFullInnerArea, layoutChildrenFullInnerArea, moveChild, paint, paintBackground, paintChild, paintChildren, paintDragOverlay, paintOverlay, positionChanged, reapplyTheme, removeChild, removePropertyChangeListener, removePropertyChangeListener, requestKeyboardFocus, requestKeyboardFocus, resetTooltip, setActionMap, setBackground, setBorderSize, setBorderSize, setBorderSize, setBorderSize, setCanAcceptKeyboardFocus, setClip, setDepthFocusTraversal, setEnabled, setFocusKeyEnabled, setInnerSize, setInputMap, setMaxSize, setMinSize, setMouseCursor, setOffscreenExtra, setOffscreenExtra, setOverlay, setPosition, setRenderOffscreen, setSize, setTheme, setTintAnimator, setTooltipContent, setVisible, updateTintAnimation, updateTooltip, validateLayout, widgetDisabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AllFilesFilter

public static final FileSelector.NamedFileFilter AllFilesFilter
Constructor Detail

FileSelector

public FileSelector()
Create a FileSelector without persistent state


FileSelector

public FileSelector(java.util.prefs.Preferences prefs,
                    java.lang.String prefsKey)
Method Detail

createLayout

protected void createLayout()

afterAddToGUI

protected void afterAddToGUI(GUI gui)
Description copied from class: Widget
Called after this widget has been added to a GUI tree.

Overrides:
afterAddToGUI in class DialogLayout
Parameters:
gui - the GUI object - same as getGUI()
See Also:
Widget.getGUI()

getFileSystemModel

public FileSystemModel getFileSystemModel()

setFileSystemModel

public void setFileSystemModel(FileSystemModel fsm)

getAllowMultiSelection

public boolean getAllowMultiSelection()

setAllowMultiSelection

public void setAllowMultiSelection(boolean allowMultiSelection)
Controls if multi selection is allowed. Default is true.

Parameters:
allowMultiSelection - true if multiple files can be selected.

getAllowFolderSelection

public boolean getAllowFolderSelection()

setAllowFolderSelection

public void setAllowFolderSelection(boolean allowFolderSelection)
Controls if folders can be selected. If false then the "Ok" button is disabled when a folder is selected. Default is false.

Parameters:
allowFolderSelection - true if folders can be selected

getAllowHorizontalScrolling

public boolean getAllowHorizontalScrolling()

setAllowHorizontalScrolling

public void setAllowHorizontalScrolling(boolean allowHorizontalScrolling)
Controls if the file table allows horizontal scrolling or not. Default is true.

Parameters:
allowHorizontalScrolling - true if horizontal scrolling is allowed

addCallback

public void addCallback(FileSelector.Callback callback)

removeCallback

public void removeCallback(FileSelector.Callback callback)

getUserWidgetBottom

public Widget getUserWidgetBottom()

setUserWidgetBottom

public void setUserWidgetBottom(Widget userWidgetBottom)

getUserWidgetRight

public Widget getUserWidgetRight()

setUserWidgetRight

public void setUserWidgetRight(Widget userWidgetRight)

getFileTable

public FileTable getFileTable()

setOkButtonEnabled

public void setOkButtonEnabled(boolean enabled)

getCurrentFolder

public java.lang.Object getCurrentFolder()

setCurrentFolder

public boolean setCurrentFolder(java.lang.Object folder)

selectFile

public boolean selectFile(java.lang.Object file)

clearSelection

public void clearSelection()

addFileFilter

public void addFileFilter(FileSelector.NamedFileFilter filter)
Adds a named file filter to the FileSelector. The first added file filter is selected as default.

Parameters:
filter - the file filter.
Throws:
java.lang.NullPointerException - if filter is null
See Also:
AllFilesFilter

removeFileFilter

public void removeFileFilter(FileSelector.NamedFileFilter filter)

removeAllFileFilters

public void removeAllFileFilters()

setFileFilter

public void setFileFilter(FileSelector.NamedFileFilter filter)

getFileFilter

public FileSelector.NamedFileFilter getFileFilter()

getShowFolders

public boolean getShowFolders()

setShowFolders

public void setShowFolders(boolean showFolders)

getShowHidden

public boolean getShowHidden()

setShowHidden

public void setShowHidden(boolean showHidden)

goOneLevelUp

public void goOneLevelUp()

goHome

public boolean goHome()

acceptSelection

public void acceptSelection()

setCurrentNode

protected void setCurrentNode(TreeTableNode node,
                              TreeTableNode childToSelect)

setCurrentNode

protected void setCurrentNode(TreeTableNode node)