}
}
protected File[] getFilesFromDialog(int action) {
String dialogText;
JFileChooser fileChooser;
if (action == Plugin.SAVE) {
dialogText = resources.getStringValue("saveDialogText");
fileChooser = saveFileChooser;
} else if (action == Plugin.EXPORT) {
dialogText = resources.getStringValue("exportDialogText");
fileChooser = exportFileChooser;
} else {
dialogText = resources.getStringValue("openDialogText");
fileChooser = openFileChooser;
}
fileChooser.setCurrentDirectory(getPath());
if ((fileChooser.getAccessory() != null) && (fileChooser.getAccessory() instanceof FileChooserAccessory)){
((FileChooserAccessory)fileChooser.getAccessory()).updateFileChooserAccessory();
}
int result = fileChooser.showDialog(owner, dialogText);
if (result != JFileChooser.APPROVE_OPTION) {
return null;
}
CurrentPathProvider.currentPathProvider.setCurrentPath(fileChooser.getCurrentDirectory());
FileFilter currentFileFilter = fileChooser.getFileFilter();
if (currentFileFilter instanceof AggregateFileFilter) {
currentFileFilter = ((AggregateFileFilter) currentFileFilter).getFilterForFile(getOwner(), fileChooser
.getSelectedFile());
if (currentFileFilter == null) {
return null;
}
}
if (action == Plugin.SAVE) {
currentSaveFileFilter = currentFileFilter;
} else if (action == Plugin.EXPORT) {
currentExportFileFilter = currentFileFilter;
} else {
currentOpenFileFilter = currentFileFilter;
}
File[] ret;
if (fileChooser.isMultiSelectionEnabled()) {
ret = fileChooser.getSelectedFiles();
} else {
ret = new File[1];
String fileName = fileChooser.getSelectedFile().getParent() + File.separator + fileChooser.getSelectedFile().getName();
// Add file extention relarging the current file filter
if ( fileChooser.getFileFilter() instanceof MenuResourceBundle.FileFilter){
String fileFilterExtension = ((MenuResourceBundle.FileFilter)fileChooser.getFileFilter()).getExtension();
if (fileName.indexOf(".") != -1) {
String fileExtention = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
if (!fileExtention.equalsIgnoreCase(fileFilterExtension)){
fileName += "." + fileFilterExtension ;