Class AbstractFormComponent
- All Implemented Interfaces:
Bean
,FormComponent
,com.install4j.runtime.beans.formcomponents.FormEnvironmentContainer
ComponentTuple
of the form component.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
This method is called by the framework when the user advances to the next screen in GUI or console mode.Create the leading component to the left of the center component.Create the trailing component to the right of the center component.void
This method is called by the framework just after the containing screen has been activated.void
This method is called by the framework just after the containing screen has been deactivated.void
This method is called by the framework just before the containing screen will be activated.If thegetConfigurationObjectClass
method returnsnull
, this method is not called, otherwise a non-null value of the type returned bygetConfigurationObjectClass
has to be returned by this method.Class
<?> A form component can expose a well-known configuration object that is passed as a parameter to the "Initialization script" property of every form component.Returns theContext
that the framework has associated with this form component insetContext
.Returns theFormEnvironment
that the framework has associated with this form component insetFormEnvironment
.protected Object
getInitValue
(Object defaultValue, String variableName, Class<?> valueClass) Helper method to get an init value.static int
getMnemonicCharIndex
(String text) static String
boolean
handleConsole
(Console console) Handle the console mode.boolean
Handle the unattended mode.boolean
This method is called in situations where the installer must disable all user inputs.protected final void
Deprecated.void
This method is called by the framework when the initial state of the component should be evaluated.boolean
Returns whether the form component is enabled or not.boolean
Determine how the center component created bycreateCenterComponent
should should fill all available vertical space.boolean
Returns whether the form component is visible or not.void
migrateIds
(Map<String, String> oldIdToNewId) This method is only called at design time when a user pastes form components or a screen with form components from the clipboard.replaceFormVariables
(String value) Same asAbstractBean.replaceVariables(String)
, only with the additional replacement of form variables.String[]
replaceFormVariables
(String[] values) Same asAbstractBean.replaceVariables(String[])
, only with the additional replacement of form variables.String[]
replaceFormVariables
(String[] values, VariableErrorHandlingDescriptor errorHandlingDescriptor) Same asAbstractBean.replaceVariables(String[], VariableErrorHandlingDescriptor)
, only with the additional replacement of form variables.replaceFormVariables
(String value, ReplacementMode replacementMode) Same asAbstractBean.replaceVariables(String, ReplacementMode)
, only with the additional replacement of form variables.replaceFormVariables
(String value, ReplacementMode replacementMode, VariableErrorHandlingDescriptor errorHandlingDescriptor) Same asAbstractBean.replaceVariables(String, ReplacementMode, VariableErrorHandlingDescriptor)
, only with the additional replacement of form variables.replaceFormVariables
(String value, VariableErrorHandlingDescriptor errorHandlingDescriptor) Same asAbstractBean.replaceVariables(String, VariableErrorHandlingDescriptor)
, only with the additional replacement of form variables.void
Transfer the focus to this form component.void
setContext
(Context context) This method is called by the framework to set theContext
just after the form component has been constructed.void
setEnabled
(boolean enabled) Sets whether the form component is enabled or not.void
setFormEnvironment
(FormEnvironment formEnvironment) At runtime, this method is called twice by the framework.void
setVisible
(boolean visible) Sets whether the form component is visible or not.Methods inherited from class com.install4j.api.beans.AbstractBean
executeActionListAsync, executeActionListSync, getTextOverrideValue, replaceVariables, replaceVariables, replaceVariables, replaceVariables, replaceVariables, replaceVariables, replaceVariables, replaceVariables, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, rollbackActionList
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.install4j.api.formcomponents.FormComponent
createCenterComponent, isFillCenterHorizontal
-
Field Details
-
MNEMONIC_PATTERN
-
-
Constructor Details
-
AbstractFormComponent
public AbstractFormComponent()
-
-
Method Details
-
getTextWithoutMnemonics
-
getMnemonicCharIndex
-
setContext
Description copied from interface:FormComponent
This method is called by the framework to set theContext
just after the form component has been constructed. This is either anInstallerContext
or anUninstallerContext
, depending on whether the form screen is part of an installer or uninstaller.- Specified by:
setContext
in interfaceFormComponent
- Parameters:
context
- the context.
-
getContext
Returns theContext
that the framework has associated with this form component insetContext
.- Returns:
- the installer context.
-
setFormEnvironment
Description copied from interface:FormComponent
At runtime, this method is called twice by the framework. Once, to set theFormEnvironment
just after the screen has been constructed. ThegetFormComponents()
method will return an empty array for that instance. Secondly, after all form components have been instantiated, a newFormEnvironment
is set whosegetFormComponents()
method returns all form components in the form.At design time, this method is called repeatedly and the result of a call to
getFormComponents()
may be different over time.- Specified by:
setFormEnvironment
in interfaceFormComponent
- Specified by:
setFormEnvironment
in interfacecom.install4j.runtime.beans.formcomponents.FormEnvironmentContainer
- Parameters:
formEnvironment
- theFormEnvironment
- See Also:
-
getFormEnvironment
Returns theFormEnvironment
that the framework has associated with this form component insetFormEnvironment
.- Specified by:
getFormEnvironment
in interfacecom.install4j.runtime.beans.formcomponents.FormEnvironmentContainer
- Returns:
- the installer context.
-
isEnabled
public boolean isEnabled()Description copied from interface:FormComponent
Returns whether the form component is enabled or not. This must reflect the value set withsetEnabled
.AbstractFormComponent
provides a default implementation for bothisEnabled
andsetEnabled
.- Specified by:
isEnabled
in interfaceFormComponent
- Returns:
true
orfalse
.- See Also:
-
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:FormComponent
Sets whether the form component is enabled or not. This method is primarily intended for use in the "Initialization script" property in the install4j GUI.It can also be used for the case where another form component wants to control the state of this form component. For example, the "Check box" form component holds a list of coupled form components that are enabled and disabled with calls to this method.
AbstractFormComponent
provides a default implementation that callssetEnabled
on the component returned byFormComponent.getConfigurationObject()
, saves the "enabled" flag and returns it in theisEnabled
method.- Specified by:
setEnabled
in interfaceFormComponent
- Parameters:
enabled
- whether to enable this form component or not- See Also:
-
setVisible
public void setVisible(boolean visible) Description copied from interface:FormComponent
Sets whether the form component is visible or not. This method is primarily intended for the "Initialization script" property in the install4j GUI.It can also be used for the case where another form component wants to control the state of this form component.
AbstractFormComponent
provides a default implementation that callssetVisible
on all components in theComponentTuple
, saves the "visible" flag and returns it in theisVisible
method.- Specified by:
setVisible
in interfaceFormComponent
- Parameters:
visible
- whether this form component should be visible or not- See Also:
-
isVisible
public boolean isVisible()Description copied from interface:FormComponent
Returns whether the form component is visible or not. This must reflect the value set withsetVisible
.AbstractFormComponent
provides a default implementation for bothisVisible
andsetVisible
.- Specified by:
isVisible
in interfaceFormComponent
- Returns:
true
orfalse
.- See Also:
-
migrateIds
Description copied from interface:FormComponent
This method is only called at design time when a user pastes form components or a screen with form components from the clipboard. When form components are pasted, their IDs as returned byFormEnvironment.getId
change. Form components that keep a list of IDs for other form components should migrate those IDs in this method.- Specified by:
migrateIds
in interfaceFormComponent
- Parameters:
oldIdToNewId
- a map that maps the old IDs to the new IDs. An ID is of typejava.lang.String
.- See Also:
-
requestFocus
public void requestFocus()Description copied from interface:FormComponent
Transfer the focus to this form component.- Specified by:
requestFocus
in interfaceFormComponent
-
hasUserInput
public boolean hasUserInput()Description copied from interface:FormComponent
This method is called in situations where the installer must disable all user inputs. If your form component takes user input, such as for a checkbox or a text field, you should return true.- Specified by:
hasUserInput
in interfaceFormComponent
- Returns:
- if the component has user input
-
createLeftComponent
Description copied from interface:FormComponent
Create the leading component to the left of the center component. This component will not grow beyond its preferred horizontal size.In console or unattended mode, this method is never called.
- Specified by:
createLeftComponent
in interfaceFormComponent
- Returns:
- the leading component or
null
if no leading component should be created.
-
isFillCenterVertical
public boolean isFillCenterVertical()Description copied from interface:FormComponent
Determine how the center component created bycreateCenterComponent
should should fill all available vertical space. If there are multiple form components on a form that return true for this method, the excess vertical space will be distributed evenly. Note that you can configure the form not to grow vertically in the install4j GUI, so the center component may be displayed with its preferred height in any case.- Specified by:
isFillCenterVertical
in interfaceFormComponent
- Returns:
true
orfalse
.- See Also:
-
createRightComponent
Description copied from interface:FormComponent
Create the trailing component to the right of the center component. This component will not grow beyond its preferred horizontal size.In console or unattended mode, this method is never called.
- Specified by:
createRightComponent
in interfaceFormComponent
- Returns:
- the trailing component or
null
if no trailing component should be created.
-
getConfigurationObject
Description copied from interface:FormComponent
If thegetConfigurationObjectClass
method returnsnull
, this method is not called, otherwise a non-null value of the type returned bygetConfigurationObjectClass
has to be returned by this method.In console or unattended mode, this method is never called.
- Specified by:
getConfigurationObject
in interfaceFormComponent
- Returns:
- the configuration object or
null
ifgetConfigurationObjectClass
returns null as well. - See Also:
-
getConfigurationObjectClass
Description copied from interface:FormComponent
A form component can expose a well-known configuration object that is passed as a parameter to the "Initialization script" property of every form component. Typically, you expose the main component contained in this form component, such as aJCheckBox
or aJTextField
. If you return a non-null value in the method, thegetConfigurationObject
method must return an object of that class.In console or unattended mode, this method is never called.
- Specified by:
getConfigurationObjectClass
in interfaceFormComponent
- Returns:
- the class of the configuration object or
null
if no configuration object should be exposed. - See Also:
-
checkCompleted
public boolean checkCompleted()Description copied from interface:FormComponent
This method is called by the framework when the user advances to the next screen in GUI or console mode. If your form component expects user-input, this is the place to save it to an installer variable. You can veto the screen change by returningfalse
in this method.- Specified by:
checkCompleted
in interfaceFormComponent
- Returns:
- whether to allow advancing to the next screen or not.
- See Also:
-
initialize
public void initialize()Description copied from interface:FormComponent
This method is called by the framework when the initial state of the component should be evaluated. This happens when the user first enters the screen that contains the form component. Whether repeated entries to this screen will cause this method to be called depends on the value of the "Reset initialization on previous" property that can be configured in the install4j GUI.Initialization often involves replacing variables in user-configured property values.
- Specified by:
initialize
in interfaceFormComponent
- See Also:
-
initalize
Deprecated.The name of this method has changed to "initialize" -
formWillActivate
public void formWillActivate()Description copied from interface:FormComponent
This method is called by the framework just before the containing screen will be activated.- Specified by:
formWillActivate
in interfaceFormComponent
- See Also:
-
formActivated
public void formActivated()Description copied from interface:FormComponent
This method is called by the framework just after the containing screen has been activated.- Specified by:
formActivated
in interfaceFormComponent
- See Also:
-
formDeactivated
public void formDeactivated()Description copied from interface:FormComponent
This method is called by the framework just after the containing screen has been deactivated.- Specified by:
formDeactivated
in interfaceFormComponent
- See Also:
-
handleConsole
Description copied from interface:FormComponent
Handle the console mode. This method is called when the form component is processed in console mode. You can use theConsole
object to interact with the user and replicate the GUI functionality on the terminal.Note: Screens with form panels have to call
FormEnvironment.handleConsole
in theirhandleConsole
method, otherwise this method will not be invoked. All pre-defined screens in install4j comply with this requirement.- Specified by:
handleConsole
in interfaceFormComponent
- Parameters:
console
- theConsole
object- Returns:
- whether the installer or uninstaller can proceed with the next form component or whether the process should be canceled.
- Throws:
UserCanceledException
- if the user cancels a question or notice. These exceptions are thrown by methods in theConsole
object.- See Also:
-
handleUnattended
public boolean handleUnattended()Description copied from interface:FormComponent
Handle the unattended mode. This method is called when the form component is processed in unattended mode. There is no way to interact with the user. This method might be necessary to mirror some behavior from the GUI mode, such as setting an installer variable.- Specified by:
handleUnattended
in interfaceFormComponent
- Returns:
- whether the installer or uninstaller can proceed with the next form component or whether the process should be canceled.
-
getInitValue
Helper method to get an init value. If the variable is defined and of class valueClass, the variable value is used. Otherwise, the default value is used.- Parameters:
defaultValue
- the default value. Can be null.variableName
- the installer variable name the value will be assigned to later onvalueClass
- the desired class of the variable content- Returns:
- the init value to be used
-
replaceFormVariables
Same asAbstractBean.replaceVariables(String)
, only with the additional replacement of form variables.- Throws:
UndefinedVariableException
- See Also:
-
replaceFormVariables
public String replaceFormVariables(String value, ReplacementMode replacementMode) throws UndefinedVariableException Same asAbstractBean.replaceVariables(String, ReplacementMode)
, only with the additional replacement of form variables.- Throws:
UndefinedVariableException
- See Also:
-
replaceFormVariables
public String replaceFormVariables(String value, VariableErrorHandlingDescriptor errorHandlingDescriptor) throws UndefinedVariableException Same asAbstractBean.replaceVariables(String, VariableErrorHandlingDescriptor)
, only with the additional replacement of form variables.- Throws:
UndefinedVariableException
- See Also:
-
replaceFormVariables
public String replaceFormVariables(String value, ReplacementMode replacementMode, VariableErrorHandlingDescriptor errorHandlingDescriptor) throws UndefinedVariableException Same asAbstractBean.replaceVariables(String, ReplacementMode, VariableErrorHandlingDescriptor)
, only with the additional replacement of form variables.- Throws:
UndefinedVariableException
- See Also:
-
replaceFormVariables
Same asAbstractBean.replaceVariables(String[])
, only with the additional replacement of form variables.- Throws:
UndefinedVariableException
- See Also:
-
replaceFormVariables
public String[] replaceFormVariables(String[] values, VariableErrorHandlingDescriptor errorHandlingDescriptor) throws UndefinedVariableException Same asAbstractBean.replaceVariables(String[], VariableErrorHandlingDescriptor)
, only with the additional replacement of form variables.- Throws:
UndefinedVariableException
- See Also:
-