Index: src/doc-reST/installation-files.txt =================================================================== --- src/doc-reST/installation-files.txt (Revision 2934) +++ src/doc-reST/installation-files.txt (Arbeitskopie) @@ -795,6 +795,44 @@ If multiple packsLang-files were defined, all files will be merged into a single temporary file. This allows ``refpack`` files to provide their own internationalization-information. +You can define bundles of resources by using ```` +You have to set a unique id for the bundle ``id``. One bundle can be marked to be default: ``default="true"`` + +You need to define a variable to set the name of the SystemProperty: ``resource.bundle.system.property`` + +Here's a sample: + +:: + + + + ... + + + ... + + + + + + + + + + + + + + ... + +Resources will be then be loaded in the following order: + +- /res//_ +- /res// +- /res/_ +- /res/ + + The Panels Element ```` ''''''''''''''''''''''''''''''''' Index: src/dtd/installation.dtd =================================================================== --- src/dtd/installation.dtd (Revision 2934) +++ src/dtd/installation.dtd (Arbeitskopie) @@ -101,14 +101,19 @@ - - - - - - - + + + + + + + + + + + + Index: src/lib/com/izforge/izpack/compiler/CompilerConfig.java =================================================================== --- src/lib/com/izforge/izpack/compiler/CompilerConfig.java (Revision 2934) +++ src/lib/com/izforge/izpack/compiler/CompilerConfig.java (Arbeitskopie) @@ -26,7 +26,50 @@ package com.izforge.izpack.compiler; -import com.izforge.izpack.*; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Date; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.TreeMap; +import java.util.Vector; +import java.util.jar.JarInputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipInputStream; + +import org.apache.tools.ant.DirectoryScanner; + +import com.izforge.izpack.CustomData; +import com.izforge.izpack.ExecutableFile; +import com.izforge.izpack.GUIPrefs; +import com.izforge.izpack.Info; +import com.izforge.izpack.PackFile; +import com.izforge.izpack.Panel; +import com.izforge.izpack.ParsableFile; +import com.izforge.izpack.UpdateCheck; import com.izforge.izpack.adaptator.IXMLElement; import com.izforge.izpack.adaptator.IXMLParser; import com.izforge.izpack.adaptator.IXMLWriter; @@ -37,37 +80,31 @@ import com.izforge.izpack.installer.DataValidator; import com.izforge.izpack.installer.InstallerRequirement; import com.izforge.izpack.installer.PanelAction; +import com.izforge.izpack.installer.PanelActionConfiguration; import com.izforge.izpack.installer.PanelAction.ActionStage; -import com.izforge.izpack.installer.PanelActionConfiguration; import com.izforge.izpack.panels.HelpWindow; import com.izforge.izpack.rules.Condition; import com.izforge.izpack.rules.RulesEngine; import com.izforge.izpack.util.Debug; import com.izforge.izpack.util.OsConstraint; import com.izforge.izpack.util.VariableSubstitutor; -import org.apache.tools.ant.DirectoryScanner; -import java.io.*; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.*; -import java.util.jar.JarInputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import java.util.zip.ZipInputStream; - - /** * A parser for the installer xml configuration. This parses a document conforming to the * installation.dtd and populates a Compiler instance to perform the install compilation. - * + * * @author Scott Stark * @version $Revision$ */ -public class CompilerConfig extends Thread { +public class CompilerConfig extends Thread +{ + public final static String RESOURCES_TAG_NAME = "resources"; + + public final static String RES_TAG_NAME = "res"; + + public final static String BUNDLE_TAG_NAME = "bundle"; + /** * The compiler version. */ @@ -125,113 +162,120 @@ /** * A list of packsLang-files that were defined by the user in the resource-section The key of - * 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. - * + * 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> packsLangUrlMap = new HashMap>(); /** * Set the IzPack home directory - * + * * @param izHome - the izpack home directory */ - public static void setIzpackHome(String izHome) { + public static void setIzpackHome(String izHome) + { Compiler.setIzpackHome(izHome); } /** * The constructor. - * + * * @param filename The XML filename. - * @param basedir The base directory. - * @param kind The installer kind. - * @param output The installer filename. - * + * @param basedir The base directory. + * @param kind The installer kind. + * @param output The installer filename. + * * @throws CompilerException */ public CompilerConfig(String filename, String basedir, String kind, String output) - throws CompilerException { + throws CompilerException + { this(filename, basedir, kind, output, null); } /** * The constructor. - * + * * @param filename The XML filename. - * @param basedir The base directory. - * @param kind The installer kind. - * @param output The installer filename. + * @param basedir The base directory. + * @param kind The installer kind. + * @param output The installer filename. * @param listener The PackagerListener. - * + * * @throws CompilerException */ public CompilerConfig(String filename, String basedir, String kind, String output, - PackagerListener listener) throws CompilerException { + PackagerListener listener) throws CompilerException + { this(filename, basedir, kind, output, "default", listener); } /** - * @param filename The XML filename. - * @param kind The installer kind. - * @param output The installer filename. + * @param filename The XML filename. + * @param kind The installer kind. + * @param output The installer filename. * @param compr_format The compression format to be used for packs. - * @param listener The PackagerListener. - * + * @param listener The PackagerListener. + * * @throws CompilerException */ public CompilerConfig(String filename, String base, String kind, String output, - String compr_format, PackagerListener listener) throws CompilerException { + String compr_format, PackagerListener listener) throws CompilerException + { this(filename, base, kind, output, compr_format, listener, null); } /** - * @param basedir The base directory. - * @param kind The installer kind. - * @param output The installer filename. - * @param listener The PackagerListener. + * @param basedir The base directory. + * @param kind The installer kind. + * @param output The installer filename. + * @param listener The PackagerListener. * @param installText The install xml configuration text - * + * * @throws CompilerException */ public CompilerConfig(String basedir, String kind, String output, PackagerListener listener, - String installText) throws CompilerException { + String installText) throws CompilerException + { this(null, basedir, kind, output, "default", listener, installText); } /** - * @param filename The XML filename. - * @param basedir The base directory. - * @param kind The installer kind. - * @param output The installer filename. + * @param filename The XML filename. + * @param basedir The base directory. + * @param kind The installer kind. + * @param output The installer filename. * @param compr_format The compression format to be used for packs. - * @param listener The PackagerListener. - * @param installText The install xml configuration text - * + * @param listener The PackagerListener. + * @param installText The install xml configuration text + * * @throws CompilerException */ public CompilerConfig(String filename, String basedir, String kind, String output, - String compr_format, PackagerListener listener, String installText) - throws CompilerException { + String compr_format, PackagerListener listener, String installText) + throws CompilerException + { this(filename, basedir, kind, output, compr_format, -1, listener, installText); } /** - * @param filename The XML filename. - * @param basedir The base directory. - * @param kind The installer kind. - * @param output The installer filename. + * @param filename The XML filename. + * @param basedir The base directory. + * @param kind The installer kind. + * @param output The installer filename. * @param compr_format The compression format to be used for packs. - * @param compr_level Compression level to be used if supported. - * @param listener The PackagerListener. - * @param installText The install xml configuration text - * + * @param compr_level Compression level to be used if supported. + * @param listener The PackagerListener. + * @param installText The install xml configuration text + * * @throws CompilerException */ public CompilerConfig(String filename, String basedir, String kind, String output, - String compr_format, int compr_level, PackagerListener listener, String installText) - throws CompilerException { + String compr_format, int compr_level, PackagerListener listener, String installText) + throws CompilerException + { this.filename = filename; this.installText = installText; this.basedir = basedir; @@ -240,45 +284,50 @@ } /** - * Add a name value pair to the project property set. It is not replaced it is already - * in the set of properties. - * - * @param name the name of the property + * Add a name value pair to the project property set. It is not replaced it is already in + * the set of properties. + * + * @param name the name of the property * @param value the value to set - * + * * @return true if the property was not already set */ - public boolean addProperty(String name, String value) { + public boolean addProperty(String name, String value) + { return compiler.addProperty(name, value); } /** * Access the install compiler - * + * * @return the install compiler */ - public Compiler getCompiler() { + public Compiler getCompiler() + { return compiler; } /** * Retrieves the packager listener */ - public PackagerListener getPackagerListener() { + public PackagerListener getPackagerListener() + { return compiler.getPackagerListener(); } /** * Compile the installation */ - public void compile() { + public void compile() + { start(); } /** * The run() method. */ - public void run() { + public void run() + { try { executeCompiler(); @@ -302,18 +351,16 @@ /** * Compiles the installation. - * + * * @throws Exception Description of the Exception */ - public void executeCompiler() throws Exception { + public void executeCompiler() throws Exception + { // normalize and test: TODO: may allow failure if we require write // access File base = new File(basedir).getAbsoluteFile(); - if (!base.canRead() || !base.isDirectory()) - { - throw new CompilerException( - "Invalid base directory: " + base); - } + if (!base.canRead() || !base.isDirectory()) { throw new CompilerException( + "Invalid base directory: " + base); } // add izpack built in property compiler.setProperty("basedir", base.toString()); @@ -350,7 +397,8 @@ compiler.createInstaller(); } - private void addInstallerRequirement(IXMLElement data) throws CompilerException { + private void addInstallerRequirement(IXMLElement data) throws CompilerException + { notifyCompilerListener("addInstallerRequirement", CompilerListener.BEGIN, data); IXMLElement root = data.getFirstChildNamed("installerrequirements"); List installerrequirements = new ArrayList(); @@ -373,7 +421,8 @@ notifyCompilerListener("addInstallerRequirement", CompilerListener.END, data); } - private void loadPackagingInformation(IXMLElement data) throws CompilerException { + private void loadPackagingInformation(IXMLElement data) throws CompilerException + { notifyCompilerListener("loadPackager", CompilerListener.BEGIN, data); // Initialisation IXMLElement root = data.getFirstChildNamed("packaging"); @@ -409,18 +458,20 @@ notifyCompilerListener("loadPackager", CompilerListener.END, data); } - public boolean wasSuccessful() { + public boolean wasSuccessful() + { return compiler.wasSuccessful(); } /** * Returns the GUIPrefs. - * + * * @param data The XML data. - * + * * @throws CompilerException Description of the Exception */ - protected void addGUIPrefs(IXMLElement data) throws CompilerException { + protected void addGUIPrefs(IXMLElement data) throws CompilerException + { notifyCompilerListener("addGUIPrefs", CompilerListener.BEGIN, data); // We get the IXMLElement & the attributes IXMLElement gp = data.getFirstChildNamed("guiprefs"); @@ -504,10 +555,11 @@ /** * Add project specific external jar files to the installer. - * + * * @param data The XML data. */ - protected void addJars(IXMLElement data) throws Exception { + protected void addJars(IXMLElement data) throws Exception + { notifyCompilerListener("addJars", CompilerListener.BEGIN, data); Iterator iter = data.getChildrenNamed("jar").iterator(); while (iter.hasNext()) @@ -538,10 +590,11 @@ /** * Add native libraries to the installer. - * + * * @param data The XML data. */ - protected void addNativeLibraries(IXMLElement data) throws Exception { + protected void addNativeLibraries(IXMLElement data) throws Exception + { boolean needAddOns = false; notifyCompilerListener("addNativeLibraries", CompilerListener.BEGIN, data); Iterator iter = data.getChildrenNamed("native").iterator(); @@ -596,10 +649,11 @@ /** * Add packs and their contents to the installer. - * + * * @param data The XML data. */ - protected void addPacks(IXMLElement data) throws CompilerException { + protected void addPacks(IXMLElement data) throws CompilerException + { notifyCompilerListener("addPacks", CompilerListener.BEGIN, data); // the actual adding is delegated to addPacksSingle to enable recursive @@ -614,13 +668,15 @@ /** * Add packs and their contents to the installer without checking the dependencies and includes. - *

Helper method to recursively add more packs from refpack XML packs definitions - * + *

+ * Helper method to recursively add more packs from refpack XML packs definitions + * * @param data The XML data - * + * * @throws CompilerException */ - private void addPacksSingle(IXMLElement data) throws CompilerException { + private void addPacksSingle(IXMLElement data) throws CompilerException + { notifyCompilerListener("addPacksSingle", CompilerListener.BEGIN, data); // Initialisation IXMLElement root = requireChildNamed(data, "packs"); @@ -654,7 +710,7 @@ String excludeGroup = el.getAttribute("excludeGroup"); boolean uninstall = "yes".equalsIgnoreCase(el.getAttribute("uninstall", "yes")); String parent = el.getAttribute("parent"); - boolean hidden = "true".equalsIgnoreCase(el.getAttribute("hidden","false")); + boolean hidden = "true".equalsIgnoreCase(el.getAttribute("hidden", "false")); String conditionid = el.getAttribute("condition"); @@ -736,16 +792,18 @@ { parseError(f, "Invalid directory 'dir': " + dir_attr); } - String []includedFiles = getFilesetIncludedFiles(f); + String[] includedFiles = getFilesetIncludedFiles(f); if (includedFiles != null) { - for (String filePath:includedFiles) + for (String filePath : includedFiles) { - File file = new File(dir,filePath); + File file = new File(dir, filePath); if (file.exists() && file.isFile()) { - String targetFile = new File(targetdir, filePath).getPath().replace(File.separatorChar, '/'); - ParsableFile parsable = new ParsableFile(targetFile, type, encoding, osList); + String targetFile = new File(targetdir, filePath).getPath() + .replace(File.separatorChar, '/'); + ParsableFile parsable = new ParsableFile(targetFile, type, + encoding, osList); parsable.setCondition(condition); pack.addParsable(parsable); } @@ -859,8 +917,8 @@ } else { - addRecursively(baseDir, file, targetdir, osList, override, blockable, - pack, additionals, condition); + addRecursively(baseDir, file, targetdir, osList, override, blockable, pack, + additionals, condition); } } catch (Exception x) @@ -896,7 +954,8 @@ try { - pack.addFile(baseDir, file, target, osList, override, blockable, additionals, condition); + pack.addFile(baseDir, file, target, osList, override, blockable, additionals, + condition); } catch (FileNotFoundException x) { @@ -911,7 +970,7 @@ IXMLElement f = iter.next(); String dir_attr = requireAttribute(f, "dir"); String targetdir = requireAttribute(f, "targetdir"); - + File dir = new File(dir_attr); if (!dir.isAbsolute()) { @@ -922,7 +981,7 @@ parseError(f, "Invalid directory 'dir': " + dir_attr); } - String []includedFiles = getFilesetIncludedFiles(f); + String[] includedFiles = getFilesetIncludedFiles(f); List osList = OsConstraint.getOsList(f); // TODO: unverified int override = getOverrideValue(f); int blockable = getBlockableValue(f, osList); @@ -931,13 +990,13 @@ if (includedFiles != null) { - for (String filePath:includedFiles) + for (String filePath : includedFiles) { try { - File file = new File(dir,filePath); + File file = new File(dir, filePath); String target = new File(targetdir, filePath).getPath(); - pack.addFile(baseDir, file, target, osList, override,blockable, + pack.addFile(baseDir, file, target, osList, override, blockable, additionals, condition); } catch (FileNotFoundException x) @@ -1106,10 +1165,10 @@ } // parse additional fileset attributes "includes" and "excludes" - String[] toDo = new String[]{"includes", "excludes"}; + String[] toDo = new String[] { "includes", "excludes"}; // use the existing containers filled from include and exclude // and add the includes and excludes to it - String[][] containers = new String[][]{includes, excludes}; + String[][] containers = new String[][] { includes, excludes}; for (int j = 0; j < toDo.length; ++j) { String inex = f.getAttribute(toDo[j]); @@ -1131,13 +1190,13 @@ } } if (nCont == null) // No container for old values - // created, - // create a new one. + // created, + // create a new one. { nCont = new String[newSize]; } for (; k < newSize; ++k) - // Fill the new one or expand the existent container + // Fill the new one or expand the existent container { nCont[k] = tok.nextToken(); } @@ -1168,37 +1227,32 @@ // directories for (String file : files) { - includedFiles.add( file); + includedFiles.add(file); } for (String dir1 : dirs) { - includedFiles.add( dir1); + includedFiles.add(dir1); } - return includedFiles.toArray(new String[]{}); + return includedFiles.toArray(new String[] {}); } - + private IXMLElement readRefPackData(String refFileName, boolean isselfcontained) - throws CompilerException { + throws CompilerException + { File refXMLFile = new File(refFileName); if (!refXMLFile.isAbsolute()) { refXMLFile = new File(basedir, refFileName); } - if (!refXMLFile.canRead()) - { - throw new CompilerException("Invalid file: " + refXMLFile); - } + if (!refXMLFile.canRead()) { throw new CompilerException("Invalid file: " + refXMLFile); } InputStream specin = null; if (isselfcontained) { - if (!refXMLFile.getAbsolutePath().endsWith(".zip")) - { - throw new CompilerException( - "Invalid file: " + refXMLFile - + ". Selfcontained files can only be of type zip."); - } + if (!refXMLFile.getAbsolutePath().endsWith(".zip")) { throw new CompilerException( + "Invalid file: " + refXMLFile + + ". Selfcontained files can only be of type zip."); } ZipFile zip; try { @@ -1226,7 +1280,7 @@ IXMLParser refXMLParser = new XMLParser(); // We get it - IXMLElement refXMLData = refXMLParser.parse(specin,refXMLFile.getAbsolutePath()); + IXMLElement refXMLData = refXMLParser.parse(specin, refXMLFile.getAbsolutePath()); // Now checked the loaded XML file for basic syntax // We check it @@ -1263,7 +1317,8 @@ * checks that no pack point to a non existent pack and also that there are no circular * dependencies in the packs. */ - public void checkDependencies(List packs) throws CompilerException { + public void checkDependencies(List packs) throws CompilerException + { // Because we use package names in the configuration file we assosiate // the names with the objects Map names = new HashMap(); @@ -1287,20 +1342,18 @@ * We use the dfs graph search algorithm to check whether the graph is acyclic as described in: * Thomas H. Cormen, Charles Leiserson, Ronald Rivest and Clifford Stein. Introduction to * algorithms 2nd Edition 540-549,MIT Press, 2001 - * + * * @param packs The graph * @param names The name map */ - private int dfs(List packs, Map names) { + private int dfs(List packs, Map names) + { Map edges = new HashMap(); for (PackInfo pack : packs) { if (pack.colour == PackInfo.WHITE) { - if (dfsVisit(pack, names, edges) != 0) - { - return -1; - } + if (dfsVisit(pack, names, edges) != 0) { return -1; } } } @@ -1310,15 +1363,13 @@ /** * This function checks for the existence of back edges. */ - private int checkBackEdges(Map edges) { + private int checkBackEdges(Map edges) + { Set keys = edges.keySet(); for (final Edge key : keys) { int color = edges.get(key); - if (color == PackInfo.GREY) - { - return -2; - } + if (color == PackInfo.GREY) { return -2; } } return 0; @@ -1327,19 +1378,22 @@ /** * This class is used for the classification of the edges */ - private class Edge { + private class Edge + { PackInfo u; PackInfo v; - Edge(PackInfo u, PackInfo v) { + Edge(PackInfo u, PackInfo v) + { this.u = u; this.v = v; } } - private int dfsVisit(PackInfo u, Map names, Map edges) { + private int dfsVisit(PackInfo u, Map names, Map edges) + { u.colour = PackInfo.GREY; List deps = u.getDependencies(); if (deps != null) @@ -1362,10 +1416,7 @@ { final int result = dfsVisit(v, names, edges); - if (result != 0) - { - return result; - } + if (result != 0) { return result; } } } } @@ -1375,19 +1426,19 @@ /** * Add files in an archive to a pack - * - * @param archive the archive file to unpack - * @param targetdir the target directory where the content of the archive will be installed - * @param osList The target OS constraints. - * @param override Overriding behaviour. - * @param pack Pack to be packed into + * + * @param archive the archive file to unpack + * @param targetdir the target directory where the content of the archive will be installed + * @param osList The target OS constraints. + * @param override Overriding behaviour. + * @param pack Pack to be packed into * @param additionals Map which contains additional data * @param condition */ protected void addArchiveContent(File baseDir, File archive, String targetdir, - List osList, int override, int blockable, - PackInfo pack, Map additionals, - String condition) throws IOException { + List osList, int override, int blockable, PackInfo pack, Map additionals, + String condition) throws IOException + { FileInputStream fin = new FileInputStream(archive); ZipInputStream zin = new ZipInputStream(fin); @@ -1427,39 +1478,42 @@ /** * Recursive method to add files in a pack. - * - * @param file The file to add. - * @param targetdir The relative path to the parent. - * @param osList The target OS constraints. - * @param override Overriding behaviour. - * @param pack Pack to be packed into + * + * @param file The file to add. + * @param targetdir The relative path to the parent. + * @param osList The target OS constraints. + * @param override Overriding behaviour. + * @param pack Pack to be packed into * @param additionals Map which contains additional data * @param condition - * + * * @throws FileNotFoundException if the file does not exist */ protected void addRecursively(File baseDir, File file, String targetdir, - List osList, int override, int blockable, - PackInfo pack, Map additionals, String condition) throws IOException { + List osList, int override, int blockable, PackInfo pack, Map additionals, + String condition) throws IOException + { String targetfile = targetdir + "/" + file.getName(); if (!file.isDirectory()) { - pack.addFile(baseDir, file, targetfile, osList, override, blockable, additionals, condition); + pack.addFile(baseDir, file, targetfile, osList, override, blockable, additionals, + condition); } else { File[] files = file.listFiles(); if (files.length == 0) // The directory is empty so must be added { - pack.addFile(baseDir, file, targetfile, osList, override, blockable, additionals, condition); + pack.addFile(baseDir, file, targetfile, osList, override, blockable, additionals, + condition); } else { // new targetdir = targetfile; for (File file1 : files) { - addRecursively(baseDir, file1, targetfile, osList, override, blockable, - pack, additionals, condition); + addRecursively(baseDir, file1, targetfile, osList, override, blockable, pack, + additionals, condition); } } } @@ -1467,12 +1521,13 @@ /** * Parse panels and their paramters, locate the panels resources and add to the Packager. - * + * * @param data The XML data. - * + * * @throws CompilerException Description of the Exception */ - protected void addPanels(IXMLElement data) throws CompilerException { + protected void addPanels(IXMLElement data) throws CompilerException + { notifyCompilerListener("addPanels", CompilerListener.BEGIN, data); IXMLElement root = requireChildNamed(data, "panels"); @@ -1532,8 +1587,7 @@ fullClassName = getFullClassName(url, className); } catch (IOException e) - { - } + {} } if (fullClassName != null) @@ -1545,15 +1599,20 @@ panel.className = className; } IXMLElement configurationElement = xmlPanel.getFirstChildNamed("configuration"); - if (configurationElement != null){ + if (configurationElement != null) + { Debug.trace("found a configuration for this panel."); Vector params = configurationElement.getChildrenNamed("param"); - if (params != null){ - for(IXMLElement param : params){ + if (params != null) + { + for (IXMLElement param : params) + { IXMLElement keyElement = param.getFirstChildNamed("key"); IXMLElement valueElement = param.getFirstChildNamed("value"); - if ((keyElement != null) && (valueElement != null)){ - panel.addConfiguration(keyElement.getContent(), valueElement.getContent()); + if ((keyElement != null) && (valueElement != null)) + { + panel.addConfiguration(keyElement.getContent(), valueElement + .getContent()); } } } @@ -1606,21 +1665,38 @@ /** * Adds the resources. - * + * * @param data The XML data. - * + * * @throws CompilerException Description of the Exception */ - protected void addResources(IXMLElement data) throws CompilerException { + protected void addResources(IXMLElement data) throws CompilerException + { notifyCompilerListener("addResources", CompilerListener.BEGIN, data); - IXMLElement root = data.getFirstChildNamed("resources"); - if (root == null) + IXMLElement root = data.getFirstChildNamed(RESOURCES_TAG_NAME); + if (root == null) { return; } + Iterator bundleIterator = root.getChildrenNamed(BUNDLE_TAG_NAME).iterator(); + while (bundleIterator.hasNext()) { - return; + final IXMLElement bundle = bundleIterator.next(); + addResources(bundle.getChildrenNamed(RES_TAG_NAME).iterator(), bundle + .getAttribute("id")); + final String defaultAttr = bundle.getAttribute("default"); + if (defaultAttr != null && (defaultAttr.equalsIgnoreCase("true"))) + { + // add default resources also to root resources + addResources(bundle.getChildrenNamed(RES_TAG_NAME).iterator(), null); + } } + // We process each res markup + Iterator iter = root.getChildrenNamed(RES_TAG_NAME).iterator(); + addResources(iter, null); + notifyCompilerListener("addResources", CompilerListener.END, data); + } - // We process each res markup - Iterator iter = root.getChildrenNamed("res").iterator(); + private void addResources(Iterator iter, String bundleName) + throws CompilerException + { while (iter.hasNext()) { IXMLElement res = iter.next(); @@ -1650,9 +1726,10 @@ File recodedFile = File.createTempFile("izenc", null); recodedFile.deleteOnExit(); - InputStreamReader reader = new InputStreamReader(originalUrl.openStream(), encoding); - OutputStreamWriter writer = new OutputStreamWriter( - new FileOutputStream(recodedFile), "UTF-8"); + InputStreamReader reader = new InputStreamReader(originalUrl.openStream(), + encoding); + OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream( + recodedFile), "UTF-8"); char[] buffer = new char[1024]; int read = 0; @@ -1666,7 +1743,8 @@ originalUrl = recodedFile.toURL(); } - if (parsexml || (!"".equals(encoding)) || (substitute && !compiler.getVariables().isEmpty())) + if (parsexml || (!"".equals(encoding)) + || (substitute && !compiler.getVariables().isEmpty())) { // make the substitutions into a temp file File parsedFile = File.createTempFile("izpp", null); @@ -1760,6 +1838,10 @@ } } + if (bundleName != null && !bundleName.isEmpty()) + { + id = bundleName + "/" + id; + } compiler.addResource(id, url); // remembering references to all added packsLang.xml files @@ -1779,17 +1861,17 @@ } } - notifyCompilerListener("addResources", CompilerListener.END, data); } /** * Adds the ISO3 codes of the langpacks and associated resources. - * + * * @param data The XML data. - * + * * @throws CompilerException Description of the Exception */ - protected void addLangpacks(IXMLElement data) throws CompilerException { + protected void addLangpacks(IXMLElement data) throws CompilerException + { notifyCompilerListener("addLangpacks", CompilerListener.BEGIN, data); IXMLElement root = requireChildNamed(data, "locale"); @@ -1821,12 +1903,13 @@ /** * Builds the Info class from the XML tree. - * + * * @param data The XML data. return The Info. - * + * * @throws Exception Description of the Exception */ - protected void addInfo(IXMLElement data) throws Exception { + protected void addInfo(IXMLElement data) throws Exception + { notifyCompilerListener("addInfo", CompilerListener.BEGIN, data); // Initialisation IXMLElement root = requireChildNamed(data, "info"); @@ -1924,7 +2007,8 @@ else if ("always".equalsIgnoreCase(content)) info.setRebootAction(Info.REBOOT_ACTION_ALWAYS); else - throw new CompilerException("Invalid value ''"+content+"'' of element ''reboot''"); + throw new CompilerException("Invalid value ''" + content + + "'' of element ''reboot''"); if (reboot.hasAttribute("condition")) { @@ -1941,7 +2025,8 @@ if (privileged != null) { - // default behavior for uninstaller elevation: elevate if installer has to be elevated too + // default behavior for uninstaller elevation: elevate if installer has to be + // elevated too info.setRequirePrivilegedExecutionUninstaller(validateYesNoAttribute(privileged, "uninstaller", YES)); } @@ -1989,8 +2074,10 @@ } /** - * Variable declaration is a fragment of the xml file. For example:

+ * Variable declaration is a fragment of the xml file. For example: *

+ *

+ * *

      * <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> dynamicvariables = compiler.getDynamicVariables(); @@ -2055,16 +2139,21 @@ IXMLElement var = iter.next(); String name = requireAttribute(var, "name"); String value = var.getAttribute("value"); - if (value==null){ + if (value == null) + { IXMLElement valueElement = var.getFirstChildNamed("value"); - if (valueElement != null){ + if (valueElement != null) + { value = valueElement.getContent(); - if (value == null){ - parseError("A dynamic variable needs either a value attribute or a value element."); + if (value == null) + { + parseError("A dynamic variable needs either a value attribute or a value element."); } } - else { - parseError("A dynamic variable needs either a value attribute or a value element. Variable name: " + name); + else + { + parseError("A dynamic variable needs either a value attribute or a value element. Variable name: " + + name); } } String conditionid = var.getAttribute("condition"); @@ -2094,12 +2183,13 @@ /** * Parse conditions and add them to the compiler. - * + * * @param data - * + * * @throws CompilerException */ - protected void addConditions(IXMLElement data) throws CompilerException { + protected void addConditions(IXMLElement data) throws CompilerException + { notifyCompilerListener("addConditions", CompilerListener.BEGIN, data); // We get the condition list IXMLElement root = data.getFirstChildNamed("conditions"); @@ -2132,8 +2222,10 @@ } /** - * Properties declaration is a fragment of the xml file. For example:

+ * Properties declaration is a fragment of the xml file. For example: *

+ *

+ * *

      * <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 osList) throws CompilerException { + protected int getBlockableValue(IXMLElement f, List osList) + throws CompilerException + { int blockable = PackFile.BLOCKABLE_NONE; String blockable_val = f.getAttribute("blockable"); @@ -2375,7 +2467,7 @@ // We cannot add this constraint here explicitely, because it // the copied files might be multi-platform. // Print out a warning to inform the user about this fact. - //osList.add(new OsConstraint("windows", null, null, null)); + // osList.add(new OsConstraint("windows", null, null, null)); parseWarn(f, "'blockable' will implicitely apply only on Windows target systems"); } } @@ -2387,15 +2479,16 @@ * Look for a project specified resources, which, if not absolute, are sought relative to the * projects basedir. The path should use '/' as the fileSeparator. If the resource is not found, * a CompilerException is thrown indicating fault in the parent element. - * - * @param path the relative path (using '/' as separator) to the resource. - * @param desc the description of the resource used to report errors + * + * @param path the relative path (using '/' as separator) to the resource. + * @param desc the description of the resource used to report errors * @param parent the IXMLElement the resource is specified in, used to report errors - * + * * @return a URL to the resource. */ private URL findProjectResource(String path, String desc, IXMLElement parent) - throws CompilerException { + throws CompilerException + { URL url = null; File resource = new File(path); if (!resource.isAbsolute()) @@ -2421,7 +2514,8 @@ } private URL findIzPackResource(String path, String desc, IXMLElement parent) - throws CompilerException { + throws CompilerException + { return findIzPackResource(path, desc, parent, false); } @@ -2429,17 +2523,18 @@ * Look for an IzPack resource either in the compiler jar, or within IZPACK_HOME. The path must * not be absolute. The path must use '/' as the fileSeparator (it's used to access the jar * file). If the resource is not found, take appropriate action base on ignoreWhenNotFound flag. - * - * @param path the relative path (using '/' as separator) to the resource. - * @param desc the description of the resource used to report errors - * @param parent the IXMLElement the resource is specified in, used to report errors - * @param ignoreWhenNotFound when false, throws a CompilerException indicating - * fault in the parent element when resource not found. - * + * + * @param path the relative path (using '/' as separator) to the resource. + * @param desc the description of the resource used to report errors + * @param parent the IXMLElement the resource is specified in, used to report errors + * @param ignoreWhenNotFound when false, throws a CompilerException indicating fault in the + * parent element when resource not found. + * * @return a URL to the resource. */ - private URL findIzPackResource(String path, String desc, IXMLElement parent, boolean ignoreWhenNotFound) - throws CompilerException { + private URL findIzPackResource(String path, String desc, IXMLElement parent, + boolean ignoreWhenNotFound) throws CompilerException + { URL url = getClass().getResource("/" + path); if (url == null) { @@ -2481,55 +2576,61 @@ /** * Create parse error with consistent messages. Includes file name. For use When parent is * unknown. - * + * * @param message Brief message explaining error */ - protected void parseError(String message) throws CompilerException { + protected void parseError(String message) throws CompilerException + { throw new CompilerException(filename + ":" + message); } /** * Create parse error with consistent messages. Includes file name and line # of parent. It is * an error for 'parent' to be null. - * - * @param parent The element in which the error occured + * + * @param parent The element in which the error occured * @param message Brief message explaining error */ - protected void parseError(IXMLElement parent, String message) throws CompilerException { + protected void parseError(IXMLElement parent, String message) throws CompilerException + { throw new CompilerException(filename + ":" + parent.getLineNr() + ": " + message); } /** * Create a chained parse error with consistent messages. Includes file name and line # of * parent. It is an error for 'parent' to be null. - * - * @param parent The element in which the error occured + * + * @param parent The element in which the error occured * @param message Brief message explaining error */ protected void parseError(IXMLElement parent, String message, Throwable cause) - throws CompilerException { + throws CompilerException + { throw new CompilerException(filename + ":" + parent.getLineNr() + ": " + message, cause); } /** * Create a parse warning with consistent messages. Includes file name and line # of parent. It * is an error for 'parent' to be null. - * - * @param parent The element in which the warning occured + * + * @param parent The element in which the warning occured * @param message Warning message */ - protected void parseWarn(IXMLElement parent, String message) { + protected void parseWarn(IXMLElement parent, String message) + { System.out.println("Warning: " + filename + ":" + parent.getLineNr() + ": " + message); } /** * Call getFirstChildNamed on the parent, producing a meaningful error message on failure. It is * an error for 'parent' to be null. - * + * * @param parent The element to search for a child - * @param name Name of the child element to get + * @param name Name of the child element to get */ - protected IXMLElement requireChildNamed(IXMLElement parent, String name) throws CompilerException { + protected IXMLElement requireChildNamed(IXMLElement parent, String name) + throws CompilerException + { IXMLElement child = parent.getFirstChildNamed(name); if (child == null) { @@ -2541,10 +2642,11 @@ /** * Call getContent on an element, producing a meaningful error message if not present, or empty, * or a valid URL. It is an error for 'element' to be null. - * + * * @param element The element to get content of */ - protected URL requireURLContent(IXMLElement element) throws CompilerException { + protected URL requireURLContent(IXMLElement element) throws CompilerException + { URL url = null; try { @@ -2560,10 +2662,11 @@ /** * Call getContent on an element, producing a meaningful error message if not present, or empty. * It is an error for 'element' to be null. - * + * * @param element The element to get content of */ - protected String requireContent(IXMLElement element) throws CompilerException { + protected String requireContent(IXMLElement element) throws CompilerException + { String content = element.getContent(); if (content == null || content.length() == 0) { @@ -2572,7 +2675,8 @@ return content; } - protected boolean validateYesNo(String value) { + protected boolean validateYesNo(String value) + { boolean result = false; if ("yes".equalsIgnoreCase(value)) { @@ -2593,12 +2697,13 @@ /** * Call getAttribute on an element, producing a meaningful error message if not present, or * empty. It is an error for 'element' or 'attribute' to be null. - * - * @param element The element to get the attribute value of + * + * @param element The element to get the attribute value of * @param attribute The name of the attribute to get */ protected String requireAttribute(IXMLElement element, String attribute) - throws CompilerException { + throws CompilerException + { String value = element.getAttribute(attribute); if (value == null) { @@ -2612,12 +2717,13 @@ * Get a required attribute of an element, ensuring it is an integer. A meaningful error message * is generated as a CompilerException if not present or parseable as an int. It is an error for * 'element' or 'attribute' to be null. - * - * @param element The element to get the attribute value of + * + * @param element The element to get the attribute value of * @param attribute The name of the attribute to get */ protected int requireIntAttribute(IXMLElement element, String attribute) - throws CompilerException { + throws CompilerException + { String value = element.getAttribute(attribute); if (value == null || value.length() == 0) { @@ -2638,21 +2744,16 @@ /** * Call getAttribute on an element, producing a meaningful error message if not present, or one * of "yes" or "no". It is an error for 'element' or 'attribute' to be null. - * - * @param element The element to get the attribute value of + * + * @param element The element to get the attribute value of * @param attribute The name of the attribute to get */ protected boolean requireYesNoAttribute(IXMLElement element, String attribute) - throws CompilerException { + throws CompilerException + { String value = requireAttribute(element, attribute); - if ("yes".equalsIgnoreCase(value)) - { - return true; - } - if ("no".equalsIgnoreCase(value)) - { - return false; - } + if ("yes".equalsIgnoreCase(value)) { return true; } + if ("no".equalsIgnoreCase(value)) { return false; } parseError(element, "<" + element.getName() + "> invalid attribute '" + attribute + "': Expected (yes|no)"); @@ -2663,27 +2764,19 @@ /** * Call getAttribute on an element, producing a meaningful warning if not "yes" or "no". If the * 'element' or 'attribute' are null, the default value is returned. - * - * @param element The element to get the attribute value of - * @param attribute The name of the attribute to get + * + * @param element The element to get the attribute value of + * @param attribute The name of the attribute to get * @param defaultValue Value returned if attribute not present or invalid */ protected boolean validateYesNoAttribute(IXMLElement element, String attribute, - boolean defaultValue) { - if (element == null) - { - return defaultValue; - } + boolean defaultValue) + { + if (element == null) { return defaultValue; } String value = element.getAttribute(attribute, (defaultValue ? "yes" : "no")); - if ("yes".equalsIgnoreCase(value)) - { - return true; - } - if ("no".equalsIgnoreCase(value)) - { - return false; - } + if ("yes".equalsIgnoreCase(value)) { return true; } + if ("no".equalsIgnoreCase(value)) { return false; } // TODO: should this be an error if it's present but "none of the // above"? @@ -2695,10 +2788,11 @@ /** * The main method if the compiler is invoked by a command-line call. - * + * * @param args The arguments passed on the command-line. */ - public static void main(String[] args) { + public static void main(String[] args) + { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + Compiler.IZPACK_VERSION + " ::."); @@ -2743,10 +2837,7 @@ // First check int nArgs = args.length; - if (nArgs < 1) - { - throw new Exception("no arguments given"); - } + if (nArgs < 1) { throw new Exception("no arguments given"); } // The users wants to know the command line parameters if ("-?".equalsIgnoreCase(args[0])) @@ -2798,74 +2889,74 @@ { switch (args[pos].toLowerCase().charAt(1)) { - case 'b': - if ((pos + 1) < nArgs) - { - pos++; - base = args[pos]; - } - else - { - throw new Exception("base argument missing"); - } - break; - case 'k': - if ((pos + 1) < nArgs) - { - pos++; - kind = args[pos]; - } - else - { - throw new Exception("kind argument missing"); - } - break; - case 'o': - if ((pos + 1) < nArgs) - { - pos++; - output = args[pos]; - } - else - { - throw new Exception("output argument missing"); - } - break; - case 'c': - if ((pos + 1) < nArgs) - { - pos++; - compr_format = args[pos]; - } - else - { - throw new Exception("compression format argument missing"); - } - break; - case 'l': - if ((pos + 1) < nArgs) - { - pos++; - compr_level = Integer.parseInt(args[pos]); - } - else - { - throw new Exception("compression level argument missing"); - } - break; - case 'h': - if ((pos + 1) < nArgs) - { - pos++; - home = args[pos]; - } - else - { - throw new Exception("IzPack home path argument missing"); - } - break; - default: - throw new Exception("unknown argument"); + case 'b': + if ((pos + 1) < nArgs) + { + pos++; + base = args[pos]; + } + else + { + throw new Exception("base argument missing"); + } + break; + case 'k': + if ((pos + 1) < nArgs) + { + pos++; + kind = args[pos]; + } + else + { + throw new Exception("kind argument missing"); + } + break; + case 'o': + if ((pos + 1) < nArgs) + { + pos++; + output = args[pos]; + } + else + { + throw new Exception("output argument missing"); + } + break; + case 'c': + if ((pos + 1) < nArgs) + { + pos++; + compr_format = args[pos]; + } + else + { + throw new Exception("compression format argument missing"); + } + break; + case 'l': + if ((pos + 1) < nArgs) + { + pos++; + compr_level = Integer.parseInt(args[pos]); + } + else + { + throw new Exception("compression level argument missing"); + } + break; + case 'h': + if ((pos + 1) < nArgs) + { + pos++; + home = args[pos]; + } + else + { + throw new Exception("IzPack home path argument missing"); + } + break; + default: + throw new Exception("unknown argument"); } pos++; } @@ -2922,12 +3013,10 @@ System.exit(exitCode); } - private static String resolveIzPackHome(String home) { + private static String resolveIzPackHome(String home) + { File test = new File(home, IZ_TEST_SUBDIR + File.separator + IZ_TEST_FILE); - if (test.exists()) - { - return (home); - } + if (test.exists()) { return (home); } // Try to resolve the path using compiler.jar which also should be under // IZPACK_HOME. String self = Compiler.class.getName(); @@ -2942,10 +3031,7 @@ // No idea. if (np.endsWith("standalone-compiler.jar!") || np.endsWith("standalone-compiler-4.0.0.jar!") - || np.matches("standalone-compiler-[\\d\\.]+.jar!")) - { - return ("."); - } + || np.matches("standalone-compiler-[\\d\\.]+.jar!")) { return ("."); } np = np.substring(0, np.length() - 1); } File root = null; @@ -2959,16 +3045,10 @@ } while (true) { - if (root == null) - { - throw new IllegalArgumentException( - "No valid IzPack home directory found"); - } + if (root == null) { throw new IllegalArgumentException( + "No valid IzPack home directory found"); } test = new File(root, IZ_TEST_SUBDIR + File.separator + IZ_TEST_FILE); - if (test.exists()) - { - return (root.getAbsolutePath()); - } + if (test.exists()) { return (root.getAbsolutePath()); } root = root.getParentFile(); } } @@ -2981,18 +3061,16 @@ * posible, the listeners will be validated. Listener declaration is a fragmention in * install.xml like : - * + * * @param data the XML data - * + * * @throws Exception Description of the Exception */ - private void addCustomListeners(IXMLElement data) throws Exception { + private void addCustomListeners(IXMLElement data) throws Exception + { // We get the listeners IXMLElement root = data.getFirstChildNamed("listeners"); - if (root == null) - { - return; - } + if (root == null) { return; } Iterator iter = root.getChildrenNamed("listener").iterator(); while (iter.hasNext()) { @@ -3002,8 +3080,8 @@ { addCompilerListener((CompilerListener) listener[0]); } - String[] typeNames = new String[]{"installer", "uninstaller"}; - int[] types = new int[]{CustomData.INSTALLER_LISTENER, + String[] typeNames = new String[] { "installer", "uninstaller"}; + int[] types = new int[] { CustomData.INSTALLER_LISTENER, CustomData.UNINSTALLER_LISTENER}; for (int i = 0; i < typeNames.length; ++i) { @@ -3028,14 +3106,15 @@ /** * Returns a list which contains the pathes of all files which are included in the given url. * This method expects as the url param a jar. - * + * * @param url url of the jar file - * + * * @return full qualified paths of the contained files - * + * * @throws Exception */ - private List getContainedFilePaths(URL url) throws Exception { + private List getContainedFilePaths(URL url) throws Exception + { JarInputStream jis = new JarInputStream(url.openStream()); ZipEntry zentry = null; ArrayList fullNames = new ArrayList(); @@ -3055,12 +3134,12 @@ /** * Returns the qualified class name for the given class. This method expects as the url param a * jar file which contains the given class. It scans the zip entries of the jar file. - * - * @param url url of the jar file which contains the class + * + * @param url url of the jar file which contains the class * @param className short name of the class for which the full name should be resolved - * + * * @return full qualified class name - * + * * @throws IOException */ private String getFullClassName(URL url, String className) throws IOException // throws @@ -3092,11 +3171,9 @@ if (nonCasePos != -1 && name.length() == nonCasePos + className.length() + 6) // "Main" class with different case found - { - throw new IllegalArgumentException( - "Fatal error! The declared panel name in the xml file (" + className - + ") differs in case to the founded class file (" + name + ")."); - } + { throw new IllegalArgumentException( + "Fatal error! The declared panel name in the xml file (" + className + + ") differs in case to the founded class file (" + name + ")."); } } jis.close(); return (null); @@ -3107,21 +3184,19 @@ * node will be expected. Additional it is expected, that either "findIzPackResource" returns an * url based on "bin/customActions/[className].jar", or that the listener element has a jar * attribute specifying the listener jar path. The class will be loaded via an URLClassLoader. - * + * * @param var the xml element of the "listener" node - * + * * @return instance of the defined compiler listener - * + * * @throws Exception */ - private Object[] getCompilerListenerInstance(IXMLElement var) throws Exception { + private Object[] getCompilerListenerInstance(IXMLElement var) throws Exception + { String className = var.getAttribute("compiler"); Class listener = null; Object instance = null; - if (className == null) - { - return (null); - } + if (className == null) { return (null); } // CustomAction files come in jars packaged IzPack, or they can be // specified via a jar attribute on the listener @@ -3177,7 +3252,7 @@ } // Use the class loader of the interface as parent, else // compile will fail at using it via an Ant task. - URLClassLoader ucl = new URLClassLoader(new URL[]{url}, CompilerListener.class + URLClassLoader ucl = new URLClassLoader(new URL[] { url}, CompilerListener.class .getClassLoader()); listener = ucl.loadClass(fullName); } @@ -3195,30 +3270,32 @@ + CompilerListener.class.toString()); } List constraints = OsConstraint.getOsList(var); - return (new Object[]{instance, className, constraints}); + return (new Object[] { instance, className, constraints}); } /** * Add a CompilerListener. A registered CompilerListener will be called at every enhancmend * point of compiling. - * + * * @param pe CompilerListener which should be added */ - private void addCompilerListener(CompilerListener pe) { + private void addCompilerListener(CompilerListener pe) + { compilerListeners.add(pe); } /** * Calls all defined compile listeners notify method with the given data - * + * * @param callerName name of the calling method as string - * @param state CompileListener.BEGIN or END - * @param data current install data - * + * @param state CompileListener.BEGIN or END + * @param data current install data + * * @throws CompilerException */ private void notifyCompilerListener(String callerName, int state, IXMLElement data) - throws CompilerException { + throws CompilerException + { Iterator i = compilerListeners.iterator(); IPackager packager = compiler.getPackager(); while (i != null && i.hasNext()) @@ -3231,12 +3308,13 @@ /** * Calls the reviseAdditionalDataMap method of all registered CompilerListener's. - * + * * @param f file releated XML node - * + * * @return a map with the additional attributes */ - private Map getAdditionals(IXMLElement f) throws CompilerException { + private Map getAdditionals(IXMLElement f) throws CompilerException + { Iterator i = compilerListeners.iterator(); Map retval = null; try @@ -3257,6 +3335,7 @@ * A function to merge multiple packsLang-files into a single file for each identifier, e.g. two * resource files *

+ * *

      *    <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 + ">"); } } - } + } } 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.

"); - msg.append("This could be from a previous failed installation attempt or you may have accidentally launched
"); - msg.append("the installer twice. The recommended action is to select 'Exit' and wait for the other copy of
"); - msg.append("the installer to start. If you are sure there is no other copy of the installer running, click
"); + msg + .append("The " + + appName + + " installer you are attempting to run seems to have a copy already running.

"); + msg + .append("This could be from a previous failed installation attempt or you may have accidentally launched
"); + msg + .append("the installer twice. The recommended action is to select 'Exit' and wait for the other copy of
"); + msg + .append("the installer to start. If you are sure there is no other copy of the installer running, click
"); msg.append("the 'Continue' button to allow this installer to run.

"); msg.append("Are you sure you want to continue with this installation?"); msg.append(""); JLabel label = new JLabel(msg.toString()); label.setFont(new Font("Sans Serif", Font.PLAIN, 12)); - Object[] optionValues = {"Continue", "Exit"}; + Object[] optionValues = { "Continue", "Exit"}; int selectedOption = JOptionPane.showOptionDialog(null, label, "Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, optionValues, optionValues[1]); @@ -275,7 +316,7 @@ /** * Checks the Java version. - * + * * @throws Exception Description of the Exception */ private void checkJavaVersion() throws Exception @@ -304,23 +345,19 @@ */ private void checkJDKAvailable() { - if (!this.installdata.info.isJdkRequired()) - { - return; - } + if (!this.installdata.info.isJdkRequired()) { return; } FileExecutor exec = new FileExecutor(); String[] output = new String[2]; - String[] params = {"javac", "-help"}; + String[] params = { "javac", "-help"}; if (exec.executeCommand(params, output) != 0) { String[] message = { "It looks like your system does not have a Java Development Kit (JDK) available.", "The software that you plan to install requires a JDK for both its installation and execution.", - "\n", - "Do you still want to proceed with the installation process?" - }; - int status = JOptionPane.showConfirmDialog(null, message, "Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); + "\n", "Do you still want to proceed with the installation process?"}; + int status = JOptionPane.showConfirmDialog(null, message, "Warning", + JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (status == JOptionPane.NO_OPTION) { System.exit(1); @@ -330,7 +367,7 @@ /** * Loads the suitable langpack. - * + * * @throws Exception Description of the Exception */ private void loadLangPack() throws Exception @@ -338,17 +375,23 @@ // Initialisations List availableLangPacks = getAvailableLangPacks(); int npacks = availableLangPacks.size(); - if (npacks == 0) - { - throw new Exception("no language pack available"); - } + if (npacks == 0) { throw new Exception("no language pack available"); } String selectedPack; // Dummy Frame JFrame frame = new JFrame(); - frame.setIconImage(new ImageIcon(this.getClass().getResource("/img/JFrameIcon.png")) - .getImage()); + ResourceManager rm = new ResourceManager(this.installdata); + ImageIcon imageIcon = null; + try + { + imageIcon = rm.getImageIconResource("JFrameIcon"); + } + catch (ResourceNotFoundException e) + { + imageIcon = new ImageIcon(this.getClass().getResource("/img/JFrameIcon.png")); + } + frame.setIconImage(imageIcon.getImage()); Dimension frameSize = frame.getSize(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((screenSize.width - frameSize.width) / 2, @@ -357,7 +400,7 @@ // We get the langpack name if (npacks != 1) { - LanguageDialog picker = new LanguageDialog(frame, availableLangPacks.toArray()); + LanguageDialog picker = new LanguageDialog(frame, availableLangPacks.toArray(), rm); picker.setSelection(Locale.getDefault().getISO3Language().toLowerCase()); picker.setModal(true); picker.toFront(); @@ -366,10 +409,7 @@ picker.setVisible(true); selectedPack = (String) picker.getSelection(); - if (selectedPack == null) - { - throw new Exception("installation canceled"); - } + if (selectedPack == null) { throw new Exception("installation canceled"); } } else { @@ -389,7 +429,7 @@ /** * Loads the suitable L&F. - * + * * @throws Exception Description of the Exception */ protected void loadLookAndFeel() throws Exception @@ -414,32 +454,28 @@ // Resolve whether button icons should be used or not. boolean useButtonIcons = true; if (installdata.guiPrefs.modifier.containsKey("useButtonIcons") - && "no".equalsIgnoreCase(installdata.guiPrefs.modifier - .get("useButtonIcons"))) + && "no".equalsIgnoreCase(installdata.guiPrefs.modifier.get("useButtonIcons"))) { useButtonIcons = false; } ButtonFactory.useButtonIcons(useButtonIcons); boolean useLabelIcons = true; if (installdata.guiPrefs.modifier.containsKey("useLabelIcons") - && "no".equalsIgnoreCase(installdata.guiPrefs.modifier - .get("useLabelIcons"))) + && "no".equalsIgnoreCase(installdata.guiPrefs.modifier.get("useLabelIcons"))) { useLabelIcons = false; } LabelFactory.setUseLabelIcons(useLabelIcons); if (installdata.guiPrefs.modifier.containsKey("labelFontSize")) - { //'labelFontSize' modifier found in 'guiprefs' - final String valStr = - installdata.guiPrefs.modifier.get("labelFontSize"); + { // 'labelFontSize' modifier found in 'guiprefs' + final String valStr = installdata.guiPrefs.modifier.get("labelFontSize"); try - { //parse value and enter as label-font-size multiplier: + { // parse value and enter as label-font-size multiplier: LabelFactory.setLabelFontSize(Float.parseFloat(valStr)); } catch (NumberFormatException ex) - { //error parsing value; log message - Debug.log("Error parsing guiprefs 'labelFontSize' value (" + - valStr + ')'); + { // error parsing value; log message + Debug.log("Error parsing guiprefs 'labelFontSize' value (" + valStr + ')'); } } if (laf == null) @@ -474,16 +510,18 @@ // make it always true. ButtonFactory.useButtonIcons(useButtonIcons); installdata.buttonsHColor = new Color(255, 255, 255); - Class lafClass = (Class) Class.forName("com.incors.plaf.kunststoff.KunststoffLookAndFeel"); + Class lafClass = (Class) Class + .forName("com.incors.plaf.kunststoff.KunststoffLookAndFeel"); Class mtheme = Class.forName("javax.swing.plaf.metal.MetalTheme"); - Class[] params = {mtheme}; - Class theme = (Class) Class.forName("com.izforge.izpack.gui.IzPackKMetalTheme"); + Class[] params = { mtheme}; + Class theme = (Class) Class + .forName("com.izforge.izpack.gui.IzPackKMetalTheme"); Method setCurrentThemeMethod = lafClass.getMethod("setCurrentTheme", params); // We invoke and place Kunststoff as our L&F LookAndFeel kunststoff = lafClass.newInstance(); MetalTheme ktheme = theme.newInstance(); - Object[] kparams = {ktheme}; + Object[] kparams = { ktheme}; UIManager.setLookAndFeel(kunststoff); setCurrentThemeMethod.invoke(kunststoff, kparams); @@ -563,12 +601,15 @@ Map variants = new TreeMap(); variants.put("default", "org.jvnet.substance.SubstanceLookAndFeel"); // Ugly!!! variants.put("business", "org.jvnet.substance.skin.SubstanceBusinessLookAndFeel"); - variants.put("business-blue", "org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel"); - variants.put("business-black", "org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel"); + variants.put("business-blue", + "org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel"); + variants.put("business-black", + "org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel"); variants.put("creme", "org.jvnet.substance.skin.SubstanceCremeLookAndFeel"); variants.put("sahara", "org.jvnet.substance.skin.SubstanceSaharaLookAndFeel"); variants.put("moderate", "org.jvnet.substance.skin.SubstanceModerateLookAndFeel"); - variants.put("officesilver", "org.jvnet.substance.skin.SubstanceOfficeSilver2007LookAndFeel"); + variants.put("officesilver", + "org.jvnet.substance.skin.SubstanceOfficeSilver2007LookAndFeel"); String variant = variants.get("default"); Map params = installdata.guiPrefs.lookAndFeelParams.get(laf); @@ -587,7 +628,7 @@ /** * Loads the GUI. - * + * * @throws Exception Description of the Exception */ private void loadGUI() throws Exception @@ -612,28 +653,25 @@ VariableSubstitutor vs = new VariableSubstitutor(installdata.getVariables()); title = vs.substitute(message, null); } - new InstallerFrame(title, this.installdata,this); + new InstallerFrame(title, this.installdata, this); } /** * Returns whether flags should be used in the language selection dialog or not. - * + * * @return whether flags should be used in the language selection dialog or not */ protected boolean useFlags() { if (installdata.guiPrefs.modifier.containsKey("useFlags") - && "no".equalsIgnoreCase(installdata.guiPrefs.modifier.get("useFlags"))) - { - return (false); - } + && "no".equalsIgnoreCase(installdata.guiPrefs.modifier.get("useFlags"))) { return (false); } return (true); } /** * Returns the type in which the language should be displayed in the language selction dialog. * Possible are "iso3", "native" and "usingDefault". - * + * * @return language display type */ protected String getLangType() @@ -645,10 +683,7 @@ // Verify that the value is valid, else return the default. for (String aLANGUAGE_DISPLAY_TYPES : LANGUAGE_DISPLAY_TYPES) { - if (val.equalsIgnoreCase(aLANGUAGE_DISPLAY_TYPES)) - { - return (val); - } + if (val.equalsIgnoreCase(aLANGUAGE_DISPLAY_TYPES)) { return (val); } } Debug.trace("Value for language display type not valid; value: " + val); } @@ -659,7 +694,7 @@ * Used to prompt the user for the language. Languages can be displayed in iso3 or the native * notation or the notation of the default locale. Revising to native notation is based on code * from Christian Murphy (patch #395). - * + * * @author Julien Ponge * @author Christian Murphy * @author Klaus Bartz @@ -686,16 +721,17 @@ /** * The constructor. - * + * * @param items The items to display in the box. */ - public LanguageDialog(JFrame frame, Object[] items) + public LanguageDialog(JFrame frame, Object[] items, ResourceManager rm) { super(frame); - + ImageIcon img = null; try { loadLookAndFeel(); + img = rm.getImageIconResource("installer.langsel.img"); } catch (Exception err) { @@ -718,7 +754,6 @@ gbConstraints.ipadx = 0; gbConstraints.ipady = 6; - ImageIcon img = getImage(); JLabel imgLabel = new JLabel(img); gbConstraints.gridy = 0; contentPane.add(imgLabel); @@ -774,7 +809,7 @@ /** * Revises iso3 language items depending on the language display type. - * + * * @param items item array to be revised * @return the revised array */ @@ -782,21 +817,13 @@ { String langType = getLangType(); // iso3: nothing todo. - if (langType.equals(LANGUAGE_DISPLAY_TYPES[0])) - { - return (items); - } + if (langType.equals(LANGUAGE_DISPLAY_TYPES[0])) { return (items); } // native: get the names as they are written in that language. - if (langType.equals(LANGUAGE_DISPLAY_TYPES[1])) - { - return (expandItems(items, (new JComboBox()).getFont())); - } + if (langType.equals(LANGUAGE_DISPLAY_TYPES[1])) { return (expandItems(items, + (new JComboBox()).getFont())); } // default: get the names as they are written in the default // language. - if (langType.equals(LANGUAGE_DISPLAY_TYPES[2])) - { - return (expandItems(items, null)); - } + if (langType.equals(LANGUAGE_DISPLAY_TYPES[2])) { return (expandItems(items, null)); } // Should never be. return (items); } @@ -805,8 +832,8 @@ * Expands the given iso3 codes to language names. If a testFont is given, the codes are * tested whether they can displayed or not. If not, or no font given, the language name * will be returned as written in the default language of this VM. - * - * @param items item array to be expanded to the language name + * + * @param items item array to be expanded to the language name * @param testFont font to test wheter a name is displayable * @return aray of expanded items */ @@ -835,8 +862,8 @@ * Expands the given iso3 code to a language name. If a testFont is given, the code will be * tested whether it is displayable or not. If not, or no font given, the language name will * be returned as written in the default language of this VM. - * - * @param item item to be expanded to the language name + * + * @param item item to be expanded to the language name * @param testFont font to test wheter the name is displayable * @return expanded item */ @@ -856,15 +883,11 @@ } if (iso2Str == null) // Unknown item, return it self. - { - return (item); - } + { return (item); } Locale locale = new Locale((String) iso2Str); if (testFont == null) // Return the language name in the spelling of the default locale. - { - return (locale.getDisplayLanguage()); - } + { return (locale.getDisplayLanguage()); } // Get the language name in the spelling of that language. String str = locale.getDisplayLanguage(locale); int cdut = testFont.canDisplayUpTo(str); @@ -879,7 +902,7 @@ /** * Loads an image. - * + * * @return The image icon. */ public ImageIcon getImage() @@ -898,7 +921,7 @@ /** * Gets the selected object. - * + * * @return The selected item. */ public Object getSelection() @@ -913,7 +936,7 @@ /** * Sets the selection. - * + * * @param item The item to be selected. */ public void setSelection(Object item) @@ -941,7 +964,7 @@ /** * Closer. - * + * * @param e The event. */ public void actionPerformed(ActionEvent e) @@ -951,7 +974,7 @@ /** * The window events handler. - * + * * @author Julien Ponge */ private class WindowHandler extends WindowAdapter @@ -959,7 +982,7 @@ /** * We can't avoid the exit here, so don't call exit anywhere else. - * + * * @param e the event. */ public void windowClosing(WindowEvent e) @@ -971,7 +994,7 @@ /** * A list cell renderer that adds the flags on the display. - * + * * @author Julien Ponge */ private static class FlagRenderer extends JLabel implements ListCellRenderer @@ -996,16 +1019,16 @@ /** * Returns a suitable cell. - * - * @param list The list. - * @param value The object. - * @param index The index. - * @param isSelected true if it is selected. + * + * @param list The list. + * @param value The object. + * @param index The index. + * @param isSelected true if it is selected. * @param cellHasFocus Description of the Parameter * @return The cell. */ public Component getListCellRendererComponent(JList list, Object value, int index, - boolean isSelected, boolean cellHasFocus) + boolean isSelected, boolean cellHasFocus) { // We put the label String iso3 = (String) value; 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.List panelsOrder = installdata.panelsOrder; int i; @@ -239,16 +298,18 @@ Class[] paramsClasses = new Class[2]; paramsClasses[0] = Class.forName("com.izforge.izpack.installer.InstallerFrame"); paramsClasses[1] = Class.forName("com.izforge.izpack.installer.InstallData"); - Object[] params = {this, installdata}; + Object[] params = { this, installdata}; // We load each of them int curVisPanelNumber = 0; int lastVis = 0; int count = 0; - for (i = 0; i < size; i++) { + for (i = 0; i < size; i++) + { // We add the panel Panel p = panelsOrder.get(i); - if (!OsConstraint.oneMatchesCurrentSystem(p.osConstraints)) { + if (!OsConstraint.oneMatchesCurrentSystem(p.osConstraints)) + { continue; } className = p.className; @@ -268,15 +329,18 @@ { for (int actionIndex = 0; actionIndex < preConstgructionActions.size(); actionIndex++) { - PanelAction action = PanelActionFactory.createPanelAction(preConstgructionActions.get(actionIndex)); - action.initialize(p.getPanelActionConfiguration(preConstgructionActions.get(actionIndex))); + PanelAction action = PanelActionFactory + .createPanelAction(preConstgructionActions.get(actionIndex)); + action.initialize(p.getPanelActionConfiguration(preConstgructionActions + .get(actionIndex))); action.executeAction(AutomatedInstallData.getInstance(), null); } } object = constructor.newInstance(params); panel = (IzPanel) object; String dataValidator = p.getValidator(); - if (dataValidator != null) { + if (dataValidator != null) + { panel.setValidationService(DataValidatorFactory.createDataValidator(dataValidator)); } @@ -317,9 +381,12 @@ } installdata.panels.add(panel); - if (panel.isHidden()) { + if (panel.isHidden()) + { visiblePanelMapping.add(count, -1); - } else { + } + else + { visiblePanelMapping.add(count, curVisPanelNumber); curVisPanelNumber++; lastVis = count; @@ -340,10 +407,11 @@ /** * Loads the icons. - * + * * @throws Exception Description of the Exception */ - private void loadIcons() throws Exception { + private void loadIcons() throws Exception + { // Initialisations icons = new IconsDatabase(); URL url; @@ -361,7 +429,8 @@ // We load the icons Vector children = data.getChildrenNamed("icon"); int size = children.size(); - for (int i = 0; i < size; i++) { + for (int i = 0; i < size; i++) + { icon = children.get(i); url = InstallerFrame.class.getResource(icon.getAttribute("res")); img = new ImageIcon(url); @@ -371,7 +440,8 @@ // We load the Swing-specific icons children = data.getChildrenNamed("sysicon"); size = children.size(); - for (int i = 0; i < size; i++) { + for (int i = 0; i < size; i++) + { icon = children.get(i); url = InstallerFrame.class.getResource(icon.getAttribute("res")); img = new ImageIcon(url); @@ -381,16 +451,19 @@ /** * Loads custom icons into the installer. - * + * * @throws Exception */ - protected void loadCustomIcons() throws Exception { + protected void loadCustomIcons() throws Exception + { // We try to load and add a custom langpack. InputStream inXML = null; - try { + try + { inXML = ResourceManager.getInstance().getInputStream(CUSTOM_ICONS_RESOURCEFILE); } - catch (Throwable exception) { + catch (Throwable exception) + { Debug.trace("Resource " + CUSTOM_ICONS_RESOURCEFILE + " not defined. No custom icons available."); return; @@ -409,7 +482,8 @@ // We load the icons Vector children = data.getChildrenNamed("icon"); int size = children.size(); - for (int i = 0; i < size; i++) { + for (int i = 0; i < size; i++) + { icon = children.get(i); url = InstallerFrame.class.getResource(icon.getAttribute("res")); img = new ImageIcon(url); @@ -420,7 +494,8 @@ // We load the Swing-specific icons children = data.getChildrenNamed("sysicon"); size = children.size(); - for (int i = 0; i < size; i++) { + for (int i = 0; i < size; i++) + { icon = children.get(i); url = InstallerFrame.class.getResource(icon.getAttribute("res")); img = new ImageIcon(url); @@ -431,11 +506,23 @@ /** * Builds the GUI. */ - private void buildGUI() { + private void buildGUI() + { this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); // patch 06/07/2005, - // Fabrice Mirabile // Sets the frame icon - setIconImage(icons.getImageIcon("JFrameIcon").getImage()); + try + { + ImageIcon jframeIcon = ResourceManager.getInstance().getImageIconResource("JFrameIcon"); + if (jframeIcon == null) + { + jframeIcon = icons.getImageIcon("JFrameIcon"); + } + setIconImage(jframeIcon.getImage()); + } + catch (Exception e) + { + // ignore + } // Prepares the glass pane to block the gui interaction when needed JPanel glassPane = (JPanel) getGlassPane(); @@ -510,22 +597,28 @@ JPanel debugpanel = debugger.getDebugPanel(); // create a debug panel if TRACE is enabled - if (Debug.isTRACE()) { + if (Debug.isTRACE()) + { if (installdata.guiPrefs.modifier.containsKey("showDebugWindow") - && Boolean.valueOf(installdata.guiPrefs.modifier.get("showDebugWindow"))) { + && Boolean.valueOf(installdata.guiPrefs.modifier.get("showDebugWindow"))) + { JFrame debugframe = new JFrame("Debug information"); debugframe.setContentPane(debugpanel); debugframe.setSize(new Dimension(400, 400)); debugframe.setVisible(true); - } else { + } + else + { debugpanel.setPreferredSize(new Dimension(200, 400)); contentPane.add(debugpanel, BorderLayout.EAST); } } - try { + try + { ImageIcon icon = loadIcon(ICON_RESOURCE, 0, true); - if (icon != null) { + if (icon != null) + { JPanel imgPanel = new JPanel(); imgPanel.setLayout(new BorderLayout()); imgPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0)); @@ -535,7 +628,8 @@ contentPane.add(imgPanel, BorderLayout.WEST); } } - catch (Exception e) { + catch (Exception e) + { // ignore } @@ -545,43 +639,51 @@ createHeading(navPanel); } - private void callGUIListener(int what) { + private void callGUIListener(int what) + { callGUIListener(what, null); } - private void callGUIListener(int what, Object param) { + private void callGUIListener(int what, Object param) + { Iterator iter = guiListener.iterator(); - while (iter.hasNext()) { + while (iter.hasNext()) + { (iter.next()).guiActionPerformed(what, param); } } /** * Loads icon for given panel. - * - * @param resPrefix resources prefix. - * @param PanelNo panel id. + * + * @param resPrefix resources prefix. + * @param PanelNo panel id. * @param tryBaseIcon should try to fallback to base icon? - * + * * @return icon image - * + * * @throws ResourceNotFoundException * @throws IOException */ private ImageIcon loadIcon(String resPrefix, int PanelNo, boolean tryBaseIcon) - throws ResourceNotFoundException, IOException { + throws ResourceNotFoundException, IOException + { ResourceManager rm = ResourceManager.getInstance(); ImageIcon icon = null; String iconext = this.getIconResourceNameExtension(); - if (tryBaseIcon) { - try { + if (tryBaseIcon) + { + try + { icon = rm.getImageIconResource(resPrefix); } catch (Exception e) // This is not that clean ... { icon = rm.getImageIconResource(resPrefix + "." + PanelNo + iconext); } - } else { + } + else + { icon = rm.getImageIconResource(resPrefix + "." + PanelNo + iconext); } return (icon); @@ -589,30 +691,35 @@ /** * Loads icon for given panel id. - * - * @param resPrefix resource prefix. - * @param panelid panel id. + * + * @param resPrefix resource prefix. + * @param panelid panel id. * @param tryBaseIcon should try to load base icon? - * + * * @return image icon - * + * * @throws ResourceNotFoundException * @throws IOException */ private ImageIcon loadIcon(String resPrefix, String panelid, boolean tryBaseIcon) - throws ResourceNotFoundException, IOException { + throws ResourceNotFoundException, IOException + { ResourceManager rm = ResourceManager.getInstance(); ImageIcon icon = null; String iconext = this.getIconResourceNameExtension(); - if (tryBaseIcon) { - try { + if (tryBaseIcon) + { + try + { icon = rm.getImageIconResource(resPrefix); } catch (Exception e) // This is not that clean ... { icon = rm.getImageIconResource(resPrefix + "." + panelid + iconext); } - } else { + } + else + { icon = rm.getImageIconResource(resPrefix + "." + panelid + iconext); } return (icon); @@ -621,76 +728,99 @@ /** * Returns the current set extension to icon resource names. Can be used to change the static * installer image based on user input - * + * * @return a resource extension or an empty string if the variable was not set. */ - private String getIconResourceNameExtension() { - try { + private String getIconResourceNameExtension() + { + try + { String iconext = this.installdata.getVariable(ICON_RESOURCE_EXT_VARIABLE_NAME); - if (iconext == null) { + if (iconext == null) + { iconext = ""; - } else { + } + else + { - if ((iconext.length() > 0) && (iconext.charAt(0) != '.')) { + if ((iconext.length() > 0) && (iconext.charAt(0) != '.')) + { iconext = "." + iconext; } } iconext = iconext.trim(); return iconext; } - catch (Exception e) { + catch (Exception e) + { // in case of error, return an empty string return ""; } } - private void loadAndShowImage(int panelNo) { + private void loadAndShowImage(int panelNo) + { loadAndShowImage(iconLabel, ICON_RESOURCE, panelNo); } - private void loadAndShowImage(int panelNo, String panelid) { + private void loadAndShowImage(int panelNo, String panelid) + { loadAndShowImage(iconLabel, ICON_RESOURCE, panelNo, panelid); } - private void loadAndShowImage(JLabel iLabel, String resPrefix, int panelno, String panelid) { + private void loadAndShowImage(JLabel iLabel, String resPrefix, int panelno, String panelid) + { ImageIcon icon = null; - try { + try + { icon = loadIcon(resPrefix, panelid, false); } - catch (Exception e) { - try { + catch (Exception e) + { + try + { icon = loadIcon(resPrefix, panelno, false); } - catch (Exception ex) { - try { + catch (Exception ex) + { + try + { icon = loadIcon(resPrefix, panelid, true); } - catch (Exception e1) { + catch (Exception e1) + { // ignore } } } - if (icon != null) { + if (icon != null) + { iLabel.setVisible(false); iLabel.setIcon(icon); iLabel.setVisible(true); } } - private void loadAndShowImage(JLabel iLabel, String resPrefix, int panelNo) { + private void loadAndShowImage(JLabel iLabel, String resPrefix, int panelNo) + { ImageIcon icon = null; - try { + try + { icon = loadIcon(resPrefix, panelNo, false); } - catch (Exception e) { - try { + catch (Exception e) + { + try + { icon = loadIcon(resPrefix, panelNo, true); } - catch (Exception e1) { + catch (Exception e1) + { // ignore } } - if (icon != null) { + if (icon != null) + { iLabel.setVisible(false); iLabel.setIcon(icon); iLabel.setVisible(true); @@ -700,7 +830,8 @@ /** * Shows the frame. */ - private void showFrame() { + private void showFrame() + { pack(); setSize(installdata.guiPrefs.width, installdata.guiPrefs.height); setResizable(installdata.guiPrefs.resizable); @@ -715,26 +846,30 @@ /** * Switches the current panel. - * + * * @param last Description of the Parameter */ - protected void switchPanel(int last) { + protected void switchPanel(int last) + { // refresh dynamic variables every time, a panel switch is done this.parentInstaller.refreshDynamicVariables(substitutor, installdata); - try { - if (installdata.curPanelNumber < last) { + try + { + if (installdata.curPanelNumber < last) + { isBack = true; } panelsContainer.setVisible(false); IzPanel panel = installdata.panels.get(installdata.curPanelNumber); IzPanel l_panel = installdata.panels.get(last); showHelpButton(panel.canShowHelp()); - if (Debug.isTRACE()) { + if (Debug.isTRACE()) + { debugger.switchPanel(panel.getMetadata(), l_panel.getMetadata()); } Log.getInstance().addDebugMessage( "InstallerFrame.switchPanel: try switching panel from {0} to {1} ({2} to {3})", - new String[]{l_panel.getClass().getName(), panel.getClass().getName(), + new String[] { l_panel.getClass().getName(), panel.getClass().getName(), Integer.toString(last), Integer.toString(installdata.curPanelNumber)}, DebugConstants.PANEL_TRACE, null); @@ -743,29 +878,39 @@ // writing out that script. // l_panel.makeXMLData(installdata.xmlData.getChildAtIndex(last)); // No previos button in the first visible panel - if (visiblePanelMapping.get(installdata.curPanelNumber) == 0) { + if (visiblePanelMapping.get(installdata.curPanelNumber) == 0) + { prevButton.setVisible(false); lockPrevButton(); unlockNextButton(); // if we push the button back at the license // panel } // Only the exit button in the last panel. - else if (visiblePanelMapping.get(installdata.panels.size()) == installdata.curPanelNumber) { + else if (visiblePanelMapping.get(installdata.panels.size()) == installdata.curPanelNumber) + { prevButton.setVisible(false); nextButton.setVisible(false); lockNextButton(); - } else { - if (hasNavigatePrevious(installdata.curPanelNumber, true) != -1) { + } + else + { + if (hasNavigatePrevious(installdata.curPanelNumber, true) != -1) + { prevButton.setVisible(true); unlockPrevButton(); - } else { + } + else + { lockPrevButton(); prevButton.setVisible(false); } - if (hasNavigateNext(installdata.curPanelNumber, true) != -1) { + if (hasNavigateNext(installdata.curPanelNumber, true) != -1) + { nextButton.setVisible(true); unlockNextButton(); - } else { + } + else + { lockNextButton(); nextButton.setVisible(false); } @@ -777,15 +922,19 @@ // No idea why... (Klaus Bartz, 06.09.25) SwingUtilities.invokeLater(new Runnable() { - public void run() { + public void run() + { JButton cdb = null; String buttonName = "next"; - if (nextButton.isEnabled()) { + if (nextButton.isEnabled()) + { cdb = nextButton; quitButton.setDefaultCapable(false); prevButton.setDefaultCapable(false); nextButton.setDefaultCapable(true); - } else if (quitButton.isEnabled()) { + } + else if (quitButton.isEnabled()) + { cdb = quitButton; buttonName = "quit"; quitButton.setDefaultCapable(true); @@ -795,7 +944,7 @@ getRootPane().setDefaultButton(cdb); Log.getInstance().addDebugMessage( "InstallerFrame.switchPanel: setting {0} as default button", - new String[]{buttonName}, DebugConstants.PANEL_TRACE, null); + new String[] { buttonName}, DebugConstants.PANEL_TRACE, null); } }); @@ -804,18 +953,23 @@ l_panel.panelDeactivate(); panelsContainer.add(panel); - if (panel.getInitialFocus() != null) { // Initial focus hint should be performed after current panel + if (panel.getInitialFocus() != null) + { // Initial focus hint should be performed after current panel // was added to the panels container, else the focus hint will // be ignored. // Give a hint for the initial focus to the system. final Component inFoc = panel.getInitialFocus(); - if (JAVA_SPECIFICATION_VERSION < 1.35) { + if (JAVA_SPECIFICATION_VERSION < 1.35) + { inFoc.requestFocus(); - } else { // On java VM version >= 1.5 it works only if + } + else + { // On java VM version >= 1.5 it works only if // invoke later will be used. SwingUtilities.invokeLater(new Runnable() { - public void run() { + public void run() + { inFoc.requestFocusInWindow(); } }); @@ -824,9 +978,11 @@ * On editable text components position the caret to the end of the cust existent * text. */ - if (inFoc instanceof JTextComponent) { + if (inFoc instanceof JTextComponent) + { JTextComponent inText = (JTextComponent) inFoc; - if (inText.isEditable() && inText.getDocument() != null) { + if (inText.isEditable() && inText.getDocument() != null) + { inText.setCaretPosition(inText.getDocument().getLength()); } } @@ -837,10 +993,13 @@ panel.panelActivate(); panelsContainer.setVisible(true); Panel metadata = panel.getMetadata(); - if ((metadata != null) && (!"UNKNOWN".equals(metadata.getPanelid()))) { + if ((metadata != null) && (!"UNKNOWN".equals(metadata.getPanelid()))) + { loadAndShowImage(visiblePanelMapping.get(installdata.curPanelNumber), metadata .getPanelid()); - } else { + } + else + { loadAndShowImage(visiblePanelMapping.get(installdata.curPanelNumber)); } isBack = false; @@ -848,7 +1007,8 @@ Log.getInstance().addDebugMessage("InstallerFrame.switchPanel: switched", null, DebugConstants.PANEL_TRACE, null); } - catch (Exception err) { + catch (Exception err) + { err.printStackTrace(); } } @@ -856,36 +1016,46 @@ /** * Writes the uninstalldata. */ - private void writeUninstallData() { + private void writeUninstallData() + { // Show whether a separated logfile should be also written or not. String logfile = installdata.getVariable("InstallerFrame.logfilePath"); BufferedWriter extLogWriter = null; - if (logfile != null) { - if (logfile.toLowerCase().startsWith("default")) { + if (logfile != null) + { + if (logfile.toLowerCase().startsWith("default")) + { logfile = installdata.info.getUninstallerPath() + "/install.log"; } logfile = IoHelper.translatePath(logfile, new VariableSubstitutor(installdata .getVariables())); File outFile = new File(logfile); - if (!outFile.getParentFile().exists()) { + if (!outFile.getParentFile().exists()) + { outFile.getParentFile().mkdirs(); } FileOutputStream out = null; - try { + try + { out = new FileOutputStream(outFile); } - catch (FileNotFoundException e) { + catch (FileNotFoundException e) + { Debug.trace("Cannot create logfile!"); Debug.error(e); } - if (out != null) { + if (out != null) + { extLogWriter = new BufferedWriter(new OutputStreamWriter(out)); } } - try { + try + { String condition = installdata.getVariable("UNINSTALLER_CONDITION"); - if (condition != null) { - if (!RulesEngine.getCondition(condition).isTrue()) { + if (condition != null) + { + if (!RulesEngine.getCondition(condition).isTrue()) + { // condition for creating the uninstaller is not fulfilled. return; } @@ -895,9 +1065,7 @@ List files = udata.getUninstalableFilesList(); ZipOutputStream outJar = installdata.uninstallOutJar; - if (outJar == null) { - return; - } + if (outJar == null) { return; } // We write the files log outJar.putNextEntry(new ZipEntry("install.log")); @@ -905,12 +1073,15 @@ logWriter.write(installdata.getInstallPath()); logWriter.newLine(); Iterator iter = files.iterator(); - if (extLogWriter != null) { // Write intern (in uninstaller.jar) and extern log file. - while (iter.hasNext()) { + if (extLogWriter != null) + { // Write intern (in uninstaller.jar) and extern log file. + while (iter.hasNext()) + { String txt = (String) iter.next(); logWriter.write(txt); extLogWriter.write(txt); - if (iter.hasNext()) { + if (iter.hasNext()) + { logWriter.newLine(); extLogWriter.newLine(); } @@ -918,10 +1089,14 @@ logWriter.flush(); extLogWriter.flush(); extLogWriter.close(); - } else { - while (iter.hasNext()) { + } + else + { + while (iter.hasNext()) + { logWriter.write((String) iter.next()); - if (iter.hasNext()) { + if (iter.hasNext()) + { logWriter.newLine(); } } @@ -943,7 +1118,8 @@ ObjectOutputStream execStream = new ObjectOutputStream(outJar); iter = udata.getExecutablesList().iterator(); execStream.writeInt(udata.getExecutablesList().size()); - while (iter.hasNext()) { + while (iter.hasNext()) + { ExecutableFile file = (ExecutableFile) iter.next(); execStream.writeObject(file); } @@ -955,15 +1131,19 @@ // with custom uninstall data. Therefore log it to Debug, // but do not throw. Map additionalData = udata.getAdditionalData(); - if (additionalData != null && !additionalData.isEmpty()) { + if (additionalData != null && !additionalData.isEmpty()) + { Iterator keys = additionalData.keySet().iterator(); HashSet exist = new HashSet(); - while (keys != null && keys.hasNext()) { + while (keys != null && keys.hasNext()) + { String key = keys.next(); Object contents = additionalData.get(key); - if ("__uninstallLibs__".equals(key)) { + if ("__uninstallLibs__".equals(key)) + { Iterator nativeLibIter = ((List) contents).iterator(); - while (nativeLibIter != null && nativeLibIter.hasNext()) { + while (nativeLibIter != null && nativeLibIter.hasNext()) + { String nativeLibName = (String) ((List) nativeLibIter.next()).get(0); byte[] buffer = new byte[5120]; long bytesCopied = 0; @@ -971,13 +1151,16 @@ outJar.putNextEntry(new ZipEntry("native/" + nativeLibName)); InputStream in = getClass().getResourceAsStream( "/native/" + nativeLibName); - while ((bytesInBuffer = in.read(buffer)) != -1) { + while ((bytesInBuffer = in.read(buffer)) != -1) + { outJar.write(buffer, 0, bytesInBuffer); bytesCopied += bytesInBuffer; } outJar.closeEntry(); } - } else if ("uninstallerListeners".equals(key) || "uninstallerJars".equals(key)) { // It is a ArrayList of ArrayLists which contains the + } + else if ("uninstallerListeners".equals(key) || "uninstallerJars".equals(key)) + { // It is a ArrayList of ArrayLists which contains the // full // package paths of all needed class files. // First we create a new ArrayList which contains only @@ -987,7 +1170,8 @@ // Secound put the class into uninstaller.jar Iterator listenerIter = ((List) contents).iterator(); - while (listenerIter.hasNext()) { + while (listenerIter.hasNext()) + { byte[] buffer = new byte[5120]; long bytesCopied = 0; int bytesInBuffer; @@ -995,20 +1179,25 @@ // First element of the list contains the listener // class path; // remind it for later. - if (customData.listenerName != null) { + if (customData.listenerName != null) + { subContents.add(customData.listenerName); } Iterator liClaIter = customData.contents.iterator(); - while (liClaIter.hasNext()) { + while (liClaIter.hasNext()) + { String contentPath = liClaIter.next(); - if (exist.contains(contentPath)) { + if (exist.contains(contentPath)) + { continue; } exist.add(contentPath); - try { + try + { outJar.putNextEntry(new ZipEntry(contentPath)); } - catch (ZipException ze) { // Ignore, or ignore not ?? May be it is a + catch (ZipException ze) + { // Ignore, or ignore not ?? May be it is a // exception because // a doubled entry was tried, then we should // ignore ... @@ -1017,12 +1206,16 @@ continue; } InputStream in = getClass().getResourceAsStream("/" + contentPath); - if (in != null) { - while ((bytesInBuffer = in.read(buffer)) != -1) { + if (in != null) + { + while ((bytesInBuffer = in.read(buffer)) != -1) + { outJar.write(buffer, 0, bytesInBuffer); bytesCopied += bytesInBuffer; } - } else { + } + else + { Debug.trace("custom data not found: " + contentPath); } outJar.closeEntry(); @@ -1037,11 +1230,16 @@ objOut.flush(); outJar.closeEntry(); - } else { + } + else + { outJar.putNextEntry(new ZipEntry(key)); - if (contents instanceof ByteArrayOutputStream) { + if (contents instanceof ByteArrayOutputStream) + { ((ByteArrayOutputStream) contents).writeTo(outJar); - } else { + } + else + { ObjectOutputStream objOut = new ObjectOutputStream(outJar); objOut.writeObject(contents); objOut.flush(); @@ -1057,7 +1255,8 @@ Iterator unInstallIter = unInstallScripts.iterator(); ObjectOutputStream rootStream; int idx = 0; - while (unInstallIter.hasNext()) { + while (unInstallIter.hasNext()) + { outJar.putNextEntry(new ZipEntry(UninstallData.ROOTSCRIPT + Integer.toString(idx))); rootStream = new ObjectOutputStream(outJar); String unInstallScript = (String) unInstallIter.next(); @@ -1071,48 +1270,51 @@ outJar.flush(); outJar.close(); } - catch (Exception err) { + catch (Exception err) + { err.printStackTrace(); } } /** * Gets the stream to a resource. - * + * * @param res The resource id. - * + * * @return The resource value, null if not found - * + * * @throws Exception */ - public InputStream getResource(String res) throws Exception { + public InputStream getResource(String res) throws Exception + { InputStream result; String basePath = ""; ResourceManager rm = null; - try { + try + { rm = ResourceManager.getInstance(); basePath = rm.resourceBasePath; } - catch (Exception e) { + catch (Exception e) + { e.printStackTrace(); } result = this.getClass().getResourceAsStream(basePath + res); - if (result == null) { - throw new ResourceNotFoundException("Warning: Resource not found: " - + res); - } + if (result == null) { throw new ResourceNotFoundException("Warning: Resource not found: " + + res); } return result; } /** * Centers a window on screen. - * + * * @param frame The window tp center. */ - public void centerFrame(Window frame) { + public void centerFrame(Window frame) + { Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint(); Dimension frameSize = frame.getSize(); frame.setLocation(center.x - frameSize.width / 2, center.y - frameSize.height / 2 - 10); @@ -1120,26 +1322,28 @@ /** * Returns the panels container size. - * + * * @return The panels container size. */ - public Dimension getPanelsContainerSize() { + public Dimension getPanelsContainerSize() + { return panelsContainer.getSize(); } /** * Sets the parameters of a GridBagConstraints object. - * + * * @param gbc The constraints object. - * @param gx The x coordinates. - * @param gy The y coordinates. - * @param gw The width. - * @param wx The x wheight. - * @param wy The y wheight. - * @param gh Description of the Parameter + * @param gx The x coordinates. + * @param gy The y coordinates. + * @param gw The width. + * @param wx The x wheight. + * @param wy The y wheight. + * @param gh Description of the Parameter */ public void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, double wx, - double wy) { + double wy) + { gbc.gridx = gx; gbc.gridy = gy; gbc.gridwidth = gw; @@ -1151,11 +1355,13 @@ /** * Makes a clean closing. */ - public void exit() { + public void exit() + { // FIXME !!! Reboot handling if (installdata.canClose || ((!nextButton.isVisible() || !nextButton.isEnabled()) && (!prevButton - .isVisible() || !prevButton.isEnabled()))) { + .isVisible() || !prevButton.isEnabled()))) + { // this does nothing if the uninstaller was not included writeUninstallData(); @@ -1165,33 +1371,40 @@ String message, title; VariableSubstitutor vs = new VariableSubstitutor(installdata.getVariables()); System.out.println("[ There are file operations pending after reboot ]"); - switch( installdata.info.getRebootAction()) { - case Info.REBOOT_ACTION_ALWAYS: + switch (installdata.info.getRebootAction()) + { + case Info.REBOOT_ACTION_ALWAYS: + reboot = true; + break; + case Info.REBOOT_ACTION_ASK: + message = vs.substitute(langpack.getString("installer.reboot.ask.message"), + null); + title = vs.substitute(langpack.getString("installer.reboot.ask.title"), null); + int res = JOptionPane.showConfirmDialog(this, message, title, + JOptionPane.YES_NO_OPTION); + if (res == JOptionPane.YES_OPTION) + { reboot = true; - break; - case Info.REBOOT_ACTION_ASK: - message = vs.substitute(langpack.getString("installer.reboot.ask.message"), null); - title = vs.substitute(langpack.getString("installer.reboot.ask.title"), null); - int res = JOptionPane - .showConfirmDialog(this, message, title, JOptionPane.YES_NO_OPTION); - if (res == JOptionPane.YES_OPTION) { - reboot = true; - } - break; - case Info.REBOOT_ACTION_NOTICE: - message = vs.substitute(langpack.getString("installer.reboot.notice.message"), null); - title = vs.substitute(langpack.getString("installer.reboot.notice.title"), null); - JOptionPane.showConfirmDialog(this, message, title, JOptionPane.OK_OPTION); - break; + } + break; + case Info.REBOOT_ACTION_NOTICE: + message = vs.substitute(langpack.getString("installer.reboot.notice.message"), + null); + title = vs + .substitute(langpack.getString("installer.reboot.notice.title"), null); + JOptionPane.showConfirmDialog(this, message, title, JOptionPane.OK_OPTION); + break; } - if (reboot) - System.out.println("[ Rebooting now automatically ]"); + if (reboot) System.out.println("[ Rebooting now automatically ]"); } Housekeeper.getInstance().shutDown(0, reboot); - } else { + } + else + { // The installation is not over - if (Unpacker.isDiscardInterrupt() && interruptCount < MAX_INTERRUPT) { // But we should not interrupt. + if (Unpacker.isDiscardInterrupt() && interruptCount < MAX_INTERRUPT) + { // But we should not interrupt. interruptCount++; return; } @@ -1201,11 +1414,13 @@ String message = langpack.getString(mkey); String title = langpack.getString(tkey); // message equal to key -> no alternate message defined. - if (message.indexOf(mkey) > -1) { + if (message.indexOf(mkey) > -1) + { message = langpack.getString("installer.quit.message"); } // title equal to key -> no alternate title defined. - if (title.indexOf(tkey) > -1) { + if (title.indexOf(tkey) > -1) + { title = langpack.getString("installer.quit.title"); } // Now replace variables in message or title. @@ -1214,7 +1429,8 @@ title = vs.substitute(title, null); int res = JOptionPane .showConfirmDialog(this, message, title, JOptionPane.YES_NO_OPTION); - if (res == JOptionPane.YES_OPTION) { + if (res == JOptionPane.YES_OPTION) + { wipeAborted(); Housekeeper.getInstance().shutDown(0); } @@ -1224,16 +1440,16 @@ /** * Wipes the written files when you abort the installation. */ - protected void wipeAborted() { + protected void wipeAborted() + { // We set interrupt to all running Unpacker and wait 40 sec for maximum. // If interrupt is discarded (return value false), return immediately: - if (!Unpacker.interruptAll(40000)) { - return; - } + if (!Unpacker.interruptAll(40000)) { return; } // Wipe the files that had been installed UninstallData u = UninstallData.getInstance(); - for (String p : u.getInstalledFilesList()) { + for (String p : u.getInstalledFilesList()) + { File f = new File(p); f.delete(); } @@ -1241,10 +1457,11 @@ /** * Launches the installation. - * + * * @param listener The installation listener. */ - public void install(AbstractUIProgressHandler listener) { + public void install(AbstractUIProgressHandler listener) + { IUnpacker unpacker = UnpackerFactory.getUnpacker(this.installdata.info .getUnpackerClassName(), installdata, listener); unpacker.setRules(this.rules); @@ -1254,17 +1471,19 @@ /** * Writes an XML tree. - * + * * @param root The XML tree to write out. - * @param out The stream to write on. - * + * @param out The stream to write on. + * * @throws Exception Description of the Exception */ - public void writeXMLTree(IXMLElement root, OutputStream out) throws Exception { + public void writeXMLTree(IXMLElement root, OutputStream out) throws Exception + { IXMLWriter writer = new XMLWriter(out); // fix bug# 4551 // write.write(root); - for (int i = 0; i < installdata.panels.size(); i++) { + for (int i = 0; i < installdata.panels.size(); i++) + { IzPanel panel = installdata.panels.get(i); panel.makeXMLData(installdata.xmlData.getChildAtIndex(i)); } @@ -1274,12 +1493,14 @@ /** * Changes the quit button text. If text is null, the default quit text is used. - * + * * @param text text to be used for changes */ - public void setQuitButtonText(String text) { + public void setQuitButtonText(String text) + { String text1 = text; - if (text1 == null) { + if (text1 == null) + { text1 = langpack.getString("installer.quit"); } quitButton.setText(text1); @@ -1287,13 +1508,15 @@ /** * Sets a new icon into the quit button if icons should be used, else nothing will be done. - * + * * @param iconName name of the icon to be used */ - public void setQuitButtonIcon(String iconName) { + public void setQuitButtonIcon(String iconName) + { String useButtonIcons = installdata.guiPrefs.modifier.get("useButtonIcons"); - if (useButtonIcons == null || "yes".equalsIgnoreCase(useButtonIcons)) { + if (useButtonIcons == null || "yes".equalsIgnoreCase(useButtonIcons)) + { quitButton.setIcon(icons.getImageIcon(iconName)); } } @@ -1309,18 +1532,19 @@ /** * Blocks GUI interaction. */ - public void blockGUI() { + public void blockGUI() + { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); getGlassPane().setVisible(true); getGlassPane().setEnabled(true); // No traversal handling before VM version 1.4 - if (JAVA_SPECIFICATION_VERSION < 1.35) { - return; - } - if (usualFTP == null) { + if (JAVA_SPECIFICATION_VERSION < 1.35) { return; } + if (usualFTP == null) + { usualFTP = getFocusTraversalPolicy(); } - if (blockFTP == null) { + if (blockFTP == null) + { blockFTP = new BlockFocusTraversalPolicy(); } setFocusTraversalPolicy((java.awt.FocusTraversalPolicy) blockFTP); @@ -1332,14 +1556,13 @@ /** * Releases GUI interaction. */ - public void releaseGUI() { + public void releaseGUI() + { getGlassPane().setEnabled(false); getGlassPane().setVisible(false); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); // No traversal handling before VM version 1.4 - if (JAVA_SPECIFICATION_VERSION < 1.35) { - return; - } + if (JAVA_SPECIFICATION_VERSION < 1.35) { return; } setFocusTraversalPolicy((java.awt.FocusTraversalPolicy) usualFTP); callGUIListener(GUIListener.GUI_RELEASED); } @@ -1347,45 +1570,53 @@ /** * Locks the 'previous' button. */ - public void lockPrevButton() { + public void lockPrevButton() + { prevButton.setEnabled(false); } /** * Locks the 'next' button. */ - public void lockNextButton() { + public void lockNextButton() + { nextButton.setEnabled(false); } /** * Unlocks the 'previous' button. */ - public void unlockPrevButton() { + public void unlockPrevButton() + { prevButton.setEnabled(true); } /** * Unlocks the 'next' button. */ - public void unlockNextButton() { + public void unlockNextButton() + { unlockNextButton(true); } /** * Unlocks the 'next' button. - * + * * @param requestFocus if true 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 List getGuiListener() { + public List getGuiListener() + { return guiListener; } /** * Add a listener to the listener list. - * + * * @param listener to be added as gui creation listener */ - public void addGuiListener(GUIListener listener) { + public void addGuiListener(GUIListener listener) + { guiListener.add(listener); } /** * Creates heading labels. - * + * * @param headingLines the number of lines of heading labels - * @param back background color (currently not used) + * @param back background color (currently not used) */ - private void createHeadingLabels(int headingLines, Color back) { + private void createHeadingLabels(int headingLines, Color back) + { // headingLabels are an array which contains the labels for header (0), // description lines and the icon (last). headingLabels = new JLabel[headingLines + 1]; @@ -1712,29 +1987,37 @@ // Updated by Daniel Azarov, Exadel Inc. // start Color foreground = null; - if (installdata.guiPrefs.modifier.containsKey("headingForegroundColor")) { + if (installdata.guiPrefs.modifier.containsKey("headingForegroundColor")) + { foreground = Color.decode(installdata.guiPrefs.modifier.get("headingForegroundColor")); headingLabels[0].setForeground(foreground); } // end - if (installdata.guiPrefs.modifier.containsKey("headingFontSize")) { + if (installdata.guiPrefs.modifier.containsKey("headingFontSize")) + { float fontSize = Float.parseFloat(installdata.guiPrefs.modifier.get("headingFontSize")); - if (fontSize > 0.0 && fontSize <= 5.0) { + if (fontSize > 0.0 && fontSize <= 5.0) + { float currentSize = headingLabels[0].getFont().getSize2D(); headingLabels[0].setFont(headingLabels[0].getFont().deriveFont( currentSize * fontSize)); } } - if (imageLeft) { + if (imageLeft) + { headingLabels[0].setAlignmentX(Component.RIGHT_ALIGNMENT); } - for (int i = 1; i < headingLines; ++i) { + for (int i = 1; i < headingLines; ++i) + { headingLabels[i] = new JLabel(); // Minor headings should be a little bit more to the right. - if (imageLeft) { + if (imageLeft) + { headingLabels[i].setAlignmentX(Component.RIGHT_ALIGNMENT); - } else { + } + else + { headingLabels[i].setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 8)); } } @@ -1743,63 +2026,78 @@ /** * Creates heading panel counter. - * - * @param back background color - * @param navPanel navi JPanel + * + * @param back background color + * @param navPanel navi JPanel * @param leftHeadingPanel left heading JPanel */ - private void createHeadingCounter(Color back, JPanel navPanel, JPanel leftHeadingPanel) { + private void createHeadingCounter(Color back, JPanel navPanel, JPanel leftHeadingPanel) + { int i; String counterPos = "inHeading"; - if (installdata.guiPrefs.modifier.containsKey("headingPanelCounterPos")) { + if (installdata.guiPrefs.modifier.containsKey("headingPanelCounterPos")) + { counterPos = installdata.guiPrefs.modifier.get("headingPanelCounterPos"); } // Do not create counter if it should be in the heading, but no heading should be used. - if (leftHeadingPanel == null && "inHeading".equalsIgnoreCase(counterPos)) { - return; - } - if (installdata.guiPrefs.modifier.containsKey("headingPanelCounter")) { + if (leftHeadingPanel == null && "inHeading".equalsIgnoreCase(counterPos)) { return; } + if (installdata.guiPrefs.modifier.containsKey("headingPanelCounter")) + { headingCounterComponent = null; if ("progressbar".equalsIgnoreCase(installdata.guiPrefs.modifier - .get("headingPanelCounter"))) { + .get("headingPanelCounter"))) + { JProgressBar headingProgressBar = new JProgressBar(); headingProgressBar.setStringPainted(true); headingProgressBar.setString(""); headingProgressBar.setValue(0); headingCounterComponent = headingProgressBar; - if (imageLeft) { + if (imageLeft) + { headingCounterComponent.setAlignmentX(Component.RIGHT_ALIGNMENT); } - } else if ("text".equalsIgnoreCase(installdata.guiPrefs.modifier - .get("headingPanelCounter"))) { + } + else if ("text".equalsIgnoreCase(installdata.guiPrefs.modifier + .get("headingPanelCounter"))) + { JLabel headingCountPanels = new JLabel(" "); headingCounterComponent = headingCountPanels; - if (imageLeft) { + if (imageLeft) + { headingCounterComponent.setAlignmentX(Component.RIGHT_ALIGNMENT); - } else { + } + else + { headingCounterComponent.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0)); } // Updated by Daniel Azarov, Exadel Inc. // start Color foreground = null; - if (installdata.guiPrefs.modifier.containsKey("headingForegroundColor")) { + if (installdata.guiPrefs.modifier.containsKey("headingForegroundColor")) + { foreground = Color.decode(installdata.guiPrefs.modifier .get("headingForegroundColor")); headingCountPanels.setForeground(foreground); } // end } - if ("inHeading".equals(counterPos)) { + if ("inHeading".equals(counterPos)) + { leftHeadingPanel.add(headingCounterComponent); - } else if ("inNavigationPanel".equals(counterPos)) { + } + else if ("inNavigationPanel".equals(counterPos)) + { Component[] comps = navPanel.getComponents(); - for (i = 0; i < comps.length; ++i) { - if (comps[i].equals(prevButton)) { + for (i = 0; i < comps.length; ++i) + { + if (comps[i].equals(prevButton)) + { break; } } - if (i <= comps.length) { + if (i <= comps.length) + { navPanel.add(Box.createHorizontalGlue(), i); navPanel.add(headingCounterComponent, i); } @@ -1810,18 +2108,21 @@ /** * Creates heading icon. - * + * * @param back the color of background around image. - * + * * @return a panel with heading image. */ - private JPanel createHeadingIcon(Color back) { + private JPanel createHeadingIcon(Color back) + { // the icon ImageIcon icon = null; - try { + try + { icon = loadIcon(HEADING_ICON_RESOURCE, 0, true); } - catch (Exception e) { + catch (Exception e) + { // ignore } JPanel imgPanel = new JPanel(); @@ -1830,7 +2131,8 @@ // Updated by Daniel Azarov, Exadel Inc. // start int borderSize = 8; - if (installdata.guiPrefs.modifier.containsKey("headingImageBorderSize")) { + if (installdata.guiPrefs.modifier.containsKey("headingImageBorderSize")) + { borderSize = Integer.parseInt(installdata.guiPrefs.modifier .get("headingImageBorderSize")); } @@ -1838,13 +2140,17 @@ borderSize)); // end - if (back != null) { + if (back != null) + { imgPanel.setBackground(back); } JLabel iconLab = new JLabel(icon); - if (imageLeft) { + if (imageLeft) + { imgPanel.add(iconLab, BorderLayout.WEST); - } else { + } + else + { imgPanel.add(iconLab, BorderLayout.EAST); } headingLabels[headingLabels.length - 1] = iconLab; @@ -1854,32 +2160,37 @@ /** * Creates a Heading in given Panel. - * + * * @param navPanel a panel */ - private void createHeading(JPanel navPanel) { + private void createHeading(JPanel navPanel) + { headingPanel = null; int headingLines = 1; // The number of lines can be determined in the config xml file. // The first is the header, additonals are descriptions for the header. - if (installdata.guiPrefs.modifier.containsKey("headingLineCount")) { + if (installdata.guiPrefs.modifier.containsKey("headingLineCount")) + { headingLines = Integer.parseInt(installdata.guiPrefs.modifier.get("headingLineCount")); } Color back = null; int i = 0; // It is possible to determine the used background color of the heading panel. - if (installdata.guiPrefs.modifier.containsKey("headingBackgroundColor")) { + if (installdata.guiPrefs.modifier.containsKey("headingBackgroundColor")) + { back = Color.decode(installdata.guiPrefs.modifier.get("headingBackgroundColor")); } // Try to create counter if no heading should be used. - if (!isHeading(null)) { + if (!isHeading(null)) + { createHeadingCounter(back, navPanel, null); return; } // See if we should switch the header image to the left side if (installdata.guiPrefs.modifier.containsKey("headingImageOnLeft") && (installdata.guiPrefs.modifier.get("headingImageOnLeft").equalsIgnoreCase("yes") || installdata.guiPrefs.modifier - .get("headingImageOnLeft").equalsIgnoreCase("true"))) { + .get("headingImageOnLeft").equalsIgnoreCase("true"))) + { imageLeft = true; } // We create the text labels and the needed panels. From inner to outer. @@ -1887,14 +2198,17 @@ createHeadingLabels(headingLines, back); // Panel which contains the labels JPanel leftHeadingPanel = new JPanel(); - if (back != null) { + if (back != null) + { leftHeadingPanel.setBackground(back); } leftHeadingPanel.setLayout(new BoxLayout(leftHeadingPanel, BoxLayout.Y_AXIS)); - if (imageLeft) { + if (imageLeft) + { leftHeadingPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8)); } - for (i = 0; i < headingLines; ++i) { + for (i = 0; i < headingLines; ++i) + { leftHeadingPanel.add(headingLabels[i]); } @@ -1907,16 +2221,20 @@ // The panel for text and icon. JPanel northPanel = new JPanel(); - if (back != null) { + if (back != null) + { northPanel.setBackground(back); } northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.X_AXIS)); northPanel.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); - if (imageLeft) { + if (imageLeft) + { northPanel.add(imgPanel); northPanel.add(Box.createHorizontalGlue()); northPanel.add(leftHeadingPanel); - } else { + } + else + { northPanel.add(leftHeadingPanel); northPanel.add(Box.createHorizontalGlue()); northPanel.add(imgPanel); @@ -1936,50 +2254,53 @@ * IzPanel. This heading will be placed if the gui preferences contains an modifier with the key * "useHeadingPanel" and the value "yes" and there is a message with the key "<class * name>.headline". - * + * * @param caller the IzPanel for which heading should be resolved - * + * * @return whether an heading panel will be used or not */ - public boolean isHeading(IzPanel caller) { + public boolean isHeading(IzPanel caller) + { if (!installdata.guiPrefs.modifier.containsKey("useHeadingPanel") - || !(installdata.guiPrefs.modifier.get("useHeadingPanel")).equalsIgnoreCase("yes")) { - return (false); - } - if (caller == null) { - return (true); - } + || !(installdata.guiPrefs.modifier.get("useHeadingPanel")).equalsIgnoreCase("yes")) { return (false); } + if (caller == null) { return (true); } return (caller.getI18nStringForClass("headline", null) != null); } - private void performHeading(IzPanel panel) { + private void performHeading(IzPanel panel) + { int i; int headingLines = 1; - if (installdata.guiPrefs.modifier.containsKey("headingLineCount")) { + if (installdata.guiPrefs.modifier.containsKey("headingLineCount")) + { headingLines = Integer.parseInt(installdata.guiPrefs.modifier.get("headingLineCount")); } - if (headingLabels == null) { - return; - } + if (headingLabels == null) { return; } String headline = panel.getI18nStringForClass("headline"); - if (headline == null) { + if (headline == null) + { headingPanel.setVisible(false); return; } - for (i = 0; i <= headingLines; ++i) { - if (headingLabels[i] != null) { + for (i = 0; i <= headingLines; ++i) + { + if (headingLabels[i] != null) + { headingLabels[i].setVisible(false); } } String info; - for (i = 0; i < headingLines - 1; ++i) { + for (i = 0; i < headingLines - 1; ++i) + { info = panel.getI18nStringForClass("headinfo" + Integer.toString(i)); - if (info == null) { + if (info == null) + { info = " "; } - if (info.endsWith(":")) { + if (info.endsWith(":")) + { info = info.substring(0, info.length() - 1) + "."; } headingLabels[i + 1].setText(info); @@ -1989,7 +2310,8 @@ headingLabels[0].setText(headline); headingLabels[0].setVisible(true); int curPanelNo = visiblePanelMapping.get(installdata.curPanelNumber); - if (headingLabels[headingLines] != null) { + if (headingLabels[headingLines] != null) + { loadAndShowImage(headingLabels[headingLines], HEADING_ICON_RESOURCE, curPanelNo); headingLabels[headingLines].setVisible(true); } @@ -1997,8 +2319,10 @@ } - private void performHeadingCounter(IzPanel panel) { - if (headingCounterComponent != null) { + private void performHeadingCounter(IzPanel panel) + { + if (headingCounterComponent != null) + { int curPanelNo = visiblePanelMapping.get(installdata.curPanelNumber); int visPanelsCount = visiblePanelMapping.get((visiblePanelMapping .get(installdata.panels.size())).intValue()); @@ -2006,13 +2330,16 @@ StringBuffer buf = new StringBuffer(); buf.append(langpack.getString("installer.step")).append(" ").append(curPanelNo + 1) .append(" ").append(langpack.getString("installer.of")).append(" ").append( - visPanelsCount + 1); - if (headingCounterComponent instanceof JProgressBar) { + visPanelsCount + 1); + if (headingCounterComponent instanceof JProgressBar) + { JProgressBar headingProgressBar = (JProgressBar) headingCounterComponent; headingProgressBar.setMaximum(visPanelsCount + 1); headingProgressBar.setValue(curPanelNo + 1); headingProgressBar.setString(buf.toString()); - } else { + } + else + { ((JLabel) headingCounterComponent).setText(buf.toString()); } } @@ -2021,23 +2348,26 @@ /** * @return the rules */ - public RulesEngine getRules() { + public RulesEngine getRules() + { return this.rules; } /** * @param rules the rules to set */ - public void setRules(RulesEngine rules) { + public void setRules(RulesEngine rules) + { this.rules = rules; } /** * Shows or hides Help button depending on show 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/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 Resourcename
*
* Example: - *

  • InfoPanel.info - for default value
  • - *
  • InfoPanel.info_deu - for german value
  • - *
  • InfoPanel.info_eng - for english value
  • - *
    + *
  • InfoPanel.info - for default value
  • + *
  • InfoPanel.info_deu - for german value
  • + *
  • InfoPanel.info_eng - for english value

  • *

    * This class is almost a singleton. It is created once using create 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; + } }