com.izforge.izpack.installer.panel
Class AbstractPanelView<T>

java.lang.Object
  extended by com.izforge.izpack.installer.panel.AbstractPanelView<T>
All Implemented Interfaces:
PanelView<T>
Direct Known Subclasses:
AutomatedPanelView, ConsolePanelView, IzPanelView

public abstract class AbstractPanelView<T>
extends Object
implements PanelView<T>

Encapsulates a Panel and its user-interface representation.

Author:
Tim Anderson

Constructor Summary
AbstractPanelView(Panel panel, Class<T> viewClass, ObjectFactory factory, InstallData installData)
          Constructs a PanelView.
 
Method Summary
 boolean canShow()
          Determines if the panel can be shown.
 IXMLElement createPanelRootRecord()
          Creates an empty root element prepared for adding auto-installation records for this panel.
protected  T createView(Panel panel, Class<T> viewClass)
          Creates a new view.
 void executePostValidationActions()
          Executes actions after validating the panel.
 void executePreActivationActions()
          Executes actions prior to activating the panel.
 void executePreValidationActions()
          Executes actions prior to validating the panel.
protected  ObjectFactory getFactory()
          Returns the factory.
protected abstract  AbstractUIHandler getHandler()
          Returns a handler to prompt the user.
 int getIndex()
          Returns the panel index.
protected  String getMessage(String id)
          Helper to return a localised message, given its id.
 Panel getPanel()
          Returns the panel.
 String getPanelId()
          Returns the panel identifier.
 T getView()
          Returns the panel user interface.
protected  void initialise(T view, Panel panel, InstallData installData)
          Initialises the view.
 boolean isValid()
          Determines if the panel is valid.
 boolean isValid(boolean refreshVariables)
          Determines if the panel is valid.
 boolean isVisible()
          Determines the visibility of the panel.
protected  boolean isWarningValid(String message, boolean defaultAnswer)
          Determines the behaviour when a warning is encountered during validation.
 void saveData()
          Save the contents of the panel into install data.
 void setIndex(int index)
          Sets the panel index.
 void setVisible(boolean visible)
          Sets the visibility of the panel.
protected  boolean validateData()
          Evaluates the panel data validator.
protected  boolean validateDynamicConditions()
          Validates dynamic conditions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.izforge.izpack.installer.panel.PanelView
createInstallationRecord
 

Constructor Detail

AbstractPanelView

public AbstractPanelView(Panel panel,
                         Class<T> viewClass,
                         ObjectFactory factory,
                         InstallData installData)
Constructs a PanelView.

Parameters:
panel - the panel
viewClass - the panel user interface class
factory - the factory for creating the view
installData - the installation data
Method Detail

getPanelId

public String getPanelId()
Returns the panel identifier.

Specified by:
getPanelId in interface PanelView<T>
Returns:
the panel identifier

getPanel

public Panel getPanel()
Returns the panel.

Specified by:
getPanel in interface PanelView<T>
Returns:
the panel

getIndex

public int getIndex()
Returns the panel index.
This is the offset of the panel relative to the other panels, visible or not.

Specified by:
getIndex in interface PanelView<T>
Returns:
the panel index

setIndex

public void setIndex(int index)
Sets the panel index.

Specified by:
setIndex in interface PanelView<T>
Parameters:
index - the index

getView

public T getView()
Returns the panel user interface.
The view will be created if it doesn't exist.
If the panel has a DataValidator specified, this will be constructed, with both the panel and view supplied for injection into it's constructor.

Specified by:
getView in interface PanelView<T>
Returns:
the panel user interface

setVisible

public void setVisible(boolean visible)
Sets the visibility of the panel.

Specified by:
setVisible in interface PanelView<T>
Parameters:
visible - if true the panel is visible, otherwise it is hidden

isVisible

public boolean isVisible()
Determines the visibility of the panel.

Specified by:
isVisible in interface PanelView<T>
Returns:
true if the panel is visible, false if it is hidden

isValid

public boolean isValid()
Determines if the panel is valid. Dynamic variables are automatically refreshed.

Specified by:
isValid in interface PanelView<T>
Returns:
true if the panel is valid

isValid

public boolean isValid(boolean refreshVariables)
Determines if the panel is valid.

Specified by:
isValid in interface PanelView<T>
Parameters:
refreshVariables - whether to refresh dynamic variables before validating
Returns:
true if the panel is valid

saveData

public void saveData()
Save the contents of the panel into install data.

Specified by:
saveData in interface PanelView<T>

canShow

public boolean canShow()
Determines if the panel can be shown.

Specified by:
canShow in interface PanelView<T>
Returns:
true if the panel can be shown

executePreActivationActions

public void executePreActivationActions()
Executes actions prior to activating the panel.


executePreValidationActions

public void executePreValidationActions()
Executes actions prior to validating the panel.


executePostValidationActions

public void executePostValidationActions()
Executes actions after validating the panel.


getHandler

protected abstract AbstractUIHandler getHandler()
Returns a handler to prompt the user.

Returns:
the handler

createView

protected T createView(Panel panel,
                       Class<T> viewClass)
Creates a new view.

Parameters:
panel - the panel to create the view for
viewClass - the view base class
Returns:
the new view

initialise

protected void initialise(T view,
                          Panel panel,
                          InstallData installData)
Initialises the view.
This implementation is a no-op.

Parameters:
view - the view to initialise
panel - the panel the view represents
installData - the installation data

validateDynamicConditions

protected boolean validateDynamicConditions()
Validates dynamic conditions.

Returns:
true if there are no conditions, or conditions validate successfully

validateData

protected boolean validateData()
Evaluates the panel data validator.

Returns:
true if the validator evaluated successfully, or with a warning that the user chose to skip; otherwise false

isWarningValid

protected boolean isWarningValid(String message,
                                 boolean defaultAnswer)
Determines the behaviour when a warning is encountered during validation.

Parameters:
message - the validation message. May be null
defaultAnswer - the default response for warnings
Returns:
true if the warning doesn't invalidate the panel; false if it does

getFactory

protected ObjectFactory getFactory()
Returns the factory.

Returns:
the factory

getMessage

protected String getMessage(String id)
Helper to return a localised message, given its id.

Parameters:
id - the message identifier
Returns:
the corresponding message or null if none is found

createPanelRootRecord

public final IXMLElement createPanelRootRecord()
Creates an empty root element prepared for adding auto-installation records for this panel.

Returns:
IXMLElement The prepared panel record XML


Copyright © 2018. All rights reserved.