Class AbstractFormComponent
- All Implemented Interfaces:
Bean,FormComponent,com.install4j.runtime.beans.formcomponents.FormEnvironmentContainer
ComponentTuple of the form component.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanThis 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.voidThis method is called by the framework just after the containing screen has been activated.voidThis method is called by the framework just after the containing screen has been deactivated.voidThis method is called by the framework just before the containing screen will be activated.If thegetConfigurationObjectClassmethod returnsnull, this method is not called, otherwise a non-null value of the type returned bygetConfigurationObjectClasshas 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 theContextthat the framework has associated with this form component insetContext.Returns theFormEnvironmentthat the framework has associated with this form component insetFormEnvironment.protected ObjectgetInitValue(Object defaultValue, String variableName, Class<?> valueClass) Helper method to get an init value.static intgetMnemonicCharIndex(String text) static StringbooleanhandleConsole(Console console) Handle the console mode.booleanHandle the unattended mode.booleanThis method is called in situations where the installer must disable all user inputs.protected final voidDeprecated.voidThis method is called by the framework when the initial state of the component should be evaluated.booleanReturns whether the form component is enabled or not.booleanDetermine how the center component created bycreateCenterComponentshould should fill all available vertical space.booleanReturns whether the form component is visible or not.voidmigrateIds(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.voidTransfer the focus to this form component.voidsetContext(Context context) This method is called by the framework to set theContextjust after the form component has been constructed.voidsetEnabled(boolean enabled) Sets whether the form component is enabled or not.voidsetFormEnvironment(FormEnvironment formEnvironment) At runtime, this method is called twice by the framework.voidsetVisible(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, rollbackActionListMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:FormComponentThis method is called by the framework to set theContextjust after the form component has been constructed. This is either anInstallerContextor anUninstallerContext, depending on whether the form screen is part of an installer or uninstaller.- Specified by:
setContextin interfaceFormComponent- Parameters:
context- the context.
-
getContext
Returns theContextthat the framework has associated with this form component insetContext.- Returns:
- the installer context.
-
setFormEnvironment
Description copied from interface:FormComponentAt runtime, this method is called twice by the framework. Once, to set theFormEnvironmentjust 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 newFormEnvironmentis 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:
setFormEnvironmentin interfaceFormComponent- Specified by:
setFormEnvironmentin interfacecom.install4j.runtime.beans.formcomponents.FormEnvironmentContainer- Parameters:
formEnvironment- theFormEnvironment- See Also:
-
getFormEnvironment
Returns theFormEnvironmentthat the framework has associated with this form component insetFormEnvironment.- Specified by:
getFormEnvironmentin interfacecom.install4j.runtime.beans.formcomponents.FormEnvironmentContainer- Returns:
- the installer context.
-
isEnabled
public boolean isEnabled()Description copied from interface:FormComponentReturns whether the form component is enabled or not. This must reflect the value set withsetEnabled.AbstractFormComponentprovides a default implementation for bothisEnabledandsetEnabled.- Specified by:
isEnabledin interfaceFormComponent- Returns:
trueorfalse.- See Also:
-
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:FormComponentSets 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.
AbstractFormComponentprovides a default implementation that callssetEnabledon the component returned byFormComponent.getConfigurationObject(), saves the "enabled" flag and returns it in theisEnabledmethod.- Specified by:
setEnabledin interfaceFormComponent- Parameters:
enabled- whether to enable this form component or not- See Also:
-
setVisible
public void setVisible(boolean visible) Description copied from interface:FormComponentSets 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.
AbstractFormComponentprovides a default implementation that callssetVisibleon all components in theComponentTuple, saves the "visible" flag and returns it in theisVisiblemethod.- Specified by:
setVisiblein interfaceFormComponent- Parameters:
visible- whether this form component should be visible or not- See Also:
-
isVisible
public boolean isVisible()Description copied from interface:FormComponentReturns whether the form component is visible or not. This must reflect the value set withsetVisible.AbstractFormComponentprovides a default implementation for bothisVisibleandsetVisible.- Specified by:
isVisiblein interfaceFormComponent- Returns:
trueorfalse.- See Also:
-
migrateIds
Description copied from interface:FormComponentThis 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.getIdchange. Form components that keep a list of IDs for other form components should migrate those IDs in this method.- Specified by:
migrateIdsin 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:FormComponentTransfer the focus to this form component.- Specified by:
requestFocusin interfaceFormComponent
-
hasUserInput
public boolean hasUserInput()Description copied from interface:FormComponentThis 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:
hasUserInputin interfaceFormComponent- Returns:
- if the component has user input
-
createLeftComponent
Description copied from interface:FormComponentCreate 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:
createLeftComponentin interfaceFormComponent- Returns:
- the leading component or
nullif no leading component should be created.
-
isFillCenterVertical
public boolean isFillCenterVertical()Description copied from interface:FormComponentDetermine how the center component created bycreateCenterComponentshould 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:
isFillCenterVerticalin interfaceFormComponent- Returns:
trueorfalse.- See Also:
-
createRightComponent
Description copied from interface:FormComponentCreate 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:
createRightComponentin interfaceFormComponent- Returns:
- the trailing component or
nullif no trailing component should be created.
-
getConfigurationObject
Description copied from interface:FormComponentIf thegetConfigurationObjectClassmethod returnsnull, this method is not called, otherwise a non-null value of the type returned bygetConfigurationObjectClasshas to be returned by this method.In console or unattended mode, this method is never called.
- Specified by:
getConfigurationObjectin interfaceFormComponent- Returns:
- the configuration object or
nullifgetConfigurationObjectClassreturns null as well. - See Also:
-
getConfigurationObjectClass
Description copied from interface:FormComponentA 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 aJCheckBoxor aJTextField. If you return a non-null value in the method, thegetConfigurationObjectmethod must return an object of that class.In console or unattended mode, this method is never called.
- Specified by:
getConfigurationObjectClassin interfaceFormComponent- Returns:
- the class of the configuration object or
nullif no configuration object should be exposed. - See Also:
-
checkCompleted
public boolean checkCompleted()Description copied from interface:FormComponentThis 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 returningfalsein this method.- Specified by:
checkCompletedin interfaceFormComponent- Returns:
- whether to allow advancing to the next screen or not.
- See Also:
-
initialize
public void initialize()Description copied from interface:FormComponentThis 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:
initializein interfaceFormComponent- See Also:
-
initalize
Deprecated.The name of this method has changed to "initialize" -
formWillActivate
public void formWillActivate()Description copied from interface:FormComponentThis method is called by the framework just before the containing screen will be activated.- Specified by:
formWillActivatein interfaceFormComponent- See Also:
-
formActivated
public void formActivated()Description copied from interface:FormComponentThis method is called by the framework just after the containing screen has been activated.- Specified by:
formActivatedin interfaceFormComponent- See Also:
-
formDeactivated
public void formDeactivated()Description copied from interface:FormComponentThis method is called by the framework just after the containing screen has been deactivated.- Specified by:
formDeactivatedin interfaceFormComponent- See Also:
-
handleConsole
Description copied from interface:FormComponentHandle the console mode. This method is called when the form component is processed in console mode. You can use theConsoleobject to interact with the user and replicate the GUI functionality on the terminal.Note: Screens with form panels have to call
FormEnvironment.handleConsolein theirhandleConsolemethod, otherwise this method will not be invoked. All pre-defined screens in install4j comply with this requirement.- Specified by:
handleConsolein interfaceFormComponent- Parameters:
console- theConsoleobject- 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 theConsoleobject.- See Also:
-
handleUnattended
public boolean handleUnattended()Description copied from interface:FormComponentHandle 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:
handleUnattendedin 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:
-