/** * Creates the file chooser. * * @return the initialized file chooser. */ protected JFileChooser createFileChooser() { final JFileChooser fc = new JFileChooser(); fc.addChoosableFileFilter( new ExtensionFileFilter(getFileDescription(), getFileExtension()) ); fc.setMultiSelectionEnabled(false); fc.setCurrentDirectory(getCurrentDirectory()); return fc; }
/** * Selects a file to use as target for the operation. * * @param selectedFile the selected file. * @param dialogType the dialog type. * @param appendExtension true, if the file extension should be added if * necessary, false if the unmodified filename should be used. * * @return the selected and approved file or null, if the user canceled * the operation */ protected File performSelectFile(final File selectedFile, final int dialogType, final boolean appendExtension) { if (this.fileChooser == null) { this.fileChooser = createFileChooser(); } this.fileChooser.setSelectedFile(selectedFile); this.fileChooser.setDialogType(dialogType); final int option = this.fileChooser.showDialog(this.parent, null); if (option == JFileChooser.APPROVE_OPTION) { final File selFile = this.fileChooser.getSelectedFile(); String selFileName = selFile.getAbsolutePath(); if (StringUtils.endsWithIgnoreCase(selFileName, getFileExtension()) == false) { selFileName = selFileName + getFileExtension(); } return new File(selFileName); } return null; }
/** * Selects a file to use as target for the operation. * * @param selectedFile the selected file. * @param dialogType the dialog type. * @param appendExtension true, if the file extension should be added if * necessary, false if the unmodified filename should be used. * * @return the selected and approved file or null, if the user canceled * the operation */ protected File performSelectFile(final File selectedFile, final int dialogType, final boolean appendExtension) { if (this.fileChooser == null) { this.fileChooser = createFileChooser(); } this.fileChooser.setSelectedFile(selectedFile); this.fileChooser.setDialogType(dialogType); final int option = this.fileChooser.showDialog(this.parent, null); if (option == JFileChooser.APPROVE_OPTION) { final File selFile = this.fileChooser.getSelectedFile(); String selFileName = selFile.getAbsolutePath(); if (StringUtils.endsWithIgnoreCase(selFileName, getFileExtension()) == false) { selFileName = selFileName + getFileExtension(); } return new File(selFileName); } return null; }
/** * Creates the file chooser. * * @return the initialized file chooser. */ protected JFileChooser createFileChooser() { final JFileChooser fc = new JFileChooser(); fc.addChoosableFileFilter( new ExtensionFileFilter(getFileDescription(), getFileExtension()) ); fc.setMultiSelectionEnabled(false); fc.setCurrentDirectory(getCurrentDirectory()); return fc; }
/** * Selects a file to use as target for the operation. * * @param selectedFile the selected file. * @param dialogType the dialog type. * @param appendExtension true, if the file extension should be added if * necessary, false if the unmodified filename should be used. * * @return the selected and approved file or null, if the user canceled * the operation */ protected File performSelectFile(final File selectedFile, final int dialogType, final boolean appendExtension) { if (this.fileChooser == null) { this.fileChooser = createFileChooser(); } this.fileChooser.setSelectedFile(selectedFile); this.fileChooser.setDialogType(dialogType); final int option = this.fileChooser.showDialog(this.parent, null); if (option == JFileChooser.APPROVE_OPTION) { final File selFile = this.fileChooser.getSelectedFile(); String selFileName = selFile.getAbsolutePath(); if (StringUtils.endsWithIgnoreCase(selFileName, getFileExtension()) == false) { selFileName = selFileName + getFileExtension(); } return new File(selFileName); } return null; }
/** * Creates the file chooser. * * @return the initialized file chooser. */ protected JFileChooser createFileChooser() { final JFileChooser fc = new JFileChooser(); fc.addChoosableFileFilter( new ExtensionFileFilter(getFileDescription(), getFileExtension()) ); fc.setMultiSelectionEnabled(false); fc.setCurrentDirectory(getCurrentDirectory()); return fc; }