Revision: 3424
Author: ferguson.sebastian
Date: Tue Mar 30 12:55:03 2010
Log: Fixed minor bug where altering a grant (remove then add) was not properly wrapped
http://code.google.com/p/power-architect/source/detail?r=3424

Modified:
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/PrivilegesEditorPanel.java /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/ProjectSecurityPanel.java /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/SecurityPanel.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/PrivilegesEditorPanel.java Mon Mar 29 14:08:45 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/PrivilegesEditorPanel.java Tue Mar 30 12:55:03 2010
@@ -26,6 +26,7 @@
 import javax.swing.JCheckBox;
 import javax.swing.JPanel;

+import ca.sqlpower.architect.ArchitectProject;
 import ca.sqlpower.enterprise.client.Grant;
 import ca.sqlpower.enterprise.client.Group;
 import ca.sqlpower.enterprise.client.User;
@@ -57,9 +58,12 @@
     private final String subject;
     private final String target;

+    private final ArchitectProject securityWorkspace;
+
     private boolean hasUnsavedChanges = false;

- public PrivilegesEditorPanel(Grant baseGrant, SPObject baseGroupOrUser, String subject, String target) { + public PrivilegesEditorPanel(Grant baseGrant, SPObject baseGroupOrUser, String subject, String target, ArchitectProject securityWorkspace) {
+        this.securityWorkspace = securityWorkspace;
         this.grant = baseGrant;
         this.groupOrUser = baseGroupOrUser;
         this.subject = subject;
@@ -149,11 +153,11 @@
                             viewPrivilege.isSelected(),
                             grantPrivilege.isSelected());

+                    securityWorkspace.begin("");
                     if (groupOrUser instanceof User) {
                         if (grant != null) {
                             ((User) groupOrUser).removeGrant(grant);
                         }
-
                         ((User) groupOrUser).addGrant(newGrant);
                     }

@@ -161,9 +165,9 @@
                         if (grant != null) {
                             ((Group) groupOrUser).removeGrant(grant);
                         }
-
                         ((Group) groupOrUser).addGrant(newGrant);
                     }
+                    securityWorkspace.commit();
                 }
             }

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/ProjectSecurityPanel.java Mon Mar 29 14:08:45 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/ProjectSecurityPanel.java Tue Mar 30 12:55:03 2010
@@ -176,8 +176,8 @@

         for (User user : users) {
             // can pass in null, it will just be empty
- final PrivilegesEditorPanel specific = new PrivilegesEditorPanel(specificGrantsForUsers.get(user), user, workspace.getUUID(), null); - final PrivilegesEditorPanel global = new PrivilegesEditorPanel(globalGrantsForUsers.get(user), user, workspace.getUUID(), null); + final PrivilegesEditorPanel specific = new PrivilegesEditorPanel(specificGrantsForUsers.get(user), user, workspace.getUUID(), null, securityWorkspace); + final PrivilegesEditorPanel global = new PrivilegesEditorPanel(globalGrantsForUsers.get(user), user, workspace.getUUID(), null, securityWorkspace);

             panels.add(specific);
             panels.add(global);
@@ -282,8 +282,8 @@

         for (Group group : groups) {
             // can pass in null, it will just be empty
- final PrivilegesEditorPanel specific = new PrivilegesEditorPanel(specificGrantsForGroups.get(group), group, workspace.getUUID(), null); - final PrivilegesEditorPanel global = new PrivilegesEditorPanel(globalGrantsForGroups.get(group), group, workspace.getUUID(), null); + final PrivilegesEditorPanel specific = new PrivilegesEditorPanel(specificGrantsForGroups.get(group), group, workspace.getUUID(), null, securityWorkspace); + final PrivilegesEditorPanel global = new PrivilegesEditorPanel(globalGrantsForGroups.get(group), group, workspace.getUUID(), null, securityWorkspace);

             panels.add(specific);
             panels.add(global);
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/SecurityPanel.java Tue Mar 30 10:53:37 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/SecurityPanel.java Tue Mar 30 12:55:03 2010
@@ -270,12 +270,12 @@
                 if (privilegesEditorPanel != null) {
throw new IllegalStateException("Multiple grants for this workspace found!");
                 }
- privilegesEditorPanel = new PrivilegesEditorPanel(grant, groupOrUser, null, ArchitectProject.class.getName()); + privilegesEditorPanel = new PrivilegesEditorPanel(grant, groupOrUser, null, ArchitectProject.class.getName(), securityWorkspace);
             }
         }

         if (privilegesEditorPanel == null) {
- privilegesEditorPanel = new PrivilegesEditorPanel(null, groupOrUser, null, ArchitectProject.class.getName()); + privilegesEditorPanel = new PrivilegesEditorPanel(null, groupOrUser, null, ArchitectProject.class.getName(), securityWorkspace);
         }

         currentGroupOrUserEditPanel = groupOrUserEditPanel;

To unsubscribe from this group, send email to 
architect-commits+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to