return true;
}
private void actionSave(final FileChooserType type){
if(type == FileChooserType.SAVE_REQUEST){
Request request = view.getLastRequest();
if(request == null){
JOptionPane.showMessageDialog(view,
"No last request available.",
"No Request",
JOptionPane.ERROR_MESSAGE);
return;
}
Request uiRequest = view.getRequestFromUI();
if(!request.equals(uiRequest)){
if(!doSaveEvenIfUIChanged(DO_SAVE_UI_REQUEST)){
return;
}
}
File f = getSaveFile(FileChooserType.SAVE_REQUEST);
if(f != null){
try{
XMLUtil.writeRequestXML(request, f);
}
catch(IOException ex){
view.showError(Util.getStackTrace(ex));
}
catch(XMLException ex){
view.showError(Util.getStackTrace(ex));
}
}
}
else if(type == FileChooserType.SAVE_RESPONSE){
Response response = view.getLastResponse();
if(response == null){
JOptionPane.showMessageDialog(view,
"No last response available.",
"No Response",
JOptionPane.ERROR_MESSAGE);
return;
}
Response uiResponse = view.getResponseFromUI();
if(!response.equals(uiResponse)){
if(!doSaveEvenIfUIChanged(DO_SAVE_UI_RESPONSE)){
return;
}
}
File f = getSaveFile(FileChooserType.SAVE_RESPONSE);
if(f != null){
try{
XMLUtil.writeResponseXML(response, f);
}
catch(IOException ex){
view.showError(Util.getStackTrace(ex));
}
catch(XMLException ex){
view.showError(Util.getStackTrace(ex));
}
}
}
else if(type == FileChooserType.SAVE_RESPONSE_BODY){
Response response = view.getLastResponse();
if(response == null){
JOptionPane.showMessageDialog(view,
"No last response available.",
"No Response",
JOptionPane.ERROR_MESSAGE);
return;
}
File f = getSaveFile(FileChooserType.SAVE_RESPONSE_BODY);
if(f != null){
PrintWriter pw = null;
try{
pw = new PrintWriter(new FileWriter(f));
pw.print(response.getResponseBody());
}
catch(IOException ex){
view.showError(Util.getStackTrace(ex));
}
finally{
if(pw != null){
pw.close();
}
}
}
}
else if(type == FileChooserType.SAVE_ARCHIVE){
Request request = view.getLastRequest();
Response response = view.getLastResponse();
if(request == null || response == null){
JOptionPane.showMessageDialog(view,
"No last request/response available.",
"No Request/Response",
JOptionPane.ERROR_MESSAGE);
return;
}
Request uiRequest = view.getRequestFromUI();
Response uiResponse = view.getResponseFromUI();
if((!request.equals(uiRequest)) || (!response.equals(uiResponse))){
if(!doSaveEvenIfUIChanged(DO_SAVE_UI_ARCHIVE)){
return;
}