com.izforge.izpack.installer.gui
Class IzPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.izforge.izpack.installer.gui.IzPanel
All Implemented Interfaces:
AbstractUIHandler, ISummarisable, LayoutConstants, ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants

public abstract class IzPanel
extends JPanel
implements AbstractUIHandler, LayoutConstants, ISummarisable

Defines the base class for the IzPack panels. Any panel should be a subclass of it and should belong to the com.izforge.izpack.panels package. Since IzPack version 3.9 the layout handling will be delegated to the class LayoutHelper which can be accessed by getLayoutHelper. There are some layout helper methods in this class which will be exist some time longer, but they are deprecated. At a redesign or new panel use the layout helper. There is a special layout manager for IzPanels. This layout manager will be supported by the layout helper. There are some points which should be observed at layouting. One point e.g. is the anchor. All IzPanels have to be able to use different anchors, as minimum CENTER and NORTHWEST. To use a consistent appearance use this special layout manger and not others.

Author:
Julien Ponge, Klaus Bartz
See Also:
Serialized Form

Nested Class Summary
static class IzPanel.Filler
           
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String DELIMITER
          DELIMITER = "." ( dot )
static String HEADLINE
          HEADLINE = "headline"
protected  JLabel headLineLabel
          internal headline Label
protected  Component initialFocus
          The component which should get the focus at activation
protected  GUIInstallData installData
          The installer internal data (actually a melting-pot class with all-public fields.
protected  LayoutHelper layoutHelper
          The helper object which handles layout
protected  InstallerFrame parent
          The parent IzPack installer frame.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface com.izforge.izpack.api.handler.AbstractUIHandler
ANSWER_CANCEL, ANSWER_NO, ANSWER_YES, CHOICES_YES_NO
 
Fields inherited from interface com.izforge.izpack.gui.LayoutConstants
ABSOLUTE_STRETCH, ALL_GAP, AUTOMATIC_GAP, CONTROL_CONSTRAINT, CONTROL_GAP, CONTROL_TO_LABEL_GAP, CONTROL_TO_TEXT_GAP, CURRENT_COLUMN, CURRENT_ROW, DEFAULT_CONTROL_ALIGNMENT, DEFAULT_LABEL_ALIGNMENT, DEFAULT_TEXT_ALIGNMENT, FILL_OUT_COLUMN_HEIGHT, FILL_OUT_COLUMN_SIZE, FILL_OUT_COLUMN_WIDTH, FILLER1_GAP, FILLER13_GAP, FILLER2_GAP, FILLER4_GAP, FILLER5_GAP, FULL_COLUMN_STRETCH, FULL_LINE_COMPONENT_CONSTRAINT, FULL_LINE_CONTROL_CONSTRAINT, FULL_LINE_STRETCH, GAP_LOAD_MARKER, LABEL_CONSTRAINT, LABEL_GAP, LABEL_TO_CONTROL_GAP, LABEL_TO_TEXT_GAP, NEXT_COLUMN, NEXT_LINE, NEXT_ROW, NO_FILL_OUT_COLUMN, NO_GAP, NO_STRETCH, PARAGRAPH_GAP, RELATIVE_STRETCH, TEXT_CONSTRAINT, TEXT_GAP, TEXT_TO_CONTROL_GAP, TEXT_TO_LABEL_GAP, TOP_GAP, XDUMMY_CONSTRAINT, XY_VARIABLE_CONSTRAINT, YDUMMY_CONSTRAINT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
IzPanel(Panel panel, InstallerFrame parent, GUIInstallData installData, LayoutManager2 layoutManager, Resources resources)
          Constructs an IzPanel with the given layout manager.
IzPanel(Panel panel, InstallerFrame parent, GUIInstallData installData, Resources resources)
          Constructs an IzPanel.
IzPanel(Panel panel, InstallerFrame parent, GUIInstallData installData, String iconName, Resources resources)
          Deprecated. 
 
Method Summary
 int askQuestion(String title, String question, int choices)
          Ask the user a question.
 int askQuestion(String title, String question, int choices, int defaultChoice)
          Ask the user a question.
 int askWarningQuestion(String title, String question, int choices, int defaultChoice)
           
 boolean canShowHelp()
          Indicates wether the panel can display help.
 void createInstallationRecord(IXMLElement rootElement)
           
 JLabel createLabel(String subkey, String alternateClass, String iconId, int pos, boolean isFullLine)
          Creates a label via LabelFactory using iconId, pos and method getI18nStringForClass for resolving the text to be used.
 MultiLineLabel createMultiLineLabel(String text)
          Creates a label via LabelFactory with the given text, the given icon id and the given horizontal alignment.
 MultiLineLabel createMultiLineLabelLang(String textId)
          Creates a multi line label with the language dependent text given by the text id.
 void emitError(String title, String message)
          Notify the user of some error.
 void emitNotification(String message)
          Notify the user about something.
 boolean emitNotificationFeedback(String message)
           
 boolean emitWarning(String title, String message)
          Warn the user about something.
 Font getControlTextFont()
          The Font of Labels in many cases
 String getI18nStringForClass(String subkey)
          Calls the langpack of parent InstallerFrame for the String RuntimeClassName.subkey.
 String getI18nStringForClass(String subkey, String alternateClass)
          Calls the langpack of parent InstallerFrame for the String RuntimeClassName.subkey.
 ImageIcon getImageIcon(String iconName)
          Gets a named image icon
 Component getInitialFocus()
          Returns the component which should be get the focus at activation of this panel.
 InstallerFrame getInstallerFrame()
          Returns the parent of this IzPanel (which is a InstallerFrame).
protected static MetalLookAndFeel getLAF()
           
 LayoutHelper getLayoutHelper()
          Returns the used layout helper.
 Panel getMetadata()
          Returns the panel metadata.
protected  Resources getResources()
          Returns the resources.
 String getString(String key)
          Helper to return a language resource string.
 String getSummaryBody()
          This method will be called from the SummaryPanel to get the summary of this class which should be placed in the SummaryPanel.
 String getSummaryCaption()
          This method will be called from the SummaryPanel to get the caption for this class which should be placed in the SummaryPanel.
protected  void initLayoutHelper()
          Inits and sets the internal layout helper object.
protected  boolean isValidated()
          Indicates wether the panel has been validated or not.
 void panelActivate()
          This method is called when the panel becomes active.
 void panelDeactivate()
          This method is called when the panel gets desactivated, when the user switches to the next panel.
 boolean panelValidated()
           
protected  String parseText(String string_to_parse)
          Parses the text for special variables.
protected  void saveData()
           
 void setHelpUrl(String helpUrl)
           
 void setInitialFocus(Component component)
          Sets the component which should be get the focus at activation of this panel.
 void showHelp()
          This method is called when Help button has been clicked.
 String toString()
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

layoutHelper

protected transient LayoutHelper layoutHelper
The helper object which handles layout


initialFocus

protected Component initialFocus
The component which should get the focus at activation


installData

protected final GUIInstallData installData
The installer internal data (actually a melting-pot class with all-public fields.


parent

protected final InstallerFrame parent
The parent IzPack installer frame.


headLineLabel

protected JLabel headLineLabel
internal headline Label


HEADLINE

public static final String HEADLINE
HEADLINE = "headline"

See Also:
Constant Field Values

DELIMITER

public static final String DELIMITER
DELIMITER = "." ( dot )

See Also:
Constant Field Values
Constructor Detail

IzPanel

public IzPanel(Panel panel,
               InstallerFrame parent,
               GUIInstallData installData,
               Resources resources)
Constructs an IzPanel.

Parameters:
panel - the panel meta-data
parent - the parent IzPack installer frame
installData - the installation data
resources - the resources

IzPanel

public IzPanel(Panel panel,
               InstallerFrame parent,
               GUIInstallData installData,
               LayoutManager2 layoutManager,
               Resources resources)
Constructs an IzPanel with the given layout manager.

Valid layout manager are the IzPanelLayout and GridBagLayout. New panels should be use IzPanelLayout. If layoutManager is null, no layout manager will be created or initialized.

Parameters:
panel - the panel meta-data
parent - the parent IzPack installer frame
installData - the installation data
layoutManager - layout manager to be used with this IzPanel
resources - the resources

IzPanel

@Deprecated
public IzPanel(Panel panel,
                          InstallerFrame parent,
                          GUIInstallData installData,
                          String iconName,
                          Resources resources)
Deprecated. 

Constructs an IzPanel.

Parameters:
panel - the panel meta-data
parent - the parent IzPack installer frame
installData - the installation data
iconName - the Headline icon name
resources - the resources
Method Detail

getString

public String getString(String key)
Helper to return a language resource string.

Parameters:
key - the search key
Returns:
the corresponding string, or key if the string is not found

getImageIcon

public ImageIcon getImageIcon(String iconName)
Gets a named image icon

Parameters:
iconName - a valid image icon
Returns:
the icon

initLayoutHelper

protected void initLayoutHelper()
Inits and sets the internal layout helper object.


isValidated

protected boolean isValidated()
Indicates wether the panel has been validated or not. The installer won't let the user go further through the installation process until the panel is validated. Default behaviour is to return true.

Returns:
A boolean stating whether the panel has been validated or not.

saveData

protected void saveData()

panelValidated

public boolean panelValidated()

panelActivate

public void panelActivate()
This method is called when the panel becomes active. Default is to do nothing : feel free to implement what you need in your subclasses. A panel becomes active when the user reaches it during the installation process.


panelDeactivate

public void panelDeactivate()
This method is called when the panel gets desactivated, when the user switches to the next panel. By default it doesn't do anything.


createInstallationRecord

public void createInstallationRecord(IXMLElement rootElement)

askQuestion

public int askQuestion(String title,
                       String question,
                       int choices)
Ask the user a question.

Specified by:
askQuestion in interface AbstractUIHandler
Parameters:
title - Message title.
question - The question.
choices - The set of choices to present.
Returns:
The user's choice.
See Also:
AbstractUIHandler.askQuestion(String, String, int)

askQuestion

public int askQuestion(String title,
                       String question,
                       int choices,
                       int defaultChoice)
Ask the user a question.

Specified by:
askQuestion in interface AbstractUIHandler
Parameters:
title - Message title.
question - The question.
choices - The set of choices to present.
defaultChoice - The default choice. (-1 = no default choice)
Returns:
The user's choice.
See Also:
AbstractUIHandler.askQuestion(String, String, int, int)

askWarningQuestion

public int askWarningQuestion(String title,
                              String question,
                              int choices,
                              int defaultChoice)
Specified by:
askWarningQuestion in interface AbstractUIHandler

emitNotificationFeedback

public boolean emitNotificationFeedback(String message)

emitNotification

public void emitNotification(String message)
Notify the user about something.

Specified by:
emitNotification in interface AbstractUIHandler
Parameters:
message - The notification.

emitWarning

public boolean emitWarning(String title,
                           String message)
Warn the user about something.

Specified by:
emitWarning in interface AbstractUIHandler
Parameters:
message - The warning message.

emitError

public void emitError(String title,
                      String message)
Notify the user of some error.

Specified by:
emitError in interface AbstractUIHandler
Parameters:
message - The error message.

getInitialFocus

public Component getInitialFocus()
Returns the component which should be get the focus at activation of this panel.

Returns:
the component which should be get the focus at activation of this panel

setInitialFocus

public void setInitialFocus(Component component)
Sets the component which should be get the focus at activation of this panel.

Parameters:
component - which should be get the focus at activation of this panel

getI18nStringForClass

public String getI18nStringForClass(String subkey)
Calls the langpack of parent InstallerFrame for the String RuntimeClassName.subkey. Do not add a point infront of subkey, it is always added in this method. If RuntimeClassName.subkey is not found, the super class name will be used until it is IzPanel. If no key will be found, null returns.

Parameters:
subkey - the subkey for the string which should be returned
Returns:
the founded string

getI18nStringForClass

public String getI18nStringForClass(String subkey,
                                    String alternateClass)
Calls the langpack of parent InstallerFrame for the String RuntimeClassName.subkey. Do not add a point infront of subkey, it is always added in this method. If no key will be found the key or - if alternate class is null - null returns.

Parameters:
subkey - the subkey for the string which should be returned
alternateClass - the short name of the class which should be used if no string is present with the runtime class name
Returns:
the founded string

getInstallerFrame

public InstallerFrame getInstallerFrame()
Returns the parent of this IzPanel (which is a InstallerFrame).

Returns:
the parent of this IzPanel

createLabel

public JLabel createLabel(String subkey,
                          String alternateClass,
                          String iconId,
                          int pos,
                          boolean isFullLine)
Creates a label via LabelFactory using iconId, pos and method getI18nStringForClass for resolving the text to be used. If the icon id is null, the label will be created also. If isFullLine true a LabelFactory.FullLineLabel will be created instead of a JLabel. The difference between both classes are a different layout handling.

Parameters:
subkey - the subkey which should be used for resolving the text
alternateClass - the short name of the class which should be used if no string is present with the runtime class name
iconId - id string for the icon
pos - horizontal alignment
isFullLine - determines whether a FullLineLabel or a JLabel should be created
Returns:
the newly created label

createMultiLineLabelLang

public MultiLineLabel createMultiLineLabelLang(String textId)
Creates a multi line label with the language dependent text given by the text id. The strings is the id for the text in langpack of the installer frame. The horizontal alignment will be LEFT.

Parameters:
textId - id string for the text
Returns:
the newly created multi line label

createMultiLineLabel

public MultiLineLabel createMultiLineLabel(String text)
Creates a label via LabelFactory with the given text, the given icon id and the given horizontal alignment. If the icon id is null, the label will be created also. The strings are the ids for the text in langpack and the icon in icons of the installer frame.

Parameters:
text - text to be used in the label
Returns:
the created multi line label

getControlTextFont

public Font getControlTextFont()
The Font of Labels in many cases


getLAF

protected static MetalLookAndFeel getLAF()

getSummaryBody

public String getSummaryBody()
This method will be called from the SummaryPanel to get the summary of this class which should be placed in the SummaryPanel. The returned text should not contain a caption of this item. The caption will be requested from the method getCaption. If null returns, no summary for this panel will be generated. Default behaviour is to return null.

Specified by:
getSummaryBody in interface ISummarisable
Returns:
the summary for this class

getSummaryCaption

public String getSummaryCaption()
This method will be called from the SummaryPanel to get the caption for this class which should be placed in the SummaryPanel. If null returns, no summary for this panel will be generated. Default behaviour is to return the string given by langpack for the key <current class name>.summaryCaption> if exist, else the string "summaryCaption.<ClassName>".

Specified by:
getSummaryCaption in interface ISummarisable
Returns:
the caption for this class

getLayoutHelper

public LayoutHelper getLayoutHelper()
Returns the used layout helper. Can be used in a derived class to create custom layout.

Returns:
the used layout helper

getMetadata

public Panel getMetadata()
Returns the panel metadata.

Returns:
the panel metadata

parseText

protected String parseText(String string_to_parse)
Parses the text for special variables.


canShowHelp

public boolean canShowHelp()
Indicates wether the panel can display help. The installer will hide Help button if current panel does not support help functions. Default behaviour is to return false.

Returns:
A boolean stating wether the panel supports Help function.

showHelp

public void showHelp()
This method is called when Help button has been clicked. By default it doesn't do anything.


setHelpUrl

public void setHelpUrl(String helpUrl)

toString

public String toString()
Overrides:
toString in class Component

getResources

protected Resources getResources()
Returns the resources.

Returns:
the resources


Copyright © 2018. All rights reserved.