public interface FormComponent
All form components must implement this interface. You have to override all methods and provide a public constructor with no arguments. It is recommended that you choose AbstractFormComponent as as a super class.
Form components are configurable in the install4j GUI for screens that return true in their hasFormPanel method. Their life-cycle is controlled by the framework.
Screen.hasFormPanel()
Method Summary | |
---|---|
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 |
createCenterComponent()
Create the main component in the center. |
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. |
boolean |
handleConsole(Console console)
Handle the console mode. |
boolean |
handleUnattended()
Handle the unattended mode. |
void |
initalize()
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 |
isFillCenterHorizontal()
Determine whether the center component created by createCenterComponent should fill all available horizontal space. |
boolean |
isVisible()
Returns whether the form component is visible or not. |
void |
migrateIds(java.util.Map oldItToNewId)
This method is only called at design time when a user pastes form components or a screen with form components from the clipboard. |
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. |
Method Detail |
---|
void setContext(Context context)
context
- the context.void setFormEnvironment(FormEnvironment formEnvironment)
At design time, this method is called repeatedly and the result of a call to getFormComponents() may be different over time.
formEnvironment
- the FormEnvironmentFormEnvironment.getFormComponents()
javax.swing.JComponent createLeftComponent()
In console or unattended mode, this method is never called.
javax.swing.JComponent createCenterComponent()
In console or unattended mode, this method is never called.
isFillCenterHorizontal()
boolean isFillCenterHorizontal()
createCenterComponent()
javax.swing.JComponent createRightComponent()
In console or unattended mode, this method is never called.
java.lang.Class getConfigurationObjectClass()
In console or unattended mode, this method is never called.
getConfigurationObject()
java.lang.Object getConfigurationObject()
In console or unattended mode, this method is never called.
getConfigurationObjectClass()
boolean checkCompleted()
Context.setVariable(String, Object)
void initalize()
Initialization often involves replacing variables in user-configured property values.
AbstractBean.replaceVariables(String)
void formWillActivate()
Screen.willActivate()
void formActivated()
Screen.activated()
void formDeactivated()
Screen.deactivated()
boolean handleConsole(Console console) throws UserCanceledException
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.
console
- the Console object
UserCanceledException
- if the user cancels a question or notice. These exceptions are thrown by methods in the Console object.Screen.handleConsole(com.install4j.api.screens.Console)
,
FormEnvironment.handleConsole(com.install4j.api.screens.Console)
boolean handleUnattended()
void setEnabled(boolean enabled)
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 all components in the ComponentTuple, saves the "enabled" flag and returns it in the isEnabled method.
enabled
- whether to enable this form component or notAbstractFormComponent
,
ComponentTuple
,
isEnabled()
boolean isEnabled()
AbstractFormComponent provides a default implementation for both isEnabled and setEnabled.
setEnabled(boolean)
void setVisible(boolean visible)
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.
visible
- whether this form component should be visible or notAbstractFormComponent
,
ComponentTuple
,
isVisible()
boolean isVisible()
AbstractFormComponent provides a default implementation for both isVisible and setVisible.
setVisible(boolean)
void migrateIds(java.util.Map oldItToNewId)
oldItToNewId
- 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)