}
// This method is invoked from SU.invokeLater
@Override
public File getSaveFile(final FileChooserType type){
FileChooser jfc = null;
String title = null;
if(type == FileChooserType.SAVE_REQUEST){
jfc = jfc_request;
title = "Save Request";
}
else if(type == FileChooserType.SAVE_RESPONSE){
jfc = jfc_response;
title = "Save Response";
}
else if(type == FileChooserType.SAVE_RESPONSE_BODY){
jfc = jfc_generic;
title = "Save Response Body";
}
else if(type == FileChooserType.SAVE_ARCHIVE){
jfc = jfc_archive;
title = "Save Req-Res Archive";
}
else if(type == FileChooserType.SAVE_HISTORY) {
jfc = jfc_history;
title = "Save History";
}
jfc.setDialogTitle(title);
FileChooserResponse status = jfc.showSaveDialog(frame);
if(status == FileChooserResponse.APPROVE_OPTION){
File f = jfc.getSelectedFile();
if(f == null){
return null;
}
String ext = null;
switch(type){
case SAVE_REQUEST:
ext = FileType.REQUEST_EXT;
break;
case SAVE_RESPONSE:
ext = FileType.RESPONSE_EXT;
break;
case SAVE_ARCHIVE:
ext = FileType.ARCHIVE_EXT;
break;
default:
break;
}
if(ext != null){
String path = f.getAbsolutePath();
path = path.toLowerCase();
// Add our extension only if the selected filter is ours
FileFilter ff = jfc.getFileFilter();
RCFileFilter rcFileFilter = null;
if(ff instanceof RCFileFilter){
rcFileFilter = (RCFileFilter)ff;
}
if((rcFileFilter != null) &&
(rcFileFilter.getFileTypeExt().equals(ext)) &&
!path.endsWith(ext)){
f = new File(f.getAbsolutePath() + ext);
jfc.setSelectedFile(f);
view.setStatusMessage("Adding default extension: " + ext);
}
}
if(f.exists()){
int yesNo = JOptionPane.showConfirmDialog(frame,