Statistics
| Revision:

svn-gvsig-desktop / tags / v1_2_Build_1200 / install / IzPack / src / doc / chapter5.tex @ 38629

History | View | Annotate | Download (3.55 KB)

1 5819 cesar
% Chapter 5
2
\chapter{Creating Your Own Panels}
3
4
\section{How It Works}
5
6
\subsection{What You Need}
7
8
First you have to read the NanoXML documentation if you need to use XML
9
in your panel. Secondly, it is necessary that you use the
10
Javadoc-generated class references. We will just explain here briefly
11
how to start making your panels.\\
12
13
It is a good idea to read the source code of some IzPack panels. They
14
are usually \textsl{very} small, which makes it easier to understand how
15
to write your own.\\
16
17
\subsection{What You Have To Do}
18
19
Extending \IzPack with a panel is quite simple. A panel used with
20
\IzPack must be a subclass of \texttt{IzPanel}. The \texttt{IzPanel}
21
class is located in the \texttt{com.izforge.izpack.installer} package
22
but your panels need to belong to \texttt{com.izforge.izpack.panels}.\\
23
24
Things will get a good deal easier if you build IzPack with Jakarta Ant.
25
Simply add your class in the source tree and add the And directives to
26
build your own panels. In this way you'll be able to focus on your code
27
:-)\\
28
29
\section{The \texttt{IzPanel} Class}
30
31
\subsection{UML Diagram}
32
33
\begin{center}
34
\fbox{\includegraphics[scale=0.5]{img/ch5-izpanel}}
35
\end{center}\
36
37
\subsection{Description}
38
39
The data members are : the install data (refer to the \texttt{InstallData}
40
Javadoc reference) and a reference to the parent installer frame.
41
Additional there are the initialFocus Component and some members for
42
handling the grid bag constraint.\\
43
44
The methods have the following functionality :\\
45
\begin{itemize}
46
47
  \item \textit{(constructor)} : called just after the language
48
  selection dialog. All the panels are constructed at this time and then
49
  the installer is shown. So be aware of the fact that the installer
50
  window is \textbf{not} yet visible when the panel is created. If you
51
  need to do some work when the window is created, it is in most cases
52
  better do it in \texttt{panelActivate}.\\
53
54
  \item \texttt{isValidated} returns \texttt{true} if the user is
55
  allowed to go a step further in the installation process. Returning
56
  \texttt{false} will lock it. For instance the LicencePanel returns
57
  \texttt{true} only if the user has agreed with the license agreement.
58
  The default is to return \texttt{true}.\\
59
60
  \item \texttt{panelActivate} is called when the panel becomes active.
61
  This is the best place for most initialization tasks. The default is
62
  to do nothing.\\
63
64
  \item \texttt{makeXMLData} is called to build the automated installer
65
  data. The default is to do nothing. \texttt{panelRoot} refers to the
66
  node in the XML tree where you can save your data. Each panel is given
67
  a node. You can organize it as you want with the markups you want
68
  starting from \texttt{panelRoot}. It's that simple.\\
69
70
  \item \texttt{runAutomated} is called by an automated-mode
71
  installation. Each panel is called and can do its job by picking the
72
  data collected during a previous installation as saved in
73
  \texttt{panelRoot} by \texttt{makeXMLData}.\\
74
75
  \item \texttt{setInitialFocus} with this method it is possible to set
76
  a hint which component should be get the focus at activation of the
77
  panel. It is only a hint. Not all components are supported. For more
78
  information see java.awt.Component.requestFocusInWindow or
79
  java.awt.Component.requestFocus if the VM version is less than 1.4.\\
80
81
  \item \texttt{getInitialFocus} returns the component which should be get the
82
  focos at activation of the panel. If no component was set, null returns.\\
83
84
\end{itemize}\
85
Additional there are some helper methods to simplify grid bag layout handling
86
and creation of some common used components.