[Ejtools-cvs] libraries/common/src/main/org/ejtools/util FileTools.java,1.1,1.2
Brought to you by:
letiemble
From: <let...@us...> - 2003-12-26 00:17:32
|
Update of /cvsroot/ejtools/libraries/common/src/main/org/ejtools/util In directory sc8-pr-cvs1:/tmp/cvs-serv23005/libraries/common/src/main/org/ejtools/util Modified Files: FileTools.java Log Message: Add extension completion for unqualified files. Index: FileTools.java =================================================================== RCS file: /cvsroot/ejtools/libraries/common/src/main/org/ejtools/util/FileTools.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FileTools.java 13 Dec 2003 21:27:49 -0000 1.1 --- FileTools.java 26 Dec 2003 00:17:29 -0000 1.2 *************** *** 43,47 **** * @see javax.swing.JFileChooser#SAVE_DIALOG */ ! public static File selectFile(String title, String approveText, int type, FileFilter filter) { File selectedFile = null; --- 43,47 ---- * @see javax.swing.JFileChooser#SAVE_DIALOG */ ! public static File selectFile(String title, String approveText, int type, SimpleFileFilter filter) { File selectedFile = null; *************** *** 65,74 **** } ! if ((selectedFile != null) && (type == JFileChooser.SAVE_DIALOG) && (selectedFile.exists())) { ! int ret = JOptionPane.showConfirmDialog(null, MessageFormat.format(resources.getString("file.dialog.overwrite.text"), new Object[]{selectedFile.getName()})); ! if (ret != JOptionPane.OK_OPTION) { ! selectedFile = null; } } --- 65,84 ---- } ! if (selectedFile != null) { ! // Check if the extension is correct ! if (!filter.accept(selectedFile)) { ! selectedFile = new File(selectedFile.getName() + filter.getExtension()); ! } ! ! // If it is a save action, check if file exists ! if ((type == JFileChooser.SAVE_DIALOG) && (selectedFile.exists())) ! { ! int ret = JOptionPane.showConfirmDialog(null, MessageFormat.format(resources.getString("file.dialog.overwrite.text"), new Object[]{selectedFile.getName()})); ! if (ret != JOptionPane.OK_OPTION) ! { ! selectedFile = null; ! } } } *************** *** 123,126 **** --- 133,147 ---- { return this.description; + } + + + /** + * Gets the extension attribute of the SimpleFileFilter object + * + * @return The extension value + */ + public String getExtension() + { + return this.extension; } } |