Class FWFileChooserFormComponent

All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, FWObserver

public class FWFileChooserFormComponent extends FWAbstractFormComponent implements ActionListener
Author:
andi, ckunze Form component that displays a standard dialog to let the user select a file or directory. Multiple selection is not supported. Use a tag in the XML configuration of the enclosing form to make this component select files or use a tag to make it select directories.

The component reckognizes the following parameters in its XML configuration:

Required:

id

Optional:

enabled
Determines, if the value of the component can be changed. Possible values are expressions that evaluate to 0, 1, true or false. The default value is true.
default
An expression that evaluates to a file or directory name. If the component is configured for file selection, this sets the preselected file or the initial directory of the file selection dialog. If the component is configured for directory selection, this sets the preselected directory. Notice that this setting has no effect, if the components initial value is set using a FormFiller! If the component is configured for diectory selection and this parameter is not set, the initial directory will be set to the user's home directory.
required
Default: false.

If the component is used for file selection, the displayed file types can be limited by their extensions using <extension> child elements. Note however, that this does not limit the file types that can be selected! If specified for a directory chooser, these child elements are ignored.

An example configuration might look like this: <file id="mymodel.inputfile" required="true" enabled="true" default="data/myinputfile.dat"> <extension>dat</extension> <extension>txt</extension> </file>

See Also:
  • Constructor Details

    • FWFileChooserFormComponent

      public FWFileChooserFormComponent(String aFormId, String aFieldId, boolean aShowBorder, org.jdom2.Element aParameters, FWObservable aObservabal, boolean aIsDirectoryChooser)
      Parameters:
      aFormId -
      aFieldId -
      aShowBorder -
      aParameters -
      aObservabal -
      aIsDirectoryChooser -
  • Method Details

    • getValue

      public String getValue()
      If used for file selection, returns the currently selected file or null if the current selection is a directory, does not exist or is not a valid file.

      If used for directory selection, returns the currently selected directory, the parent directory of the currently selected file or null if the current selection does not exist or is not a valid file or directory.

      Specified by:
      getValue in class FWAbstractFormComponent
      Returns:
      value of the implemented component
    • setValue

      public void setValue(Object aValue)
      Constructs a File from aValue and calls @link setValue( File ) with it
      Specified by:
      setValue in class FWAbstractFormComponent
      Parameters:
      aValue - of the implemented component
    • setValue

      public void setValue(File aFile)
      Sets aFile as the current value
      Parameters:
      aFile -
    • setValue

      public void setValue(File[] aFiles)
      Parameters:
      aFiles -
    • setEnabled

      public void setEnabled(boolean aNewState)
      Overrides:
      setEnabled in class JComponent
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Display a standard file/directory selection dialog and save the result
      Specified by:
      actionPerformed in interface ActionListener
    • update

      public void update(FWObservable aObservable, Object aKeyOfParameterChanged)
      Description copied from class: FWAbstractFormComponent
      updates different functions like enableing of the Component
      Specified by:
      update in interface FWObserver
      Overrides:
      update in class FWAbstractFormComponent
      Parameters:
      aObservable - the observable object.
      aKeyOfParameterChanged - an argument passed to the notifyObservers method.
      See Also:
    • processFormFiller

      public void processFormFiller()
      Specified by:
      processFormFiller in class FWAbstractFormComponent
    • getValueCell

      protected com.lowagie.text.Rectangle getValueCell(int aType)
      Description copied from class: FWAbstractFormComponent
      returns the value label to use for generating rtf, pdf or html version of the form
      Specified by:
      getValueCell in class FWAbstractFormComponent
      Returns:
      iText Cell