changeset 984:476ce40cafc7

Fixed PolicyEditor NullPointer on exit-and-save 2014-06-06 Andrew Azores <aazores@redhat.com> Fixed NullPointerException when closing PolicyEditor with changes made and no file yet set (editor opened without arguments), and selecting yes to save changes before exit. * netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java (quit): if file is null, display file chooser prompt before attempting to save
author Andrew Azores <aazores@redhat.com>
date Fri, 06 Jun 2014 09:35:30 -0400
parents 216fe105f338
children 7a6519fee342
files ChangeLog netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
diffstat 2 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Apr 15 11:32:04 2014 +0200
+++ b/ChangeLog	Fri Jun 06 09:35:30 2014 -0400
@@ -1,3 +1,11 @@
+2014-06-06  Andrew Azores  <aazores@redhat.com>
+
+	Fixed NullPointerException when closing PolicyEditor with changes made and
+	no file yet set (editor opened without arguments), and selecting yes to
+	save changes before exit.
+	* netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
+	(quit): if file is null, display file chooser prompt before attempting to save
+
 2014-04-15  Jiri Vanek  <jvanek@redhat.com>
 
 	Reflect possibility of disabled manifest check to unit-test
--- a/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java	Tue Apr 15 11:32:04 2014 +0200
+++ b/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java	Fri Jun 06 09:35:30 2014 -0400
@@ -480,6 +480,14 @@
             if (editor.changesMade) {
                 final int save = JOptionPane.showConfirmDialog(this, R("PESaveChanges"));
                 if (save == JOptionPane.YES_OPTION) {
+                    if (editor.file == null) {
+                        final int choice = editor.fileChooser.showSaveDialog(this);
+                        if (choice == JFileChooser.APPROVE_OPTION) {
+                            editor.file = editor.fileChooser.getSelectedFile();
+                        } else if (choice == JFileChooser.CANCEL_OPTION) {
+                            return;
+                        }
+                    }
                     editor.savePolicyFile();
                 } else if (save == JOptionPane.CANCEL_OPTION) {
                     return;
@@ -545,6 +553,14 @@
             if (editor.changesMade) {
                 final int save = JOptionPane.showConfirmDialog(this, R("PESaveChanges"));
                 if (save == JOptionPane.YES_OPTION) {
+                    if (editor.file == null) {
+                        final int choice = editor.fileChooser.showSaveDialog(this);
+                        if (choice == JFileChooser.APPROVE_OPTION) {
+                            editor.file = editor.fileChooser.getSelectedFile();
+                        } else if (choice == JFileChooser.CANCEL_OPTION) {
+                            return;
+                        }
+                    }
                     editor.savePolicyFile();
                 } else if (save == JOptionPane.CANCEL_OPTION) {
                     return;