protected class ApproveAction extends AbstractAction {
public void actionPerformed(ActionEvent e) {
SPFileChooser chooser = getSPFileChooser();
String filename = getFileName();
FileSystemView fs = chooser.getFileSystemView();
SPFile dir = (SPFile) chooser.getCurrentDirectory();
if(filename == null || filename.equals("")) {
// no file selected, multiple selection off,
// therefore cancel the approve action
return;
}
if(filename != null) {
// Remove whitespace from beginning and end of filename
filename = filename.trim();
}
if(filename != null && !filename.equals("")) {
FileFilter fFilter = chooser.getFileFilter();
if ( (chooser.getDialogType() == JFileChooser.SAVE_DIALOG)
&& (chooser.isFilterNaming())
&& (fFilter instanceof SPFileFilter) ) {
SPFileFilter filter = (SPFileFilter) fFilter;
int dotIndex = filename.indexOf(".");
if (dotIndex < 0) {
filename = filename.concat(
(String) filter.getFileExtension(0));
}
}
// check for directory change action
SPFile selectedFile = (SPFile) fs.createFileObject(
chooser.getCurrentDirectory(), filename);
boolean isDir = selectedFile.isDirectory();
boolean isDirSelEnabled = chooser.isDirectorySelectionEnabled();
boolean isFileSelEnabled = chooser.isFileSelectionEnabled();