public class SwingFileWidget extends SwingInputWidget<File> implements FileWidget<JPanel>, ActionListener, DocumentListener
DIRECTORY_STYLE, OPEN_STYLE, SAVE_STYLE
Constructor and Description |
---|
SwingFileWidget() |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e) |
void |
changedUpdate(DocumentEvent e) |
static FileFilter |
createFileFilter(String widgetStyle)
Creates a
FileFilter that filters files and/or directories
according to the given widget style. |
void |
doRefresh()
Performs the intended
AbstractUIInputWidget.refreshWidget() operation. |
static List<File> |
filterFiles(List<File> list,
FileFilter filter)
Filters the given list of files according to the specified
FileFilter . |
static List<File> |
getFiles(TransferHandler.TransferSupport support)
Gets the list of files associated with the given drag and drop operation.
|
static String |
getText(TransferHandler.TransferSupport support)
Gets the String content of the current transfer support
|
File |
getValue()
Gets the current widget value.
|
static boolean |
hasFiles(TransferHandler.TransferSupport support)
Checks whether the given drag and drop operation offers a list of files as
one of its flavors.
|
void |
insertUpdate(DocumentEvent e) |
void |
removeUpdate(DocumentEvent e) |
void |
set(WidgetModel model)
Associates the given data object with this plugin.
|
boolean |
supports(WidgetModel model)
Gets whether this object is compatible with the given data object.
|
getComponent, getComponentType, setToolTip, ui
refreshWidget, ui
get, updateModel
getInfo, getPriority, setInfo, setPriority, toString
context, getContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
get, getType, isLabeled, isMessage, refreshWidget, updateModel
getIdentifier, log
context, getContext, setContext
compareTo, getPriority, setPriority
getInfo, setInfo
getLocation
getVersion
getComponent, getComponentType
public File getValue()
InputWidget
getValue
in interface InputWidget<File,JPanel>
public void set(WidgetModel model)
WrapperPlugin
Typed.supports(T)
must return true).set
in interface WrapperPlugin<WidgetModel>
set
in interface InputWidget<File,JPanel>
set
in class SwingInputWidget<File>
model
- The data object to associate with the plugin.public boolean supports(WidgetModel model)
Typed
By default, this method will return true
iff the data is assignable
to the associated type given by Typed.getType()
. But individual
implementations may have other requirements beyond class assignability.
supports
in interface Typed<WidgetModel>
supports
in interface InputWidget<File,JPanel>
supports
in class AbstractInputWidget<File,JPanel>
public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
public void changedUpdate(DocumentEvent e)
changedUpdate
in interface DocumentListener
public void insertUpdate(DocumentEvent e)
insertUpdate
in interface DocumentListener
public void removeUpdate(DocumentEvent e)
removeUpdate
in interface DocumentListener
public void doRefresh()
AbstractUIInputWidget
AbstractUIInputWidget.refreshWidget()
operation.doRefresh
in class AbstractUIInputWidget<File,JPanel>
public static FileFilter createFileFilter(String widgetStyle)
FileFilter
that filters files and/or directories
according to the given widget style.
It supports filtering files by extension as specified by the syntax
extensions:ext1/ext2
where ext1
, ext2
, etc., are
extensions to accept. It also filters files and/or directories as specified
by the following styles:
widgetStyle
- The style defining which files get accepted by the
filter.FileFilter
that accepts files matching the given widget
style.public static boolean hasFiles(TransferHandler.TransferSupport support)
support
- The drag and drop operation that should be checked.public static List<File> getFiles(TransferHandler.TransferSupport support)
support
- The drag and drop operation from which files should be
extracted.File
objects; or an exception is thrown.public static String getText(TransferHandler.TransferSupport support)
support
- The paste (or drag and drop) operation from which text should
be extracted.public static List<File> filterFiles(List<File> list, FileFilter filter)
FileFilter
.list
- The list of files to filter.filter
- The filter to use.Copyright © 2015–2022 SciJava. All rights reserved.