public abstract class AbstractFormComponent extends AbstractBean implements FormComponent, com.install4j.runtime.beans.formcomponents.FormEnvironmentContainer
ComponentTuple
of the form component.Modifier and Type | Field and Description |
---|---|
static java.util.regex.Pattern |
MNEMONIC_PATTERN |
Constructor and Description |
---|
AbstractFormComponent() |
Modifier and Type | Method and Description |
---|---|
boolean |
checkCompleted()
This method is called by the framework when the user advances to the next screen in GUI or console mode.
|
javax.swing.JComponent |
createLeftComponent()
Create the leading component to the left of the center component.
|
javax.swing.JComponent |
createRightComponent()
Create the trailing component to the right of the center component.
|
void |
formActivated()
This method is called by the framework just after the containing screen has been activated.
|
void |
formDeactivated()
This method is called by the framework just after the containing screen has been deactivated.
|
void |
formWillActivate()
This method is called by the framework just before the containing screen will be activated.
|
java.lang.Object |
getConfigurationObject()
If the
getConfigurationObjectClass method
returns null , this method is not called, otherwise a non-null value of the type returned by
getConfigurationObjectClass has to be returned by this method. |
java.lang.Class |
getConfigurationObjectClass()
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.
|
Context |
getContext()
Returns the
Context that the framework has associated with
this form component in setContext . |
FormEnvironment |
getFormEnvironment()
Returns the
FormEnvironment that the framework has associated with
this form component in setFormEnvironment . |
protected java.lang.Object |
getInitValue(java.lang.Object defaultValue,
java.lang.String variableName,
java.lang.Class<?> valueClass)
Helper method to get an init value.
|
static int |
getMnemonicCharIndex(java.lang.String text) |
static java.lang.String |
getTextWithoutMnemonics(java.lang.String text) |
boolean |
handleConsole(Console console)
Handle the console mode.
|
boolean |
handleUnattended()
Handle the unattended mode.
|
boolean |
hasUserInput()
This method is called in situations where the installer must disable all user input.
|
protected void |
initalize()
Deprecated.
|
void |
initialize()
This method is called by the framework when the initial state of the component should be evaluated.
|
boolean |
isEnabled()
Returns whether the form component is enabled or not.
|
boolean |
isFillCenterVertical()
Determine how the center component created by
createCenterComponent should should fill all available
vertical space. |
boolean |
isVisible()
Returns whether the form component is visible or not.
|
void |
migrateIds(java.util.Map<java.lang.String,java.lang.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.
|
java.lang.String |
replaceFormVariables(java.lang.String value)
Same as
AbstractBean.replaceVariables(String) , only with the additional replacement of form variables. |
java.lang.String[] |
replaceFormVariables(java.lang.String[] values)
Same as
AbstractBean.replaceVariables(String[]) , only with the additional replacement of form variables. |
java.lang.String[] |
replaceFormVariables(java.lang.String[] values,
VariableErrorHandlingDescriptor errorHandlingDescriptor)
Same as
AbstractBean.replaceVariables(String[], VariableErrorHandlingDescriptor) , only with the additional replacement of form variables. |
java.lang.String |
replaceFormVariables(java.lang.String value,
ReplacementMode replacementMode)
Same as
AbstractBean.replaceVariables(String, ReplacementMode) , only with the additional replacement of form variables. |
java.lang.String |
replaceFormVariables(java.lang.String value,
ReplacementMode replacementMode,
VariableErrorHandlingDescriptor errorHandlingDescriptor)
Same as
AbstractBean.replaceVariables(String, ReplacementMode, VariableErrorHandlingDescriptor) , only with the additional replacement of form variables. |
java.lang.String |
replaceFormVariables(java.lang.String value,
VariableErrorHandlingDescriptor errorHandlingDescriptor)
Same as
AbstractBean.replaceVariables(String, VariableErrorHandlingDescriptor) , only with the additional replacement of form variables. |
void |
requestFocus()
Transfer the focus to this form component.
|
void |
setContext(Context context)
This method is called by the framework to set the
Context 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.
|
executeActionListAsync, executeActionListSync, replaceVariables, replaceVariables, replaceVariables, replaceVariables, replaceVariables, replaceVariables, replaceVariables, replaceVariables, rollbackActionList
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createCenterComponent, isFillCenterHorizontal
public static java.lang.String getTextWithoutMnemonics(java.lang.String text)
public static int getMnemonicCharIndex(java.lang.String text)
public void setContext(Context context)
FormComponent
Context
just after the
form component has been constructed. This is either an InstallerContext
or an
UninstallerContext
, depending on the whether the form screen is part of an
installer or uninstaller.setContext
in interface FormComponent
context
- the context.public Context getContext()
Context
that the framework has associated with
this form component in setContext
.public void setFormEnvironment(FormEnvironment formEnvironment)
FormComponent
FormEnvironment
just after the
screen has been constructed. The getFormComponents()
method will return an empty array for that instance.
Second, after all form components have been instantiated, a new FormEnvironment
is set whose
getFormComponents()
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.
setFormEnvironment
in interface FormComponent
setFormEnvironment
in interface com.install4j.runtime.beans.formcomponents.FormEnvironmentContainer
formEnvironment
- the FormEnvironment
FormEnvironment.getFormComponents()
public FormEnvironment getFormEnvironment()
FormEnvironment
that the framework has associated with
this form component in setFormEnvironment
.getFormEnvironment
in interface com.install4j.runtime.beans.formcomponents.FormEnvironmentContainer
public boolean isEnabled()
FormComponent
setEnabled
.
AbstractFormComponent
provides a default implementation for both isEnabled
and setEnabled
.
isEnabled
in interface FormComponent
true
or false
.FormComponent.setEnabled(boolean)
public void setEnabled(boolean enabled)
FormComponent
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 calls setEnabled
on
the component returned by FormComponent.getConfigurationObject()
, saves the "enabled" flag and returns it in the
isEnabled
method.
setEnabled
in interface FormComponent
enabled
- whether to enable this form component or notAbstractFormComponent
,
ComponentTuple
,
FormComponent.isEnabled()
public void setVisible(boolean visible)
FormComponent
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 calls setVisible
on
all components in the ComponentTuple
, saves the "visible" flag and returns it in the
isVisible
method.
setVisible
in interface FormComponent
visible
- whether this form component should be visible or notAbstractFormComponent
,
ComponentTuple
,
FormComponent.isVisible()
public boolean isVisible()
FormComponent
setVisible
.
AbstractFormComponent
provides a default implementation for both isVisible
and setVisible
.
isVisible
in interface FormComponent
true
or false
.FormComponent.setVisible(boolean)
public void migrateIds(java.util.Map<java.lang.String,java.lang.String> oldIdToNewId)
FormComponent
FormEnvironment.getId
change. Form components that keep a list of IDs of other form components should migrate those IDs in this method.migrateIds
in interface FormComponent
oldIdToNewId
- a map that maps the old IDs to the new IDs. An ID is of type java.lang.String
.FormEnvironment.getId(FormComponent)
,
FormEnvironment.getFormComponentById(String)
public void requestFocus()
FormComponent
requestFocus
in interface FormComponent
public boolean hasUserInput()
FormComponent
hasUserInput
in interface FormComponent
public javax.swing.JComponent createLeftComponent()
FormComponent
In console or unattended mode, this method is never called.
createLeftComponent
in interface FormComponent
null
if no leading component should be created.public boolean isFillCenterVertical()
FormComponent
createCenterComponent
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.isFillCenterVertical
in interface FormComponent
true
or false
.FormComponent.createCenterComponent()
public javax.swing.JComponent createRightComponent()
FormComponent
In console or unattended mode, this method is never called.
createRightComponent
in interface FormComponent
null
if no trailing component should be created.public java.lang.Object getConfigurationObject()
FormComponent
getConfigurationObjectClass
method
returns null
, this method is not called, otherwise a non-null value of the type returned by
getConfigurationObjectClass
has to be returned by this method.
In console or unattended mode, this method is never called.
getConfigurationObject
in interface FormComponent
null
if getConfigurationObjectClass
returns null as well.FormComponent.getConfigurationObjectClass()
public java.lang.Class getConfigurationObjectClass()
FormComponent
JCheckBox
or a JTextField
. If you return a non-null value in the method,
the getConfigurationObject
method must return an object of that class.
In console or unattended mode, this method is never called.
getConfigurationObjectClass
in interface FormComponent
null
if no configuration object should be exposed.FormComponent.getConfigurationObject()
public boolean checkCompleted()
FormComponent
false
in this method.checkCompleted
in interface FormComponent
Context.setVariable(String, Object)
public void initialize()
FormComponent
Initialization often involves replacing variables in user-configured property values.
initialize
in interface FormComponent
AbstractBean.replaceVariables(String)
@Deprecated protected final void initalize()
public void formWillActivate()
FormComponent
formWillActivate
in interface FormComponent
Screen.willActivate()
public void formActivated()
FormComponent
formActivated
in interface FormComponent
Screen.activated()
public void formDeactivated()
FormComponent
formDeactivated
in interface FormComponent
Screen.deactivated()
public boolean handleConsole(Console console) throws UserCanceledException
FormComponent
Console
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 their
handleConsole
method, otherwise this method will not be invoked. All pre-defined screens
in install4j comply with this requirement.
handleConsole
in interface FormComponent
console
- the Console
objectUserCanceledException
- if the user cancels a question or notice. These exceptions are thrown by methods in the Console
object.Screen.handleConsole(Console)
,
FormEnvironment.handleConsole(Console)
public boolean handleUnattended()
FormComponent
handleUnattended
in interface FormComponent
protected java.lang.Object getInitValue(java.lang.Object defaultValue, java.lang.String variableName, java.lang.Class<?> valueClass)
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 contentpublic java.lang.String replaceFormVariables(java.lang.String value) throws UndefinedVariableException
AbstractBean.replaceVariables(String)
, only with the additional replacement of form variables.public java.lang.String replaceFormVariables(java.lang.String value, ReplacementMode replacementMode) throws UndefinedVariableException
AbstractBean.replaceVariables(String, ReplacementMode)
, only with the additional replacement of form variables.public java.lang.String replaceFormVariables(java.lang.String value, VariableErrorHandlingDescriptor errorHandlingDescriptor) throws UndefinedVariableException
AbstractBean.replaceVariables(String, VariableErrorHandlingDescriptor)
, only with the additional replacement of form variables.public java.lang.String replaceFormVariables(java.lang.String value, ReplacementMode replacementMode, VariableErrorHandlingDescriptor errorHandlingDescriptor) throws UndefinedVariableException
AbstractBean.replaceVariables(String, ReplacementMode, VariableErrorHandlingDescriptor)
, only with the additional replacement of form variables.public java.lang.String[] replaceFormVariables(java.lang.String[] values) throws UndefinedVariableException
AbstractBean.replaceVariables(String[])
, only with the additional replacement of form variables.public java.lang.String[] replaceFormVariables(java.lang.String[] values, VariableErrorHandlingDescriptor errorHandlingDescriptor) throws UndefinedVariableException
AbstractBean.replaceVariables(String[], VariableErrorHandlingDescriptor)
, only with the additional replacement of form variables.