java-gnome version 4.0.7

org.gnome.gtk
Class FileChooserDialog

java.lang.Object
  extended by org.freedesktop.bindings.Proxy
      extended by org.gnome.glib.Object
          extended by org.gnome.gtk.Object
              extended by org.gnome.gtk.Widget
                  extended by org.gnome.gtk.Container
                      extended by org.gnome.gtk.Bin
                          extended by org.gnome.gtk.Window
                              extended by org.gnome.gtk.Dialog
                                  extended by org.gnome.gtk.FileChooserDialog
All Implemented Interfaces:
FileChooser

public class FileChooserDialog
extends Dialog
implements FileChooser

A Dialog suitable for operations that need to select a file, such as "File -> Open" or "File -> Save" commands.

A FileChooserDialog is just a Dialog with a FileChooserWidget plus appropriate Buttons that corresponding to the specified FileChooserAction. Otherwise, all the methods provided by the FileChooser interface are available which gives you the necessary power to manipulate the selection received from the Dialog.

Using a FileChooserDialog to open a file could go like this:

 FileChooserDialog dialog;
 ResponseType response;
 
 // instantiate
 dialog = new FileChooserDialog("Open File", window, FileChooserAction.OPEN);
 
 // run the Dialog
 response = dialog.run();
 dialog.hide();
 
 // deal with the result
 if (response == ResponseType.OK) {
     open(dialog.getFilename());
 }
 

Since:
4.0.5
Author:
Vreixo Formoso, Andrew Cowie

Nested Class Summary
 
Nested classes/interfaces inherited from class org.gnome.gtk.Dialog
Dialog.RESPONSE
 
Nested classes/interfaces inherited from class org.gnome.gtk.Window
Window.CONFIGURE_EVENT, Window.DELETE_EVENT
 
Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.BUTTON_PRESS_EVENT, Widget.BUTTON_RELEASE_EVENT, Widget.ENTER_NOTIFY_EVENT, Widget.EXPOSE_EVENT, Widget.FOCUS_IN_EVENT, Widget.FOCUS_OUT_EVENT, Widget.HIDE, Widget.KEY_PRESS_EVENT, Widget.KEY_RELEASE_EVENT, Widget.LEAVE_NOTIFY_EVENT, Widget.UNMAP_EVENT, Widget.VISIBILITY_NOTIFY_EVENT
 
Constructor Summary
FileChooserDialog(java.lang.String title, Window parent, FileChooserAction action)
          Create a new FileChooserDialog.
 
Method Summary
 FileChooserAction getAction()
          Gets the type of operation that the file chooser is performing.
 java.lang.String getCurrentFolder()
          Get the current folder being displayed in this FileChooser.
 java.lang.String getFilename()
          Get the filename currently selected by this FileChooser.
 java.net.URI getURI()
          Get the URI representing the file or directory currently selected by this FileChooser.
 void setAction(FileChooserAction action)
          Sets the type of operation that the chooser is performing; the user interface is adapted to suit the selected action.
 boolean setCurrentFolder(java.lang.String directory)
          Set the current directory for this FileChooser.
 boolean setFilename(java.lang.String filename)
          Set the file you want selected in the FileChooser.
 
Methods inherited from class org.gnome.gtk.Dialog
add, addButton, addButton, connect, run
 
Methods inherited from class org.gnome.gtk.Window
connect, connect, getHeight, getMaximized, getPositionX, getPositionY, getScreen, getWidth, move, present, resize, setDecorated, setDefaultSize, setFullscreen, setGravity, setIcon, setKeepAbove, setKeepBelow, setMaximize, setModal, setPosition, setResizable, setSkipPagerHint, setSkipTaskbarHint, setStick, setTitle, setTransientFor, setTypeHint
 
Methods inherited from class org.gnome.gtk.Bin
getChild
 
Methods inherited from class org.gnome.gtk.Container
getChildren, remove, setBorderWidth
 
Methods inherited from class org.gnome.gtk.Widget
activate, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, getAllocation, getHasFocus, getParent, getRequisition, getToplevel, getWindow, grabDefault, grabFocus, hide, modifyBackground, modifyText, setCanFocus, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll
 
Methods inherited from class org.freedesktop.bindings.Proxy
toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileChooserDialog

public FileChooserDialog(java.lang.String title,
                         Window parent,
                         FileChooserAction action)
Create a new FileChooserDialog.

Buttons appropriate to each of the different FileChooserActions have been preconfigured in the action area of the Dialog. In all cases, the executive to go ahead with the action will be the return of ResponseType OK.

Parameters:
title - the text to use in the title bar of the Dialog Window as drawn by the window manager, or null if you want a blank title.
parent - the transient parent of the Dialog. While null is allowed, things are designed to work properly on the assumption that a parent is specified so it is recommended that you do so.
action - which style of FileChooser you want.
Method Detail

getAction

public FileChooserAction getAction()
Description copied from interface: FileChooser
Gets the type of operation that the file chooser is performing.

Specified by:
getAction in interface FileChooser
See Also:
FileChooser.setAction(FileChooserAction)

getCurrentFolder

public java.lang.String getCurrentFolder()
Description copied from interface: FileChooser
Get the current folder being displayed in this FileChooser. Note that this is not the same as the currently-selected folder if the FileChooser is in SELECT_FOLDER mode. To get the currently-selected folder in that mode, you can use FileChooser.getURI() instead.

Specified by:
getCurrentFolder in interface FileChooser
Returns:
The current folder, or null if if the FileChooser was unable to load the last folder that was requested of it (as would happen if calling FileChooser.setCurrentFolder(String) on a nonexistent directory).
See Also:
FileChooser.getFilename()

getFilename

public java.lang.String getFilename()
Description copied from interface: FileChooser
Get the filename currently selected by this FileChooser.

Specified by:
getFilename in interface FileChooser
Returns:
The filename, or if no file is selected then this will return null. If multiple files are selected, one of the filenames will be returned at random. If the FileChooser is in one of the folder modes, this returns the selected folder's name.

getURI

public java.net.URI getURI()
Description copied from interface: FileChooser
Get the URI representing the file or directory currently selected by this FileChooser.

Specified by:
getURI in interface FileChooser
Returns:
The selected file's URI, or if no file is selected then this will return null. If multiple files are selected, one of the filenames will be returned at random. If the FileChooser is in one of the folder modes, this returns the selected folder's URI.

setAction

public void setAction(FileChooserAction action)
Description copied from interface: FileChooser
Sets the type of operation that the chooser is performing; the user interface is adapted to suit the selected action. For example, an option to create a new folder might be shown if the action is SAVE but not if the action is OPEN.

Specified by:
setAction in interface FileChooser

setCurrentFolder

public boolean setCurrentFolder(java.lang.String directory)
Description copied from interface: FileChooser
Set the current directory for this FileChooser. The user will be shown the full contents of that folder, plus user interface elements for navigating to other folders.

Specified by:
setCurrentFolder in interface FileChooser
Parameters:
directory - the full path of the new current folder
Returns:
true if the folder could be changed successfully, false otherwise.

setFilename

public boolean setFilename(java.lang.String filename)
Description copied from interface: FileChooser
Set the file you want selected in the FileChooser.

If the folder currently showing in the FileChooser isn't the directory containing the filename you specify, then the FileChooser will be changed to that directory.

Specified by:
setFilename in interface FileChooser
Parameters:
filename - Must be an absolute path.
Returns:
true if the the directory was changed (if necessary) and a file was successfully selected.


java-gnome