[Yanel-commits] rev 31481 - public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client

michi at wyona.com michi at wyona.com
Fri Feb 8 10:11:36 CET 2008


Author: michi
Date: 2008-02-08 10:11:35 +0100 (Fri, 08 Feb 2008)
New Revision: 31481

Modified:
   public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java
Log:
setListItem implemented

Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java	2008-02-08 09:11:06 UTC (rev 31480)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java	2008-02-08 09:11:35 UTC (rev 31481)
@@ -85,7 +85,13 @@
                 if (sender == readCB) {
                     Window.alert("Add/Remove Read right from selected identity " + selectedIdentity + " from policy");
                     String[] currentRights = getRights(selectedIdentity);
-                    Vector newRights = new Vector();
+                    String[] newRights;
+                    if (readCB.isChecked()) {
+                        newRights = addRight(currentRights, "Read");
+                    } else {
+                        newRights = removeRight(currentRights, "Read");
+                    }
+                    setListItem(newRights);
                 } else if (sender == writeCB) {
                     Window.alert("Add/Remove Write right from selected identity " + selectedIdentity + " from policy");
                 }
@@ -139,4 +145,42 @@
         }
         return null;
     }
+
+    /**
+     *
+     */
+    private String[] addRight(String[] currentRights, String right) {
+        String[] newRights = new String[1];
+        newRights[0] = right;
+        return newRights;
+    }
+
+    /**
+     *
+     */
+    private String[] removeRight(String[] currentRights, String right) {
+        String[] newRights = new String[1];
+        newRights[0] = right;
+        return newRights;
+    }
+
+    /**
+     *
+     */
+    private void setListItem(String[] rights) {
+        int index = lb.getSelectedIndex();
+        if (index >= 0) {
+            StringBuffer sb = new StringBuffer("U: HUGO");
+            if (rights.length > 0) {
+                sb.append(" (" + rights[0]);
+                for (int j = 1; j < rights.length; j++) {
+                sb.append("," + rights[j]);
+                }
+                sb.append(")");
+            }
+            lb.setItemText(index, sb.toString());
+        } else {
+            Window.alert("Exception: No list item selected!");
+        }
+    }
 }



More information about the Yanel-commits mailing list