Class FileDialog
- All Implemented Interfaces:
Adaptable
- Styles:
- MULTI
- Events:
- (none)
The OPEN style is applied by default and setting any other styles has no effect.
IMPORTANT: This class is intended to be subclassed only within the SWT implementation.
-
Field Summary
Fields inherited from class org.eclipse.swt.widgets.Dialog
returnCode, shell
-
Constructor Summary
ConstructorDescriptionFileDialog
(Shell parent) Constructs a new instance of this class given only its parent.FileDialog
(Shell parent, int style) Constructs a new instance of this class given its parent and a style value describing its behavior and appearance. -
Method Summary
Modifier and TypeMethodDescriptionprotected Button
createButton
(Composite parent, String text) protected FileUpload
createFileUpload
(Composite parent, String text) Returns a list with exceptions thrown during the file upload.Returns the path of the first file that was selected in the dialog relative to the filter path, or an empty string if no such file has been selected.String[]
Returns a (possibly empty) array with the paths of all files that were selected in the dialog relative to the filter path.String[]
Returns the file extensions which the dialog will use to filter the files it shows.Returns the directory where the files should be uploaded to, ornull
when a temporary directory is used.long
Returns the maximum upload size in bytes.long
Returns the maximum upload duration in milliseconds.open()
Makes the dialog visible and brings it to the front of the display.protected void
void
setClientFiles
(ClientFile[] files) Sets initial client files to be uploaded.void
setFilterExtensions
(String[] extensions) Set the file extensions which the dialog will use to filter the files it shows to the argument, which may be null.void
setUploadDirectory
(File directory) Set the directory where the files should be uploaded to.void
setUploadSizeLimit
(long limit) Sets the maximum upload size in bytes.void
setUploadTimeLimit
(long limit) Sets the maximum upload duration in milliseconds.Methods inherited from class org.eclipse.swt.widgets.Dialog
checkOperationMode, checkSubclass, getAdapter, getParent, getStyle, getText, open, runEventLoop, setText
-
Constructor Details
-
FileDialog
Constructs a new instance of this class given only its parent.- Parameters:
parent
- a shell which will be the parent of the new instance- Throws:
IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the parent is null
SWTException
-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
-
FileDialog
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.The style value is either one of the style constants defined in class
SWT
which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using theint
"|" operator) two or more of thoseSWT
style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.- Parameters:
parent
- a shell which will be the parent of the new instancestyle
- the style of dialog to construct- Throws:
IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the parent is null
SWTException
-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
-
-
Method Details
-
getFileName
Returns the path of the first file that was selected in the dialog relative to the filter path, or an empty string if no such file has been selected.- Returns:
- the relative path of the file
-
getFileNames
Returns a (possibly empty) array with the paths of all files that were selected in the dialog relative to the filter path.- Returns:
- the relative paths of the files
-
setFilterExtensions
Set the file extensions which the dialog will use to filter the files it shows to the argument, which may be null.An extension filter string must be of the form ".extension".
- Parameters:
extensions
- the file extension filter- Since:
- 3.2
-
getFilterExtensions
Returns the file extensions which the dialog will use to filter the files it shows.- Returns:
- the file extensions filter
- Since:
- 3.2
-
setClientFiles
Sets initial client files to be uploaded. The upload of these files will start immediately after opening the dialog. Hence, this method must be called before opening the dialog.A user can drag and drop files from the client operating system on any control with a drop listener attached. In this case, the client files can be obtained from the
ClientFileTransfer
object. This FileDialog can then be used to handle the upload and display upload progress.- Parameters:
files
- an array of client files to be added to the dialog- Since:
- 3.1
-
setUploadSizeLimit
public void setUploadSizeLimit(long limit) Sets the maximum upload size in bytes. If upload size is bigger it will be interrupted. A value of -1 indicates no limit.- Parameters:
limit
- the maximum upload size in bytes- Since:
- 3.3
- See Also:
-
getUploadSizeLimit
public long getUploadSizeLimit()Returns the maximum upload size in bytes. The default value of -1 indicates no limit.- Since:
- 3.3
-
setUploadDirectory
Set the directory where the files should be uploaded to. If no directory is set or it is set tonull
a temporary directory is used.- Parameters:
directory
- the directory to upload to- Since:
- 3.7
-
getUploadDirectory
Returns the directory where the files should be uploaded to, ornull
when a temporary directory is used.- Since:
- 3.7
-
setUploadTimeLimit
public void setUploadTimeLimit(long limit) Sets the maximum upload duration in milliseconds. If upload takes longer it will be interrupted. The default value of -1 indicates no limit.- Parameters:
limit
- the maximum upload duration in milliseconds- Since:
- 3.3
- See Also:
-
getUploadTimeLimit
public long getUploadTimeLimit()Returns the maximum upload duration in milliseconds. The default value of -1 indicates no limit.- Since:
- 3.3
-
getExceptions
Returns a list with exceptions thrown during the file upload. Will never return null.- Since:
- 3.3
- See Also:
-
open
Makes the dialog visible and brings it to the front of the display.RAP Note: This method is not supported when running the application in JEE_COMPATIBILITY mode. Use
Dialog#open(DialogCallback)
instead.- Returns:
- a string describing the absolute path of the first selected file, or null if the dialog was cancelled or an error occurred
- Throws:
SWTException
-- ERROR_WIDGET_DISPOSED - if the dialog has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog
-
prepareOpen
protected void prepareOpen()- Overrides:
prepareOpen
in classDialog
-
createFileUpload
-
createButton
-