Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
IzPack
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h1>Creating Your Own Panels</h1> <p>In IzPack all of the actual work of installing an application is done in panels. The IzPack framework is primarily there to support the operation of the panels and to manage the navigation through the installation process. This enables a user to decide which operations are carried out during an installation and the order in which they are carried out, simply by listing the appropriate panels in the desired order.</p> <p>As far as extending the functionality of IzPack is concerned, the result of this design is that new functionality can be integrated by adding new panels to the framework and then listing them in the install spec. Because the existing panels all have a visible GUI and because the term panel hints at something visible, it is not obvious that a panel does not have to contain any visible GUI to function in this framework. There are more details on this subject later on in this chapter.</p> <h2>How to get started</h2> <p>To get started with writing your own panels, it is best to place all the IzPack code into a separate working directory, from where you can compile it. Then try to compile the code as is and get that to work.</p> <p>The next step would be to have a look at another panel implementation, so you can see how things are done. Make sure you look at the less complicated panels, as the panels with advanced features will only be confusing. All the code for building UI and such, only detracts from the essentials of what a panel needs to do. This means that you shouldn't start with <code>UserInputPanel</code> or <code>ShortcutPanel</code>. <code>HelloPanel</code> is probably a much better choice at this stage. The source code for panels is located at: <code>/src/lib/com/izforge/izpack/panels</code>.</p> <p>You will find that all panels are derived from <code>IzPanel</code>; do the same thing with your new panel. Please note that the <code>IzPanel</code> class itself is located in the <code>com.izforge.izpack.installer</code> package but your panels need to belong to <code>com.izforge.izpack.panels</code>. Perhaps you can just copy the code of a panel, remove all the functional stuff and then start filling in your own code. Start with something very simple to begin with, just to see how it works. The implementation is really quite straight forward.</p> <h2>Next Steps</h2> <p>Once you have a successful compilation, you must place the compiled result of your panel code at a special place, so that the installer compiler can fetch it when building an installer that uses your panel. Go to: <code>/bin/panels</code></p> <p>You will see that there is a subdirectory for each panel. Make a subdirectory for your new panel with the exact same name as your panel and place your compiled panel code there.</p> <p>Once this is accomplished, you are ready to use your panel in an installer. Just list it in the spec file like any other panel, compile and in theory it will show up when running the installer. Once you made it this far, you can dig deeper and get going with your specific needs.</p> <p>Oh, and one other thing: If you think the your code might be useful for a larger audience, please think about a contribution to IzPack.</p> <h2>Access to the Variable Substitution System</h2> <p>One thing many developers ask about is how to get access to the variable substitution system. This is not surprising, because customizing an installation for a particular target environment is one of the most important functions of an installer and the variable substitution system plays a big part in this operation.</p> <p>You can get access to the variable substitution system through the protected variable <code>idata</code> in <code>IzPanel</code>. This variable is of the type <code>InstallData</code>, which is in turn subclassed from <code>AutomatedInstallData</code>. The Javadoc documentation will give you more details on these classes. Of particular interest in this context are the methods <code>getVariable()</code>, <code>setVariable()</code> and <code>getVariableValueMap()</code> in <code>AutomatedInstallData</code>.</p> <h2>Controlling Flow</h2> <p>Some of the interesting methods in <code>com.izforge.izpack.InstallerFrame</code> that you might want to explore are <code>lockPrevButton()</code> and <code>lockNextButton()</code>. They allow you to block the use of the button to move back to the previous panel and the button that moves to the next panel respectively. Being able to control the availability of these buttons to the user is important if one of your panels performs a task where the effects cannot be undone. If the user would navigate back to the previous panel your installation might get into an unknown or even unstable state. On the other hand, if the operations in one panel vitally depend that a task in the previous panel is completed, then you should block the use of the next button until that task is completed.</p> <h2>Reading XML</h2> <p>If you need configuration files for your panel you would want to use XML for that purpose. To read XML files you should use NanoXML, as it is guaranteed to be available at installation time. In fact, all of the IzPack infrastructure uses NanoXML to read XML files. First you should read the NanoXML documentation. The documentation is included as PDF file with the IzPack distribution, have a look in <code>/doc/nanoxml</code>. In addition to that, the Javadoc-generated class documentation is an excellent resource to get help on NanoXML. And then, there is always the code of other panels to see practical examples. Generally, it is a much simpler matter to use NanoXML then to use the DOM included with the Java distribution, so don't hesitate to explore NanoXML.</p> <h2>Supporting Classes</h2> <p>If your panel requires any supporting classes that are part of the panels package, then you must place the .class files into the same directory with your panel .class file.</p> <p>It is also possible to have supporting classes that are not part of the panels package. In fact, these classes don't even have to be in the <code>com.izpack...</code> tree. You simply have to ensure that the .class files are located in the proper directory structure inside <code>/lib/installer.jar</code>. If this is done, they will be available at install time. For your first experiments you can simply compile your classes and add them to the .jar file using the jar tool or a zip utility. However, ultimately it is much easier to use Ant and the IzPack build script to accomplish this task.</p> <h2>Panels that are not visible</h2> <p>If you have a task that needs to be performed at a particular step in the installation process, but that does not need any user interaction, you can implement a panel that is not visible. To implement this, you should first familiarize yourself with the Javadoc documentation of <code>com.izforge.izpack.InstallerFrame</code>. In your panel code you get access to the right instance of <code>InstallerFrame</code> through the protected variable <code>parent</code> in <code>IzFrame</code>.</p> <p>To begin with, do not configure any UI. In other words, do not set a layout and do not place any GUI elements on your panel. In this context the method <code>skipPanel()</code> is what gets the job done. In your <code>panelActivate()</code> method you simply perform your task and then call <code>parent.skipPanel()</code>. This gets the job done without the user being aware that there was another panel in the flow.</p> <h2>A word about building IzPack</h2> <p>If you don't already use Jakarta Ant to support your development work, i highly recommend you have a look at it. It is a great help in organizing practically all routine tasks connected with building and packaging your application. For example, building and getting IzPack ready for distribution is not a straight forward process but with Ant this all comes down to starting a single command. In addition, IzPack provides its own Ant task, which supports the integration of building a complete installer into your regular build scripts. You can find more details about this in the chapter about advanced features. To get a look at Ant you can visit the following link: <a href="http://ant.apache.org/index.html.">http://ant.apache.org/index.html.</a></p> <p>You can find the Ant build script for IzPack itself at: <code>/src/build.xml</code></p> <h2>The <code>IzPanel</code> Class</h2> <p><img class="confluence-embedded-image" src="/plugins/servlet/confluence/placeholder/unknown-attachment?locale=en_GB&version=2" title="izpanel-uml-diag.png" data-resource-id="PHJpOmF0dGFjaG1lbnQgcmk6ZmlsZW5hbWU9Iml6cGFuZWwtdW1sLWRpYWcucG5nIiAvPg=="><br /> The two data members are : the install data (refer to the <code>InstallData</code> Javadoc reference) and a reference to the parent installer frame.</p> <p>The methods have the following functionality :</p> <table class="wysiwyg-macro" data-macro-name="panel" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e3BhbmVsfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"> <p> <strong><em>(constructor)</em> : called just after the language selection dialog. All the panels are constructed at this time and then the installer is shown. So be aware of the fact that the installer window is*not</strong> yet visible when the panel is created. If you need to do some work when the window is created, it is in most cases better do it in <code>panelActivate</code>.</p></td></tr></table> <ul> <li><code>isValidated</code> returns <code>true</code> if the user is allowed to go a step further in the installation process. Returning <code>false</code> will lock it. For instance the LicencePanel returns <code>true</code> only if the user has agreed with the license agreement. The default is to return <code>true</code>.</li> <li><code>panelActivate</code> is called when the panel becomes active. This is the best place for most initialization tasks. The default is to do nothing.</li> <li><code>makeXMLData</code> is called to build the automated installer data. The default is to do nothing. <code>panelRoot</code> refers to the node in the XML tree where you can save your data. Each panel is given a node. You can organize it as you want with the markups you want starting from <code>panelRoot</code>. It's that simple.</li> <li><code>runAutomated</code> is called by an automated-mode installation. Each panel is called and can do its job by picking the data collected during a previous installation as saved in <code>panelRoot</code> by <code>makeXMLData</code>.</li> <li><code>setInitialFocus</code> with this method it is possible to set a hint which component should be get the focus at activation of the panel. It is only a hint. Not all components are supported. For more information see java.awt.Component.requestFocusInWindow or java.awt.Component.requestFocus if the VM version is less than 1.4.</li> <li><code>getInitialFocus</code> returns the component which should be get the focos at activation of the panel. If no component was set, null returns.</li> <li><code>getSummaryBody</code> 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 enerated. Default behaviour is to return null.</li> <li><code>getSummaryCaption</code> this method will be called from the SummaryPanel to get the caption for this class which should be placed in the SummaryPanel. Default behaviour is to return the string given by langpack for the key ClassName.summaryCaption.</li> </ul> <p>Additionally, there are some helper methods to simplify grid bag layout handling and creation of some common used components.</p> <h2>The <code>Internationalization</code> of custom panels</h2> <p>A common way to define language dependant messages for custom panels is to add entries into the common langpacks which are stored in the directory</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>[IzPackRoot]/bin/langpacks/installer</pre></td></tr></table> <p>New with version 3.8 is the possibility to define a resource for custom langpacks. Define e.g.</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><resources> ... <res id="CustomLangpack.xml_deu" src="myConfigSubPath/CustomLangpack_deu.xml"/> ... </resources></pre></td></tr></table> <p>in the install.xml file.The id should be written as shown, the file sub path and name can be other than in the example. This file should be using the same DTD as the common langpack. For each language a separate file with the ISO3 extension in the id should be used.</p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced