### Eclipse Workspace Patch 1.0 #P IzPack_SVN Index: src/lib/com/izforge/izpack/installer/ResourceManager.java =================================================================== --- src/lib/com/izforge/izpack/installer/ResourceManager.java (Revision 2934) +++ src/lib/com/izforge/izpack/installer/ResourceManager.java (Arbeitskopie) @@ -21,12 +21,13 @@ package com.izforge.izpack.installer; -import javax.swing.*; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import javax.swing.ImageIcon; + /** * With this ResourceManager you are able to get resources from the jar file. *
@@ -34,14 +35,13 @@ * language dependent resource just append '_' and the locale to the end of the Resourcenamecreate by the installer
* and later, the instance is retrieved using getInstance.
- *
+ *
* @author Marcus Stursberg
*/
public class ResourceManager
@@ -55,10 +55,17 @@
private String locale = "";
/**
+ * Contains current bundle name. The bundleName is taken from
+ * InstallData#installData#getVariable("resource.bundle.system.property") If there is no bundle
+ * name set, it stays null.
+ */
+ private String bundleName = null;
+
+ /**
* The base path where to find the resources: resourceBasePathDefaultConstant = "/res/"
*/
public final String resourceBasePathDefaultConstant = "/res/";
-
+
/** Internel used resourceBasePath = "/res/" */
protected String resourceBasePath = "/res/";
@@ -74,7 +81,7 @@
/**
* Constructor. Protected because this is a singleton.
- *
+ *
* @param data - the current installData
*/
protected ResourceManager(AutomatedInstallData data)
@@ -89,7 +96,13 @@
// try to figure out ourself
this.locale = installData.xmlData.getAttribute("langpack", "eng");
}
-
+ final String systemPropertyBundleName = this.installData
+ .getVariable("resource.bundle.system.property");
+ if (systemPropertyBundleName != null)
+ {
+ setBundleName(System.getProperty(systemPropertyBundleName));
+ }
+
}
/**
@@ -98,7 +111,7 @@
* This method should be called only once. If it is called a second time, the already existing
* instance is returned. The resource manager should be called after the language has
* been set in {@link AutomatedInstallData#localeISO3}
- *
+ *
* @param data the installation information
* @return the created instance
*/
@@ -114,77 +127,81 @@
/**
* Return the resource manager.
- *
+ *
* @return the resource manager instance, null if no instance has been created
*/
public static ResourceManager getInstance()
{
if (ResourceManager.instance == null)
{
- ResourceManager.instance = new ResourceManager( new AutomatedInstallData() );
+ ResourceManager.instance = new ResourceManager(new AutomatedInstallData());
}
return ResourceManager.instance;
}
-
+
/**
- * If null was given the Default BasePath "/res/" is set
- * If otherwise the Basepath is set to the given String.
- * This is useful if someone needs direct access to Reosurces in the jar.
+ * If null was given the Default BasePath "/res/" is set If otherwise the basepath is set to the
+ * given String. This is useful if someone needs direct access to Resources in the jar.
+ *
* @param aDefaultBasePath If null was given the DefaultBasepath is re/set "/res/"
*/
- public void setDefaultOrResourceBasePath( String aDefaultBasePath )
+ public void setDefaultOrResourceBasePath(String aDefaultBasePath)
{
- // For direct access of named resources the BasePath should be empty
- if( null != aDefaultBasePath )
- this.resourceBasePath = aDefaultBasePath;
- else
- this.resourceBasePath = resourceBasePathDefaultConstant;
+ // For direct access of named resources the BasePath should be empty
+ if (null != aDefaultBasePath)
+ this.resourceBasePath = aDefaultBasePath;
+ else
+ this.resourceBasePath = resourceBasePathDefaultConstant;
}
-
/**
* This method is used to get the language dependent path of the given resource. If there is a
- * resource for the current language the path of the language dependen resource is returnd. If
- * there's no resource for the current lanuage the default path is returned.
- *
- * @param resource Resource to load language dependen
+ * resource for the current language the path of the language dependent resource is returned. If
+ * there's no resource for the current language the default path is returned.
+ *
+ * @param resource Resource to load language dependent
* @return the language dependent path of the given resource
* @throws ResourceNotFoundException If the resource is not found
*/
private String getLanguageResourceString(String resource) throws ResourceNotFoundException
{
- InputStream in;
- String resourcePath = this.resourceBasePath + resource + "_" + this.locale;
-
- in = ResourceManager.class.getResourceAsStream(resourcePath);
- if (in != null)
+ String localeSuffix = "_" + this.locale;
+ String resourcePath = getBundlePath() + resource + localeSuffix;
+ if (resourceExists(resourcePath)) { return resourcePath; }
+
+ // if there's no language dependent resource found
+ resourcePath = getBundlePath() + resource;
+ if (resourceExists(resourcePath)) { return resourcePath; }
+
+ resourcePath = this.resourceBasePath + resource + localeSuffix;
+ if (resourceExists(resourcePath)) { return resourcePath; }
+
+ // if there's no language dependent resource found
+ resourcePath = this.resourceBasePath + resource;
+ if (resourceExists(resourcePath)) { return resourcePath; }
+
+ throw new ResourceNotFoundException("Cannot find named Resource: '" + getBundlePath()
+ + resource + "', '" + getBundlePath() + resource + localeSuffix + "'" + ", '"
+ + this.resourceBasePath + resource + "' AND '" + this.resourceBasePath + resource
+ + localeSuffix + "'");
+ }
+
+ private boolean resourceExists(String resourcePath)
+ {
+ boolean result = true;
+ InputStream in = ResourceManager.class.getResourceAsStream(resourcePath);
+ if (in == null)
{
-
- return resourcePath;
+ result = false;
}
-
- else
- {
- // if there's no language dependent resource found
- resourcePath = this.resourceBasePath + resource;
- in = ResourceManager.class.getResourceAsStream(resourcePath);
- if (in != null)
- {
- return resourcePath;
- }
- else
- {
- throw new ResourceNotFoundException( "Cannot find named Resource: '" + this.resourceBasePath + resource + "' AND '" + this.resourceBasePath + resource + "_" + this.locale + "'" );
- }
- }
-
+ return result;
}
/**
* Returns an InputStream contains the given Resource The Resource is loaded language dependen
* by the informations from this.locale If there is no Resource for the current
* language found, the default Resource is given.
- *
+ *
* @param resource The resource to load
* @return an InputStream contains the requested resource
* @throws ResourceNotFoundException Description of the Exception
@@ -199,7 +216,7 @@
/**
* Returns a URL refers to the given Resource
- *
+ *
* @param resource the resource to load
* @return A languagedependen URL spezifies the requested resource
* @throws ResourceNotFoundException Description of the Exception
@@ -221,15 +238,16 @@
/**
* Returns a text resource from the jar file. The resource is loaded by
* ResourceManager#getResource and then converted into text.
- *
+ *
* @param resource - a text resource to load
* @param encoding - the encoding, which should be used to read the resource
* @return a String contains the text of the resource
* @throws ResourceNotFoundException if the resource can not be found
- * @throws IOException if the resource can not be loaded
+ * @throws IOException if the resource can not be loaded
*/
// Maybe we can add a text parser for this method
- public String getTextResource(String resource, String encoding) throws ResourceNotFoundException, IOException
+ public String getTextResource(String resource, String encoding)
+ throws ResourceNotFoundException, IOException
{
InputStream in = null;
try
@@ -262,11 +280,11 @@
/**
* Returns a text resource from the jar file. The resource is loaded by
* ResourceManager#getResource and then converted into text.
- *
+ *
* @param resource - a text resource to load
* @return a String contains the text of the resource
* @throws ResourceNotFoundException if the resource can not be found
- * @throws IOException if the resource can not be loaded
+ * @throws IOException if the resource can not be loaded
*/
// Maybe we can add a text parser for this method
public String getTextResource(String resource) throws ResourceNotFoundException, IOException
@@ -276,11 +294,11 @@
/**
* Returns a laguage dependent ImageIcon for the given Resource
- *
+ *
* @param resource resrouce of the Icon
* @return a ImageIcon loaded from the given Resource
* @throws ResourceNotFoundException thrown when the resource can not be found
- * @throws IOException if the resource can not be loaded
+ * @throws IOException if the resource can not be loaded
*/
public ImageIcon getImageIconResource(String resource) throws ResourceNotFoundException,
IOException
@@ -292,7 +310,7 @@
* Sets the locale for the resourcefiles. The locale is taken from
* InstallData#installData#getAttribute("langpack") If there is no language set, the default
* language is english.
- *
+ *
* @param locale of the resourcefile
*/
public void setLocale(String locale)
@@ -304,11 +322,31 @@
* Returns the locale for the resourcefiles. The locale is taken from
* InstallData#installData#getAttribute("langpack") If there is no language set, the default
* language is english.
- *
+ *
* @return the current language
*/
public String getLocale()
{
return this.locale;
}
+
+ protected void setBundleName(String bundleName)
+ {
+ this.bundleName = bundleName;
+ }
+
+ protected String getBundleName()
+ {
+ return this.bundleName;
+ }
+
+ private String getBundlePath()
+ {
+ String basePath = this.resourceBasePath;
+ if (this.bundleName != null)
+ {
+ basePath += this.bundleName + "/";
+ }
+ return basePath;
+ }
}
Index: src/lib/com/izforge/izpack/installer/InstallerFrame.java
===================================================================
--- src/lib/com/izforge/izpack/installer/InstallerFrame.java (Revision 2934)
+++ src/lib/com/izforge/izpack/installer/InstallerFrame.java (Arbeitskopie)
@@ -22,7 +22,69 @@
package com.izforge.izpack.installer;
-import com.izforge.izpack.*;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GraphicsEnvironment;
+import java.awt.GridBagConstraints;
+import java.awt.GridLayout;
+import java.awt.Point;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusAdapter;
+import java.awt.event.KeyAdapter;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseMotionAdapter;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.lang.reflect.Constructor;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipOutputStream;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.JSeparator;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.WindowConstants;
+import javax.swing.border.TitledBorder;
+import javax.swing.text.JTextComponent;
+
+import com.izforge.izpack.CustomData;
+import com.izforge.izpack.ExecutableFile;
+import com.izforge.izpack.Info;
+import com.izforge.izpack.LocaleDatabase;
import com.izforge.izpack.Panel;
import com.izforge.izpack.adaptator.IXMLElement;
import com.izforge.izpack.adaptator.IXMLParser;
@@ -34,30 +96,24 @@
import com.izforge.izpack.gui.EtchedLineBorder;
import com.izforge.izpack.gui.IconsDatabase;
import com.izforge.izpack.rules.RulesEngine;
-import com.izforge.izpack.util.*;
+import com.izforge.izpack.util.AbstractUIProgressHandler;
+import com.izforge.izpack.util.Debug;
+import com.izforge.izpack.util.DebugConstants;
+import com.izforge.izpack.util.Housekeeper;
+import com.izforge.izpack.util.IoHelper;
+import com.izforge.izpack.util.Log;
+import com.izforge.izpack.util.OsConstraint;
+import com.izforge.izpack.util.VariableSubstitutor;
-import javax.swing.*;
-import javax.swing.border.TitledBorder;
-import javax.swing.text.JTextComponent;
-import java.awt.*;
-import java.awt.event.*;
-import java.io.*;
-import java.lang.reflect.Constructor;
-import java.net.URL;
-import java.util.*;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
-import java.util.zip.ZipOutputStream;
-
/**
* The IzPack installer frame.
- *
+ *
* @author Julien Ponge created October 27, 2002
* @author Fabrice Mirabile added fix for alert window on cross button, July 06 2005
* @author Dennis Reil, added RulesEngine November 10 2006, several changes in January 2007
*/
-public class InstallerFrame extends JFrame {
+public class InstallerFrame extends JFrame
+{
private static final long serialVersionUID = 3257852069162727473L;
@@ -185,14 +241,15 @@
/**
* The constructor (normal mode).
- *
- * @param title The window title.
+ *
+ * @param title The window title.
* @param installdata The installation data.
- *
+ *
* @throws Exception Description of the Exception
*/
public InstallerFrame(String title, InstallData installdata, InstallerBase parentInstaller)
- throws Exception {
+ throws Exception
+ {
super(title);
this.parentInstaller = parentInstaller;
this.rules = this.parentInstaller.getRules();
@@ -217,16 +274,18 @@
switchPanel(0);
}
- public Debugger getDebugger() {
+ public Debugger getDebugger()
+ {
return this.debugger;
}
/**
* Loads the panels.
- *
+ *
* @throws Exception Description of the Exception
*/
- private void loadPanels() throws Exception {
+ private void loadPanels() throws Exception
+ {
// Initialisation
java.util.Listtrue focus goes to nextButton
*/
- public void unlockNextButton(boolean requestFocus) {
+ public void unlockNextButton(boolean requestFocus)
+ {
nextButton.setEnabled(true);
- if (requestFocus) {
+ if (requestFocus)
+ {
nextButton.requestFocusInWindow();
getRootPane().setDefaultButton(nextButton);
- if (this.getFocusOwner() != null) {
+ if (this.getFocusOwner() != null)
+ {
Debug.trace("Current focus owner: " + this.getFocusOwner().getName());
}
- if (!(getRootPane().getDefaultButton() == nextButton)) {
+ if (!(getRootPane().getDefaultButton() == nextButton))
+ {
Debug.trace("Next button not default button, setting...");
quitButton.setDefaultCapable(false);
prevButton.setDefaultCapable(false);
@@ -1398,11 +1629,16 @@
/**
* Allows a panel to ask to be skipped.
*/
- public void skipPanel() {
- if (installdata.curPanelNumber < installdata.panels.size() - 1) {
- if (isBack) {
+ public void skipPanel()
+ {
+ if (installdata.curPanelNumber < installdata.panels.size() - 1)
+ {
+ if (isBack)
+ {
navigatePrevious(installdata.curPanelNumber);
- } else {
+ }
+ else
+ {
navigateNext(installdata.curPanelNumber, false);
}
}
@@ -1410,27 +1646,34 @@
/**
* Method checks whether conditions are met to show the given panel.
- *
+ *
* @param panelnumber the panel number to check
- *
+ *
* @return true or false
*/
- public boolean canShow(int panelnumber) {
+ public boolean canShow(int panelnumber)
+ {
IzPanel panel = installdata.panels.get(panelnumber);
Panel panelmetadata = panel.getMetadata();
String panelid = panelmetadata.getPanelid();
Debug.trace("Current Panel: " + panelid);
- if (panelmetadata.hasCondition()) {
+ if (panelmetadata.hasCondition())
+ {
Debug.log("Checking panelcondition");
return rules.isConditionTrue(panelmetadata.getCondition());
- } else {
- if (!rules.canShowPanel(panelid, this.installdata.variables)) {
+ }
+ else
+ {
+ if (!rules.canShowPanel(panelid, this.installdata.variables))
+ {
// skip panel, if conditions for panel aren't met
Debug.log("Skip panel with panelid=" + panelid);
// panel should be skipped, so we have to decrement panelnumber for skipping
return false;
- } else {
+ }
+ else
+ {
return true;
}
}
@@ -1439,23 +1682,24 @@
/**
* This function moves to the next panel
*/
- public void navigateNext() {
+ public void navigateNext()
+ {
// If the button is inactive this indicates that we cannot move
// so we don't do the move
- if (!nextButton.isEnabled()) {
- return;
- }
+ if (!nextButton.isEnabled()) { return; }
this.navigateNext(installdata.curPanelNumber, true);
}
/**
* This function searches for the next available panel, the search begins from given panel+1
- *
- * @param startPanel the starting panel number
+ *
+ * @param startPanel the starting panel number
* @param doValidation whether to do panel validation
*/
- public void navigateNext(int startPanel, boolean doValidation) {
- if ((installdata.curPanelNumber < installdata.panels.size() - 1)) {
+ public void navigateNext(int startPanel, boolean doValidation)
+ {
+ if ((installdata.curPanelNumber < installdata.panels.size() - 1))
+ {
// We must trasfer all fields into the variables before
// panelconditions try to resolve the rules based on unassigned vars.
final IzPanel panel = installdata.panels.get(startPanel);
@@ -1469,13 +1713,12 @@
// if this is not here, validation will
// occur mutilple times while skipping panels through the recursion
- if (!isValid) {
- return;
- }
+ if (!isValid) { return; }
// We try to show the next panel that we can.
int nextPanel = hasNavigateNext(startPanel, false);
- if (-1 != nextPanel) {
+ if (-1 != nextPanel)
+ {
installdata.curPanelNumber = nextPanel;
switchPanel(startPanel);
}
@@ -1486,22 +1729,26 @@
* Check to see if there is another panel that can be navigated to next. This checks the
* successive panels to see if at least one can be shown based on the conditions associated with
* the panels.
- *
- * @param startPanel The panel to check from
+ *
+ * @param startPanel The panel to check from
* @param visibleOnly Only check the visible panels
- *
+ *
* @return The panel that we can navigate to next or -1 if there is no panel that we can
- * navigate next to
+ * navigate next to
*/
- public int hasNavigateNext(int startPanel, boolean visibleOnly) {
+ public int hasNavigateNext(int startPanel, boolean visibleOnly)
+ {
// Assume that we cannot navigate to another panel
int res = -1;
// Start from the panel given and check each one until we find one
// that we can navigate to or until there are no more panels
- for (int panel = startPanel + 1; res == -1 && panel < installdata.panels.size(); panel++) {
+ for (int panel = startPanel + 1; res == -1 && panel < installdata.panels.size(); panel++)
+ {
// See if we can show this panel
- if (!visibleOnly || ((Integer) visiblePanelMapping.get(panel)).intValue() != -1) {
- if (canShow(panel)) {
+ if (!visibleOnly || ((Integer) visiblePanelMapping.get(panel)).intValue() != -1)
+ {
+ if (canShow(panel))
+ {
res = panel;
}
}
@@ -1514,21 +1761,25 @@
* Check to see if there is another panel that can be navigated to previous. This checks the
* previous panels to see if at least one can be shown based on the conditions associated with
* the panels.
- *
+ *
* @param endingPanel The panel to check from
- *
+ *
* @return The panel that we can navigate to previous or -1 if there is no panel that we can
- * navigate previous to
+ * navigate previous to
*/
- public int hasNavigatePrevious(int endingPanel, boolean visibleOnly) {
+ public int hasNavigatePrevious(int endingPanel, boolean visibleOnly)
+ {
// Assume that we cannot navigate to another panel
int res = -1;
// Start from the panel given and check each one until we find one
// that we can navigate to or until there are no more panels
- for (int panel = endingPanel - 1; res == -1 && panel >= 0; panel--) {
+ for (int panel = endingPanel - 1; res == -1 && panel >= 0; panel--)
+ {
// See if we can show this panel
- if (!visibleOnly || ((Integer) visiblePanelMapping.get(panel)).intValue() != -1) {
- if (canShow(panel)) {
+ if (!visibleOnly || ((Integer) visiblePanelMapping.get(panel)).intValue() != -1)
+ {
+ if (canShow(panel))
+ {
res = panel;
}
}
@@ -1540,24 +1791,25 @@
/**
* This function moves to the previous panel
*/
- public void navigatePrevious() {
+ public void navigatePrevious()
+ {
// If the button is inactive this indicates that we cannot move
// so we don't do the move
- if (!prevButton.isEnabled()) {
- return;
- }
+ if (!prevButton.isEnabled()) { return; }
this.navigatePrevious(installdata.curPanelNumber);
}
/**
* This function switches to the available panel that is just before the given one.
- *
+ *
* @param endingPanel the panel to search backwards, beginning from this.
*/
- public void navigatePrevious(int endingPanel) {
+ public void navigatePrevious(int endingPanel)
+ {
// We try to show the previous panel that we can.
int prevPanel = hasNavigatePrevious(endingPanel, false);
- if (-1 != prevPanel) {
+ if (-1 != prevPanel)
+ {
installdata.curPanelNumber = prevPanel;
switchPanel(endingPanel);
}
@@ -1566,28 +1818,34 @@
/**
* Show help Window
*/
- public void showHelp() {
+ public void showHelp()
+ {
installdata.panels.get(installdata.curPanelNumber).showHelp();
}
/**
* Handles the events from the navigation bar elements.
- *
+ *
* @author Julien Ponge
*/
- class NavigationHandler implements ActionListener {
+ class NavigationHandler implements ActionListener
+ {
- public void actionPerformed(final ActionEvent e) {
+ public void actionPerformed(final ActionEvent e)
+ {
/*
- Some panels activation may be slow, hence we
- block the GUI, spin a thread to handle navigation then
- release the GUI.
+ * Some panels activation may be slow, hence we block the GUI, spin a thread to handle
+ * navigation then release the GUI.
*/
new Thread(new Runnable() {
- public void run() {
+ public void run()
+ {
+
SwingUtilities.invokeLater(new Runnable() {
- public void run() {
+
+ public void run()
+ {
blockGUI();
}
});
@@ -1595,7 +1853,9 @@
navigate(e);
SwingUtilities.invokeLater(new Runnable() {
- public void run() {
+
+ public void run()
+ {
releaseGUI();
}
});
@@ -1603,52 +1863,62 @@
}).start();
}
- private void navigate(ActionEvent e) {
+ private void navigate(ActionEvent e)
+ {
Object source = e.getSource();
- if (source == prevButton) {
+ if (source == prevButton)
+ {
navigatePrevious();
- } else if (source == nextButton) {
+ }
+ else if (source == nextButton)
+ {
navigateNext();
- } else if (source == quitButton) {
+ }
+ else if (source == quitButton)
+ {
exit();
}
}
}
- class HelpHandler implements ActionListener {
+ class HelpHandler implements ActionListener
+ {
/**
* Actions handler.
- *
+ *
* @param e The event.
*/
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(ActionEvent e)
+ {
showHelp();
}
}
/**
* The window events handler.
- *
+ *
* @author julien created October 27, 2002
*/
- class WindowHandler extends WindowAdapter {
+ class WindowHandler extends WindowAdapter
+ {
/**
* Window close is pressed,
- *
+ *
* @param e The event.
*/
- public void windowClosing(WindowEvent e) {
+ public void windowClosing(WindowEvent e)
+ {
// We ask for confirmation
exit();
}
/**
* OLD VERSION We can't avoid the exit here, so don't call exit anywhere else.
- *
+ *
* @param e The event.
- *
+ *
* public void windowClosing(WindowEvent e) { if (Unpacker.isDiscardInterrupt() &&
* interruptCount < MAX_INTERRUPT) { // But we should not interrupt. interruptCount++;
* return; } // We show an alert anyway if (!installdata.canClose)
@@ -1661,47 +1931,52 @@
/**
* A FocusTraversalPolicy that only allows the block panel to have the focus
*/
- private class BlockFocusTraversalPolicy extends java.awt.DefaultFocusTraversalPolicy {
+ private class BlockFocusTraversalPolicy extends java.awt.DefaultFocusTraversalPolicy
+ {
private static final long serialVersionUID = 3258413928261169209L;
/**
* Only accepts the block panel
- *
+ *
* @param aComp the component to check
- *
+ *
* @return true if aComp is the block panel
*/
- protected boolean accept(Component aComp) {
+ protected boolean accept(Component aComp)
+ {
return aComp == getGlassPane();
}
}
/**
* Returns the gui creation listener list.
- *
+ *
* @return the gui creation listener list
*/
- public Listshow parameter
- *
+ *
* @param show - flag to show or hide Help button
*/
- private void showHelpButton(boolean show) {
+ private void showHelpButton(boolean show)
+ {
if (this.helpButton == null) return;
this.helpButton.setVisible(show);
}
Index: src/lib/com/izforge/izpack/installer/GUIInstaller.java
===================================================================
--- src/lib/com/izforge/izpack/installer/GUIInstaller.java (Revision 2934)
+++ src/lib/com/izforge/izpack/installer/GUIInstaller.java (Arbeitskopie)
@@ -20,19 +20,16 @@
package com.izforge.izpack.installer;
-import com.izforge.izpack.GUIPrefs;
-import com.izforge.izpack.LocaleDatabase;
-import com.izforge.izpack.gui.ButtonFactory;
-import com.izforge.izpack.gui.LabelFactory;
-import com.izforge.izpack.util.Debug;
-import com.izforge.izpack.util.FileExecutor;
-import com.izforge.izpack.util.OsVersion;
-import com.izforge.izpack.util.VariableSubstitutor;
-
-import javax.swing.*;
-import javax.swing.plaf.metal.MetalLookAndFeel;
-import javax.swing.plaf.metal.MetalTheme;
-import java.awt.*;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GraphicsEnvironment;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.Point;
+import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
@@ -41,12 +38,43 @@
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.lang.reflect.Method;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.TreeMap;
+import javax.swing.GrayFilter;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.ListCellRenderer;
+import javax.swing.LookAndFeel;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+import javax.swing.plaf.metal.MetalTheme;
+
+import com.izforge.izpack.GUIPrefs;
+import com.izforge.izpack.LocaleDatabase;
+import com.izforge.izpack.gui.ButtonFactory;
+import com.izforge.izpack.gui.LabelFactory;
+import com.izforge.izpack.util.Debug;
+import com.izforge.izpack.util.FileExecutor;
+import com.izforge.izpack.util.OsVersion;
+import com.izforge.izpack.util.VariableSubstitutor;
+
/**
* The IzPack graphical installer class.
- *
+ *
* @author Julien Ponge
*/
public class GUIInstaller extends InstallerBase
@@ -65,54 +93,63 @@
/**
* defined modifier for language display type.
*/
- private static final String[] LANGUAGE_DISPLAY_TYPES = {"iso3", "native", "default"};
+ private static final String[] LANGUAGE_DISPLAY_TYPES = { "iso3", "native", "default"};
- private static final String[][] LANG_CODES = {{"cat", "ca"}, {"chn", "zh"}, {"cze", "cs"},
- {"dan", "da"}, {"deu", "de"}, {"eng", "en"}, {"fin", "fi"}, {"fra", "fr"},
- {"hun", "hu"}, {"ita", "it"}, {"jpn", "ja"}, {"mys", "ms"}, {"ned", "nl"},
- {"nor", "no"}, {"pol", "pl"}, {"por", "pt"}, {"rom", "or"}, {"rus", "ru"},
- {"spa", "es"}, {"svk", "sk"}, {"swe", "sv"}, {"tur", "tr"}, {"ukr", "uk"}};
+ private static final String[][] LANG_CODES = { { "cat", "ca"}, { "chn", "zh"}, { "cze", "cs"},
+ { "dan", "da"}, { "deu", "de"}, { "eng", "en"}, { "fin", "fi"}, { "fra", "fr"},
+ { "hun", "hu"}, { "ita", "it"}, { "jpn", "ja"}, { "mys", "ms"}, { "ned", "nl"},
+ { "nor", "no"}, { "pol", "pl"}, { "por", "pt"}, { "rom", "or"}, { "rus", "ru"},
+ { "spa", "es"}, { "svk", "sk"}, { "swe", "sv"}, { "tur", "tr"}, { "ukr", "uk"}};
/**
* holds language to ISO-3 language code translation
*/
private static HashMap isoTable;
-
+
/**
* The constructor.
- *
+ *
* @throws Exception Description of the Exception
*/
public GUIInstaller() throws Exception
{
- try {
+ try
+ {
init();
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
showFatalError(e);
throw e;
- } catch (Error e) {
+ }
+ catch (Error e)
+ {
showFatalError(e);
throw e;
}
}
-
+
private void showFatalError(Throwable e)
{
- try {
- JOptionPane.showMessageDialog (null, "Error: "+e.toString(), "Error", JOptionPane.ERROR_MESSAGE);
- } catch (Exception e2) {
+ try
+ {
+ JOptionPane.showMessageDialog(null, "Error: " + e.toString(), "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ catch (Exception e2)
+ {
e2.printStackTrace();
}
}
-
+
private void init() throws Exception
{
-
- this.installdata = new InstallData();
-
+
+ this.installdata = new InstallData();
+
// Loads the installation data
loadInstallData(installdata);
-
+
// add the GUI install data
loadGUIInstallData();
@@ -125,11 +162,10 @@
// Check for already running instance
checkLockFile();
-
-// Loads the suitable langpack
- SwingUtilities.invokeAndWait(new Runnable()
- {
+ // Loads the suitable langpack
+ SwingUtilities.invokeAndWait(new Runnable() {
+
public void run()
{
try
@@ -142,19 +178,19 @@
}
}
});
-
+
// create the resource manager (after the language selection!)
ResourceManager.create(this.installdata);
-
-// load conditions
+
+ // load conditions
loadConditions(installdata);
-
+
// loads installer conditions
loadInstallerRequirements();
// load dynamic variables
loadDynamicVariables();
-
+
// check installer conditions
if (!checkInstallerRequirements(installdata))
{
@@ -167,8 +203,7 @@
addCustomLangpack(installdata);
// We launch the installer GUI
- SwingUtilities.invokeLater(new Runnable()
- {
+ SwingUtilities.invokeLater(new Runnable() {
public void run()
{
@@ -183,14 +218,15 @@
}
});
}
-
- public void showMissingRequirementMessage(String message){
+
+ public void showMissingRequirementMessage(String message)
+ {
JOptionPane.showMessageDialog(null, message);
}
/**
* Load GUI preference information.
- *
+ *
* @throws Exception
*/
public void loadGUIInstallData() throws Exception
@@ -199,13 +235,12 @@
ObjectInputStream objIn = new ObjectInputStream(in);
this.installdata.guiPrefs = (GUIPrefs) objIn.readObject();
objIn.close();
- }
+ }
/**
- * Sets a lock file. Not using java.nio.channels.FileLock to prevent
- * the installer from accidentally keeping a lock on a file if the install
- * fails or is killed.
- *
+ * Sets a lock file. Not using java.nio.channels.FileLock to prevent the installer from
+ * accidentally keeping a lock on a file if the install fails or is killed.
+ *
* @throws Exception Description of the Exception
*/
private void checkLockFile() throws Exception
@@ -222,16 +257,22 @@
Debug.trace("Lock File Exists, asking user for permission to proceed.");
StringBuffer msg = new StringBuffer();
msg.append("");
- msg.append("The " + appName + " installer you are attempting to run seems to have a copy already running.packsLang.xml_eng, the values
- * are lists of {@link URL} pointing to the concrete packsLang-files.
- *
+ * this map is an packsLang-file identifier, e.g. packsLang.xml_eng, the values are
+ * lists of {@link URL} pointing to the concrete packsLang-files.
+ *
* @see #mergePacksLangFiles()
*/
private HashMap
* <p/>
* <p/>
@@ -2006,20 +2093,19 @@
* <p/>
*
*
- * variable declared in this can be referred to in parsable files.
- *
+ *
+ * variable declared in this can be referred to in parsable files.
+ *
* @param data The XML data.
- *
+ *
* @throws CompilerException Description of the Exception
*/
- protected void addVariables(IXMLElement data) throws CompilerException {
+ protected void addVariables(IXMLElement data) throws CompilerException
+ {
notifyCompilerListener("addVariables", CompilerListener.BEGIN, data);
// We get the varible list
IXMLElement root = data.getFirstChildNamed("variables");
- if (root == null)
- {
- return;
- }
+ if (root == null) { return; }
Properties variables = compiler.getVariables();
@@ -2038,14 +2124,12 @@
notifyCompilerListener("addVariables", CompilerListener.END, data);
}
- protected void addDynamicVariables(IXMLElement data) throws CompilerException {
+ protected void addDynamicVariables(IXMLElement data) throws CompilerException
+ {
notifyCompilerListener("addDynamicVariables", CompilerListener.BEGIN, data);
// We get the dynamic variable list
IXMLElement root = data.getFirstChildNamed("dynamicvariables");
- if (root == null)
- {
- return;
- }
+ if (root == null) { return; }
Map
* <p/>
* <p/>
@@ -2153,13 +2245,15 @@
* <p/>
*
*
- * variable declared in this can be referred to in parsable files.
- *
+ *
+ * variable declared in this can be referred to in parsable files.
+ *
* @param data The XML data.
- *
+ *
* @throws CompilerException Description of the Exception
*/
- protected void substituteProperties(IXMLElement data) throws CompilerException {
+ protected void substituteProperties(IXMLElement data) throws CompilerException
+ {
notifyCompilerListener("substituteProperties", CompilerListener.BEGIN, data);
IXMLElement root = data.getFirstChildNamed("properties");
@@ -2196,7 +2290,8 @@
/**
* Perform recursive substitution on all properties
*/
- protected void substituteAllProperties(IXMLElement element) throws CompilerException {
+ protected void substituteAllProperties(IXMLElement element) throws CompilerException
+ {
Enumeration attributes = element.enumerateAttributeNames();
while (attributes.hasMoreElements())
{
@@ -2221,48 +2316,41 @@
/**
* Checks whether a File instance is a regular file, exists and is readable. Throws appropriate
* CompilerException to report violations of these conditions.
- *
+ *
* @throws CompilerException if the file is either not existing, not a regular file or not
- * readable.
+ * readable.
*/
private void assertIsNormalReadableFile(File fileToCheck, String fileDescription)
- throws CompilerException {
+ throws CompilerException
+ {
if (fileToCheck != null)
{
- if (!fileToCheck.exists())
- {
- throw new CompilerException(fileDescription
- + " does not exist: " + fileToCheck);
- }
- if (!fileToCheck.isFile())
- {
- throw new CompilerException(fileDescription
- + " is not a regular file: " + fileToCheck);
- }
- if (!fileToCheck.canRead())
- {
- throw new CompilerException(fileDescription
- + " is not readable by application: " + fileToCheck);
- }
+ if (!fileToCheck.exists()) { throw new CompilerException(fileDescription
+ + " does not exist: " + fileToCheck); }
+ if (!fileToCheck.isFile()) { throw new CompilerException(fileDescription
+ + " is not a regular file: " + fileToCheck); }
+ if (!fileToCheck.canRead()) { throw new CompilerException(fileDescription
+ + " is not readable by application: " + fileToCheck); }
}
}
/**
* Returns the IXMLElement representing the installation XML file.
- *
+ *
* @return The XML tree.
- *
+ *
* @throws CompilerException For problems with the installation file
- * @throws IOException for errors reading the installation file
+ * @throws IOException for errors reading the installation file
*/
- protected IXMLElement getXMLTree() throws CompilerException, IOException {
+ protected IXMLElement getXMLTree() throws CompilerException, IOException
+ {
IXMLParser parser = new XMLParser();
IXMLElement data = null;
if (filename != null)
{
File file = new File(filename).getAbsoluteFile();
assertIsNormalReadableFile(file, "Configuration file");
- data = parser.parse(new FileInputStream(filename),file.getAbsolutePath());
+ data = parser.parse(new FileInputStream(filename), file.getAbsolutePath());
// add izpack built in property
compiler.setProperty("izpack.file", file.toString());
}
@@ -2288,7 +2376,8 @@
return data;
}
- protected int getOverrideValue(IXMLElement f) throws CompilerException {
+ protected int getOverrideValue(IXMLElement f) throws CompilerException
+ {
int override = PackFile.OVERRIDE_UPDATE;
String override_val = f.getAttribute("override");
@@ -2324,15 +2413,18 @@
}
/**
- * Parses the blockable element value and adds automatically the OS constraint
- * family=windows if not already se in the given constraint list.
- * Throws a parsing warning if the constraint list was implicitely modified.
+ * Parses the blockable element value and adds automatically the OS constraint family=windows if
+ * not already se in the given constraint list. Throws a parsing warning if the constraint list
+ * was implicitely modified.
+ *
* @param f the blockable XML element to parse
* @param osList constraint list to maintain and return
* @return blockable level
* @throws CompilerException
*/
- protected int getBlockableValue(IXMLElement f, List
* <res src="./packsLang01.xml" id="packsLang.xml"/>
* <res src="./packsLang02.xml" id="packsLang.xml"/>
@@ -3264,13 +3343,15 @@
*
* are merged into a single temp-file to act as if the user had defined:
*
+ *
*
* <res src="/tmp/izpp47881.tmp" id="packsLang.xml"/>
*
- *
+ *
* @throws CompilerException
*/
- private void mergePacksLangFiles() throws CompilerException {
+ private void mergePacksLangFiles() throws CompilerException
+ {
// just one packslang file. nothing to do here
if (packsLangUrlMap.size() <= 0) return;
@@ -3365,26 +3446,33 @@
*/
private void addPanelActions(IXMLElement xmlPanel, Panel panel) throws CompilerException
{
- IXMLElement xmlActions = xmlPanel.getFirstChildNamed(PanelAction.PANEL_ACTIONS_TAG);
+ IXMLElement xmlActions = xmlPanel.getFirstChildNamed(PanelAction.PANEL_ACTIONS_TAG);
if (xmlActions != null)
{
Vector actionList = xmlActions
.getChildrenNamed(PanelAction.PANEL_ACTION_TAG);
if (actionList != null)
{
- for (IXMLElement action : actionList){
+ for (IXMLElement action : actionList)
+ {
String stage = action.getAttribute(PanelAction.PANEL_ACTION_STAGE_TAG);
String actionName = action.getAttribute(PanelAction.PANEL_ACTION_CLASSNAME_TAG);
- if (actionName != null){
+ if (actionName != null)
+ {
Vector params = action.getChildrenNamed("param");
PanelActionConfiguration config = new PanelActionConfiguration();
- for(IXMLElement param : params){
+ for (IXMLElement param : params)
+ {
IXMLElement keyElement = param.getFirstChildNamed("key");
IXMLElement valueElement = param.getFirstChildNamed("value");
- if ((keyElement != null) && (valueElement != null)){
- Debug.trace("Adding configuration property " + keyElement.getContent() + " with value " + valueElement.getContent() + " for action " + actionName);
- config.addProperty(keyElement.getContent(),valueElement.getContent());
+ if ((keyElement != null) && (valueElement != null))
+ {
+ Debug.trace("Adding configuration property "
+ + keyElement.getContent() + " with value "
+ + valueElement.getContent() + " for action " + actionName);
+ config.addProperty(keyElement.getContent(), valueElement
+ .getContent());
}
}
panel.putPanelActionConfiguration(actionName, config);
@@ -3421,6 +3509,6 @@
+ PanelAction.PANEL_ACTION_TAG + ">");
}
}
- }
+ }
}