forked from phoedos/pmd
Made the report saving process a bit nicer
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2189 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -6,6 +6,7 @@ Fixed bug 781393 - VariableNameDeclaration no longer throws ClassCastExpression
|
||||
Tweaked CPD time display field
|
||||
Made CPD text fields uneditable
|
||||
Added more error checking to CPD GUI input
|
||||
Added "dialog cancelled" check to CPD "Save" function
|
||||
TODO - fix it so tests and rules don't duplicate the xpath expressions
|
||||
|
||||
August 1, 2003 - 1.2.1:
|
||||
|
@ -54,24 +54,23 @@ public class GUI implements CPDListener {
|
||||
FileDialog fdlg = new FileDialog(GUI.this.frame, "Save", FileDialog.SAVE);
|
||||
fdlg.setVisible(true);
|
||||
String selected = fdlg.getDirectory() + System.getProperty("file.separator") + fdlg.getFile();
|
||||
if(selected !=null){
|
||||
if(!new File(selected).canWrite()){
|
||||
try{
|
||||
PrintWriter pw = new PrintWriter(new FileOutputStream(selected));
|
||||
String report = resultsTextArea.getText();
|
||||
pw.print(report);
|
||||
pw.flush();
|
||||
pw.close();
|
||||
}catch(IOException e){
|
||||
error("Couldn't save file"+new File(selected).getAbsolutePath(), e);
|
||||
}
|
||||
}else{
|
||||
error("Could not write to file "+new File(selected).getAbsolutePath(), null);
|
||||
|
||||
}
|
||||
|
||||
if (fdlg.getFile() == null) {
|
||||
return;
|
||||
}
|
||||
if(!new File(selected).canWrite()){
|
||||
try{
|
||||
PrintWriter pw = new PrintWriter(new FileOutputStream(selected));
|
||||
String report = resultsTextArea.getText();
|
||||
pw.print(report);
|
||||
pw.flush();
|
||||
pw.close();
|
||||
JOptionPane.showMessageDialog(frame, "File saved");
|
||||
}catch(IOException e){
|
||||
error("Couldn't save file"+new File(selected).getAbsolutePath(), e);
|
||||
}
|
||||
}else{
|
||||
error("Could not write to file "+new File(selected).getAbsolutePath(), null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void error(String message, Exception e){
|
||||
|
Reference in New Issue
Block a user