Index: C:/Documents and Settings/folsom-1/workspace/IzPack.Base/src/lib/com/izforge/izpack/panels/FinishPanel.java =================================================================== --- C:/Documents and Settings/folsom-1/workspace/IzPack.Base/src/lib/com/izforge/izpack/panels/FinishPanel.java (revision 2153) +++ C:/Documents and Settings/folsom-1/workspace/IzPack.Base/src/lib/com/izforge/izpack/panels/FinishPanel.java (working copy) @@ -29,6 +29,7 @@ import javax.swing.JFileChooser; import javax.swing.JOptionPane; +import com.izforge.izpack.gui.AutomatedInstallScriptFilter; import com.izforge.izpack.gui.ButtonFactory; import com.izforge.izpack.gui.IzPanelLayout; import com.izforge.izpack.gui.LabelFactory; @@ -128,7 +129,7 @@ JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(idata.getInstallPath())); fc.setMultiSelectionEnabled(false); - fc.addChoosableFileFilter(fc.getAcceptAllFileFilter()); + fc.addChoosableFileFilter(new AutomatedInstallScriptFilter()); // fc.setCurrentDirectory(new File(".")); // Shows it Index: C:/Documents and Settings/folsom-1/workspace/IzPack.Base/src/lib/com/izforge/izpack/gui/AutomatedInstallScriptFilter.java =================================================================== --- C:/Documents and Settings/folsom-1/workspace/IzPack.Base/src/lib/com/izforge/izpack/gui/AutomatedInstallScriptFilter.java (revision 0) +++ C:/Documents and Settings/folsom-1/workspace/IzPack.Base/src/lib/com/izforge/izpack/gui/AutomatedInstallScriptFilter.java (revision 0) @@ -0,0 +1,93 @@ +package com.izforge.izpack.gui; + +import java.io.File; +import java.io.InputStream; + +import javax.swing.filechooser.FileFilter; + +import com.izforge.izpack.LocaleDatabase; +import com.izforge.izpack.installer.ResourceManager; +import com.izforge.izpack.util.Debug; + +/** + * Allows a file if it is a directory or if it ends with .xml. The description + * is set using the langpack id FinishPanel.automated.dialog.filterdesc + *
+ *
+ * + * Note: + * + * This file could be replaced in java 1.6 by + * javax.swing.filechooser.FileNameExtensionFilter, although loading the value + * from a lang pack would have to use an external reference, so it may be better + * to keep this class since it has the language pack logic encapsulated. + * + * @author J. Chris Folsom + * + */ +public class AutomatedInstallScriptFilter extends FileFilter +{ + /** + * The default description for the file filter if it cannot be loaded from + * the LocaleDatabase. + */ + public static final String DEFAULT_DESCRIPTION = "XML Files"; + + /** + * This key will be used to search the locale database for the description + * to display. If it cannot be found the default value will be used. + */ + public static final String DESCRIPTION_LOCALE_DATABASE_KEY = "FinishPanel.auto.dialog.filterdesc"; + + /* + * (non-Javadoc) + * + * @see java.io.FileFilter#accept(java.io.File) + */ + public boolean accept(File pathname) + { + /* + * Return true only if the file is a directory or ends with ".xml" + */ + return pathname != null + && (pathname.isDirectory() || pathname.getName().endsWith( + ".xml")); + } + + /** + * + */ + public String getDescription() + { + // Load the lang pack using the current locale + ResourceManager resourceManager = ResourceManager.getInstance(); + String locale = resourceManager.getLocale(); + + String description = null; + + try + { + //All of this will be changed to a few lines of code after the locale database refactor. + InputStream in = this.getClass().getResourceAsStream( + "/langpacks/" + locale + ".xml"); + LocaleDatabase langpack = new LocaleDatabase(in); + + description = langpack.getString(DESCRIPTION_LOCALE_DATABASE_KEY); + + } catch (Exception e) + { + /* + * We'll just log the exception if something happens and provide the + * default value. + */ + Debug.log(e); + } + + if (description == null) + { + description = DEFAULT_DESCRIPTION; + } + + return description; + } +} \ No newline at end of file Index: C:/Documents and Settings/folsom-1/workspace/IzPack.Base/bin/langpacks/installer/eng.xml =================================================================== --- C:/Documents and Settings/folsom-1/workspace/IzPack.Base/bin/langpacks/installer/eng.xml (revision 2153) +++ C:/Documents and Settings/folsom-1/workspace/IzPack.Base/bin/langpacks/installer/eng.xml (working copy) @@ -129,6 +129,7 @@ +