DirectoryValidator (install4j API)
Keywords: com.install4j.api.DirectoryValidator class

Overview | Package | Class | Tree | Deprecated | Index | Help
| install4j API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.install4j.api
Class DirectoryValidator

    java.lang.Object
      com.install4j.api.DirectoryValidator

    public abstract class DirectoryValidator

extends java.lang.Object

If you define a directory validatory derived from this class on the "Advanced tasks" tab in the install4j GUI it will be instantiated and used to modify the behavior of the the "Installation location" screen of the installer. This is useful if the standard behavior of accepting non-existing directories and emitting a warning for existing directories is not suitable for your needs. Also, if you wish to change the installation directory after the user has made a selection, this validator can be used.

Author:
  ej-technologies GmbH

Constructor Summary
`DirectoryValidator()`

Method Summary
`abstract boolean` | `canValidate()` If you wish to validate directory selections of the user, return `true` here.
`abstract java.io.File` | `getInstallationDirectory(java.io.File selectedDirectory, java.lang.String defaultDirectoryName)` After the user selection for the installation directory has been accepted, this method will be queried to obtain the actual installation directory.
`InstallerContext` | `getInstallerContext()` Returns the `InstallerContext` that the framework has associated with this validator in `setInstallerContext`.
`void` | `setInstallerContext(InstallerContext context)` This method is called by the framework to set the `InstallerContext`.
`abstract boolean` | `validate(java.io.File selectedDirectory)` Validate the user selection for the installation directory.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DirectoryValidator

    public DirectoryValidator()

Method Detail

### getInstallerContext

    public InstallerContext getInstallerContext()

  Returns the `InstallerContext` that the framework has associated with this validator in `setInstallerContext`. For the GUI wizard, this context will be a `InstallerWizardContext`.

  Returns:
    the context.

### setInstallerContext

    public void setInstallerContext(InstallerContext context)

  This method is called by the framework to set the `InstallerContext`. This is the context that is returned from `getInstallerContext`. If you have to register an `InstallerEventListener` on the context you can override this method. Do not forget to call the super implementation in that case.

  Parameters:
    `context` - the context.

### canValidate

    public abstract boolean canValidate()

  If you wish to validate directory selections of the user, return `true` here. Returing false only makes sense if you only wish to change the installation directory without any validation. The standard validation will be used in that case.

  Returns:
    whether this class will be asked for validation or not.

### validate

    public abstract boolean validate(java.io.File selectedDirectory)

  Validate the user selection for the installation directory. If `canValidate` returns `false` this method will never be invoked. Validation takes place after the user clicks "Next" on the installation location screen. If you want to accept the selection and proceed to the next screen, return `true` in this screen, otherwise display a warning message and return `false`. The installer wizard will then continue to display the installation location screen.

  Note: No further warning message will be displayed when returning `false.`

  Parameters:
    `selectedDirectory` - the directory selected by the user.
  Returns:
    whether to accept the sleection or not.

### getInstallationDirectory

    public abstract java.io.File getInstallationDirectory(java.io.File selectedDirectory,
                                                          java.lang.String defaultDirectoryName)

  After the user selection for the installation directory has been accepted, this method will be queried to obtain the actual installation directory. This is useful, for example, for plugin installations with a separate uninstaller, where the user has to select the installation directory of an already installed application. You could then return a sub-directory of the selected directory.

  Parameters:
    `selectedDirectory` - the user selection for the installation directory.
    `defaultDirectoryName` - the default installation directory name as defined in the install4j GUI.
  Returns:
    the actual installation directory. If you do not want to substitute anything, just return `selectedDirectory`.

Overview | Package | Class | Tree | Deprecated | Index | Help
| install4j API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD