changeset 958:e9f222be36b5

PolicyEditor codebase list and checkboxes visual bug fix Fix bug with checkboxes not correctly updating on open and with repeats of a codebase appearing when opening a file multiple times * netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java: (resetCodebases) new method. (openAndParsePolicyFile) call resetCodebases at start. (PolicyEditor) call resetCodebases in constructor
author Andrew Azores <aazores@redhat.com>
date Thu, 27 Mar 2014 11:13:41 -0400
parents ede0279b5c53
children 8417559b6a12
files ChangeLog netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
diffstat 2 files changed, 25 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Mar 27 11:08:09 2014 -0400
+++ b/ChangeLog	Thu Mar 27 11:13:41 2014 -0400
@@ -1,3 +1,11 @@
+2014-03-27  Andrew Azores  <aazores@redhat.com>
+
+	Fix bug with checkboxes not correctly updating on open and with repeats of
+	a codebase appearing when opening a file multiple times
+	* netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java:
+	(resetCodebases) new method. (openAndParsePolicyFile) call resetCodebases
+	at start. (PolicyEditor) call resetCodebases in constructor
+
 2014-03-27  Andrew Azores  <aazores@redhat.com>
 
 	Applets can be temporarily granted permission levels above fully sandboxed
--- a/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java	Thu Mar 27 11:08:09 2014 -0400
+++ b/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java	Thu Mar 27 11:13:41 2014 -0400
@@ -220,6 +220,7 @@
             }
         }
     }
+
     public PolicyEditor(final String filepath) {
         super();
         setLayout(new GridBagLayout());
@@ -234,15 +235,13 @@
         if (filepath != null) {
             file = new File(filepath);
             openAndParsePolicyFile();
+        } else {
+            resetCodebases();
         }
 
         fileChooser = new JFileChooser(file);
         fileChooser.setFileHidingEnabled(false);
 
-        initializeMapForCodebase("");
-        listModel.addElement(R("PEGlobalSettings"));
-        updateCheckboxes("");
-
         okButtonAction = new ActionListener() {
             @Override
             public void actionPerformed(final ActionEvent event) {
@@ -335,8 +334,6 @@
         setAccelerators();
 
         setupLayout();
-        list.setSelectedIndex(0);
-        updateCheckboxes("");
     }
     
     private String getSelectedCodebase() {
@@ -1118,6 +1115,17 @@
         customPermissionsMap.get(codebase).addAll(permissions);
     }
 
+    private void resetCodebases() {
+        listModel.clear();
+        codebasePermissionsMap.clear();
+        customPermissionsMap.clear();
+
+        initializeMapForCodebase("");
+        listModel.addElement(R("PEGlobalSettings"));
+        list.setSelectedValue(R("PEGlobalSettings"), true);
+        updateCheckboxes("");
+    }
+
     /**
      * Open the file pointed to by the filePath field. This is either provided by the
      * "-file" command line flag, or if none given, comes from DeploymentConfiguration.
@@ -1126,6 +1134,8 @@
         new Thread() {
             @Override
             public void run() {
+                resetCodebases();
+
                 if (!file.exists()) {
                     try {
                         file.createNewFile();
@@ -1215,7 +1225,7 @@
                         }
                     }
                 }
-                list.setSelectedIndex(0);
+                list.setSelectedValue(R("PEGlobalSettings"), true);
                 updateCheckboxes("");
                 try {
                     fileLock.release();