com.alee.extended.list
Class WebFileList

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JList
                  extended by com.alee.laf.list.WebList
                      extended by com.alee.extended.list.WebFileList
All Implemented Interfaces:
FontMethods<WebList>, SizeMethods<WebList>, SwingMethods, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.Scrollable

public class WebFileList
extends WebList

Special list component that simplifies files rendering.

Author:
Mikle Garin
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JList
javax.swing.JList.AccessibleJList, javax.swing.JList.DropLocation
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.io.File displayedDirectory
          Displayed directory.
protected  java.io.FileFilter fileFilter
          File filter.
protected  FileListViewType fileListViewType
          File view mode.
protected  boolean generateThumbnails
          Whether to generate image file thumbnails or not.
protected  int preferredColumnCount
          Preferred visible column count.
protected  int preferredRowCount
          Preferred visible row count.
protected  WebScrollPane scrollView
          Scroll pane with fixed preferred size that fits file list settings.
 
Fields inherited from class com.alee.laf.list.WebList
editable, editedCell, editListeners, listCellEditor, unselectable
 
Fields inherited from class javax.swing.JList
HORIZONTAL_WRAP, VERTICAL, VERTICAL_WRAP
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
WebFileList()
          Constructs empty file list.
WebFileList(java.io.File directory)
          Constructs file list with files from the specified directory.
WebFileList(java.io.File[] data)
          Constructs file list with the specified files.
WebFileList(java.util.List<java.io.File> data)
          Constructs file list with the specified files.
WebFileList(java.lang.String directoryPath)
          Constructs file list with files from directory under the specified path.
 
Method Summary
protected  ListCellEditor createDefaultCellEditor()
          Returns default list cell editor for this list.
 WebScrollPane createScrollView()
          Returns new scroll pane with fixed preferred size that fits file list settings.
 java.io.File getDisplayedDirectory()
          Returns displayed directory.
 java.io.FileFilter getFileFilter()
          Returns file filter.
 FileListModel getFileListModel()
          Returns specific for WebFileList model.
 FileListViewType getFileListViewType()
          Returns file view mode.
 int getPreferredColumnCount()
          Returns preferred visible column count.
 int getPreferredRowCount()
          Returns preferred visible row count.
 java.awt.Dimension getPreferredSize()
          Returns preferred size for this list.
 WebScrollPane getScrollView()
          Returns scroll pane with fixed preferred size that fits file list settings.
 java.io.File getSelectedFile()
          Returns selected file.
 java.util.List<java.io.File> getSelectedFiles()
          Returns list of selected files.
 WebFileListCellRenderer getWebFileListCellRenderer()
          Returns specific for WebFileList renderer.
protected  void initializeDefaultSettings()
          Initializes default file list settings.
 boolean isGenerateThumbnails()
          Returns whether to generate image file thumbnails or not.
 void reloadFiles()
          Reloads files from displayed directory.
 void repaint(FileElement element)
          Repaints cell with specified element.
 void setDisplayedDirectory(java.io.File file)
          Sets displayed directory.
 void setFileFilter(java.io.FileFilter fileFilter)
          Sets file filter.
 void setFileListViewType(FileListViewType fileListViewType)
          Sets file view mode.
 void setGenerateThumbnails(boolean generateThumbnails)
          Sets whether to generate image file thumbnails or not.
 void setPreferredColumnCount(int preferredColumnCount)
          Sets preferred visible column count.
 void setPreferredRowCount(int preferredRowCount)
          Sets preferred visible row count.
 void setSelectedFile(java.io.File file)
          Selects specified file if it presents in the list.
 void setSelectedFile(java.io.File file, boolean shouldScroll)
          Selects specified file if it presents in the list.
 void setSelectedFiles(java.util.Collection<java.io.File> files)
          Selects specified files if they present in the list.
 
Methods inherited from class com.alee.laf.list.WebList
addListDataListener, addListEditListener, changeFontSize, editCell, editSelectedCell, fireEditCancelled, fireEditFinished, fireEditStarted, getCellEditor, getEditedCell, getFontName, getFontSize, getMinimumHeight, getMinimumWidth, getModelSize, getPreferredHeight, getPreferredWidth, getSelectionRound, getSelectionShadeWidth, getValueAt, getWebListCellRenderer, getWebModel, getWebUI, isAutoScrollToSelection, isBoldFont, isDecorateSelection, isEditable, isEditing, isHighlightRolloverCell, isItalicFont, isPlainFont, isRolloverSelectionEnabled, isUnselectable, removeCellEditor, removeListDataListener, removeListEditListener, repaint, repaint, repaint, scrollToCell, setAutoScrollToSelection, setBoldFont, setBoldFont, setCellEditor, setDecorateSelection, setEditable, setFontName, setFontSize, setFontSizeAndStyle, setFontSizeAndStyle, setFontStyle, setFontStyle, setHighlightRolloverCell, setItalicFont, setItalicFont, setMinimumHeight, setMinimumWidth, setMultiplySelectionAllowed, setPlainFont, setPlainFont, setPreferredHeight, setPreferredWidth, setRolloverSelectionEnabled, setSelectedValue, setSelectedValues, setSelectedValues, setSelectedValues, setSelectionRound, setSelectionShadeWidth, setUnselectable, stopCellEditing, updateUI
 
Methods inherited from class javax.swing.JList
addListSelectionListener, addSelectionInterval, clearSelection, createSelectionModel, ensureIndexIsVisible, fireSelectionValueChanged, getAccessibleContext, getAnchorSelectionIndex, getCellBounds, getCellRenderer, getDragEnabled, getDropLocation, getDropMode, getFirstVisibleIndex, getFixedCellHeight, getFixedCellWidth, getLastVisibleIndex, getLayoutOrientation, getLeadSelectionIndex, getListSelectionListeners, getMaxSelectionIndex, getMinSelectionIndex, getModel, getNextMatch, getPreferredScrollableViewportSize, getPrototypeCellValue, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedIndex, getSelectedIndices, getSelectedValue, getSelectedValues, getSelectionBackground, getSelectionForeground, getSelectionMode, getSelectionModel, getToolTipText, getUI, getUIClassID, getValueIsAdjusting, getVisibleRowCount, indexToLocation, isSelectedIndex, isSelectionEmpty, locationToIndex, paramString, removeListSelectionListener, removeSelectionInterval, setCellRenderer, setDragEnabled, setDropMode, setFixedCellHeight, setFixedCellWidth, setLayoutOrientation, setListData, setListData, setModel, setPrototypeCellValue, setSelectedIndex, setSelectedIndices, setSelectedValue, setSelectionBackground, setSelectionForeground, setSelectionInterval, setSelectionMode, setSelectionModel, setUI, setValueIsAdjusting, setVisibleRowCount
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

generateThumbnails

protected boolean generateThumbnails
Whether to generate image file thumbnails or not. Thumbnails generation might slow down list rendering in some cases.


preferredColumnCount

protected int preferredColumnCount
Preferred visible column count.


preferredRowCount

protected int preferredRowCount
Preferred visible row count.


fileListViewType

protected FileListViewType fileListViewType
File view mode.


fileFilter

protected java.io.FileFilter fileFilter
File filter.


displayedDirectory

protected java.io.File displayedDirectory
Displayed directory.


scrollView

protected WebScrollPane scrollView
Scroll pane with fixed preferred size that fits file list settings.

Constructor Detail

WebFileList

public WebFileList()
Constructs empty file list.


WebFileList

public WebFileList(java.lang.String directoryPath)
Constructs file list with files from directory under the specified path.

Parameters:
directoryPath - directory path

WebFileList

public WebFileList(java.io.File directory)
Constructs file list with files from the specified directory.

Parameters:
directory - directory

WebFileList

public WebFileList(java.io.File[] data)
Constructs file list with the specified files.

Parameters:
data - files array

WebFileList

public WebFileList(java.util.List<java.io.File> data)
Constructs file list with the specified files.

Parameters:
data - files list
Method Detail

initializeDefaultSettings

protected void initializeDefaultSettings()
Initializes default file list settings.


getWebFileListCellRenderer

public WebFileListCellRenderer getWebFileListCellRenderer()
                                                   throws java.lang.ClassCastException
Returns specific for WebFileList renderer. Be aware that this method might throw ClassCastException if renderer is altered by user.

Returns:
specific for WebFileList renderer
Throws:
java.lang.ClassCastException

getFileListModel

public FileListModel getFileListModel()
                               throws java.lang.ClassCastException
Returns specific for WebFileList model. Be aware that this method might throw ClassCastException if model is altered by user.

Returns:
specific for WebFileList model
Throws:
java.lang.ClassCastException

createDefaultCellEditor

protected ListCellEditor createDefaultCellEditor()
Returns default list cell editor for this list.

Overrides:
createDefaultCellEditor in class WebList
Returns:
default list cell editor for this list

setPreferredColumnCount

public void setPreferredColumnCount(int preferredColumnCount)
Sets preferred visible column count.

Parameters:
preferredColumnCount - new preferred visible column count

getPreferredColumnCount

public int getPreferredColumnCount()
Returns preferred visible column count.

Returns:
preferred visible column count

getPreferredRowCount

public int getPreferredRowCount()
Returns preferred visible row count.

Returns:
preferred visible row count

setPreferredRowCount

public void setPreferredRowCount(int preferredRowCount)
Sets preferred visible row count.

Parameters:
preferredRowCount - new preferred visible row count

isGenerateThumbnails

public boolean isGenerateThumbnails()
Returns whether to generate image file thumbnails or not.

Returns:
true if file list renderer should generate image file thumbnails, false otherwise

setGenerateThumbnails

public void setGenerateThumbnails(boolean generateThumbnails)
Sets whether to generate image file thumbnails or not.

Parameters:
generateThumbnails - whether to generate image file thumbnails or not

getFileListViewType

public FileListViewType getFileListViewType()
Returns file view mode.

Returns:
file view mode

setFileListViewType

public void setFileListViewType(FileListViewType fileListViewType)
Sets file view mode.

Parameters:
fileListViewType - new file view mode

getFileFilter

public java.io.FileFilter getFileFilter()
Returns file filter.

Returns:
file filter

setFileFilter

public void setFileFilter(java.io.FileFilter fileFilter)
Sets file filter.

Parameters:
fileFilter - new file filter

reloadFiles

public void reloadFiles()
Reloads files from displayed directory.


getDisplayedDirectory

public java.io.File getDisplayedDirectory()
Returns displayed directory. Returned File might be null in case custom files list was set or no data is loaded into list yet.

Returns:
displayed directory

setDisplayedDirectory

public void setDisplayedDirectory(java.io.File file)
Sets displayed directory. This will force list to load and display files from the specified directory.

Parameters:
file - new displayed directory

getSelectedFiles

public java.util.List<java.io.File> getSelectedFiles()
Returns list of selected files.

Returns:
list of selected files

getSelectedFile

public java.io.File getSelectedFile()
Returns selected file.

Returns:
selected file

setSelectedFile

public void setSelectedFile(java.io.File file)
Selects specified file if it presents in the list.

Parameters:
file - file to select

setSelectedFile

public void setSelectedFile(java.io.File file,
                            boolean shouldScroll)
Selects specified file if it presents in the list.

Parameters:
file - file to select
shouldScroll - whether to scroll to selected file or not

setSelectedFiles

public void setSelectedFiles(java.util.Collection<java.io.File> files)
Selects specified files if they present in the list.

Parameters:
files - files to select

getScrollView

public WebScrollPane getScrollView()
Returns scroll pane with fixed preferred size that fits file list settings.

Returns:
scroll pane with fixed preferred size that fits file list settings

createScrollView

public WebScrollPane createScrollView()
Returns new scroll pane with fixed preferred size that fits file list settings.

Returns:
new scroll pane with fixed preferred size that fits file list settings

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns preferred size for this list.

Specified by:
getPreferredSize in interface SizeMethods<WebList>
Overrides:
getPreferredSize in class WebList
Returns:
preferred size for this list

repaint

public void repaint(FileElement element)
Repaints cell with specified element.

Parameters:
element - element to process