Index: org/netbeans/modules/diff/Bundle.properties =================================================================== RCS file: /cvs/diff/src/org/netbeans/modules/diff/Bundle.properties,v retrieving revision 1.17 diff -u -r1.17 Bundle.properties --- org/netbeans/modules/diff/Bundle.properties 10 Mar 2003 16:28:11 -0000 1.17 +++ org/netbeans/modules/diff/Bundle.properties 3 Aug 2003 20:49:31 -0000 @@ -44,6 +44,9 @@ MSG_NotFoundFiles=Following files are to be patched, but not found: {0} MSG_PatchAppliedSuccessfully=Patch applied successfully. View applied changes? MSG_PatchAppliedPartially=Patch applied partially. View applied changes? +EXC_CannotRemoveBackup=The following backup copies cannot be removed \ + after succesfull application of a patch:\n {0} \ + Reason(s):\n {1} # DiffSettingsBeanInfo PROP_diffService=Default Diff Service Index: org/netbeans/modules/diff/PatchAction.java =================================================================== RCS file: /cvs/diff/src/org/netbeans/modules/diff/PatchAction.java,v retrieving revision 1.12 diff -u -r1.12 PatchAction.java --- org/netbeans/modules/diff/PatchAction.java 6 May 2003 13:13:14 -0000 1.12 +++ org/netbeans/modules/diff/PatchAction.java 3 Aug 2003 20:49:32 -0000 @@ -30,6 +30,7 @@ import java.util.HashMap; import java.util.StringTokenizer; import java.text.MessageFormat; +import java.util.List; import javax.swing.JDialog; import javax.swing.JFileChooser; @@ -212,6 +213,7 @@ if (NotifyDescriptor.YES_OPTION.equals(notifyResult)) { showDiffs(appliedFiles, backups); } + removeBackups(appliedFiles, backups); } } @@ -317,7 +319,34 @@ public HelpCtx getHelpCtx() { return new HelpCtx(PatchAction.class); } - + + /** Removes the backup copies of files upon the successful application + * of a patch (.orig files). + * @param files a list of files, to which the patch was successfully applied + * @param backups a map of a form original file -> backup file + */ + private static void removeBackups(ArrayList files, HashMap backups) { + StringBuffer filenames=new StringBuffer(), + exceptions=new StringBuffer(); + for (int i = 0; i < files.size(); i++) { + FileObject backup=(FileObject) backups.get(files.get(i)); + try { + backup.delete(); + } + catch (IOException ex) { + filenames.append(backup.getPath()); + filenames.append("\n"); + exceptions.append(ex.getLocalizedMessage()); + exceptions.append("\n"); + } + } + if (filenames.length()>0) + ErrorManager.getDefault().notify( + ErrorManager.getDefault().annotate(new IOException(), + NbBundle.getMessage(PatchAction.class, + "EXC_CannotRemoveBackup", filenames, exceptions))); + } + class ChooserListener implements ActionListener{ private JDialog dialog; private JFileChooser chooser;