[Yanel-commits] rev 31470 - 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 00:14:47 CET 2008


Author: michi
Date: 2008-02-08 00:14:47 +0100 (Fri, 08 Feb 2008)
New Revision: 31470

Added:
   public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java
Modified:
   public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client/AccessPolicyEditor.java
   public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client/AddRemoveIdentitiesWidget.java
Log:
policy widget introduced

Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client/AccessPolicyEditor.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client/AccessPolicyEditor.java	2008-02-07 22:14:56 UTC (rev 31469)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client/AccessPolicyEditor.java	2008-02-07 23:14:47 UTC (rev 31470)
@@ -48,6 +48,7 @@
         TextBox searchTB = new TextBox();
         searchTB.setVisibleLength(30);
         searchFilterVP.add(searchTB);
+        searchFilterVP.add(new Button("Search within Identities"));
 
         HorizontalPanel hp = new HorizontalPanel();
         vp.add(hp);
@@ -61,19 +62,15 @@
         identitiesLB.addItem("U: vanya");
         identitiesLB.addItem("U: ezra");
 
-        ListBox policyLB = new ListBox(true);
-        policyLB.setVisibleItemCount(visibleItemCount);
-        policyLB.addItem("U: alice");
-        policyLB.addItem("U: karin");
+        PolicyListBoxWidget policyLBW = new PolicyListBoxWidget(visibleItemCount);
 
-	AddRemoveIdentitiesWidget ariw = new AddRemoveIdentitiesWidget(identitiesLB, policyLB);
+	AddRemoveIdentitiesWidget ariw = new AddRemoveIdentitiesWidget(identitiesLB, policyLBW.getListBox());
 
         //Button removeIdentityButton = new Button("DEBUG", new AddRemoveClickListener(identitiesLB));
 
         hp.add(identitiesLB);
         hp.add(ariw);
-        //hp.add(removeIdentityButton);
-        hp.add(policyLB);
+        hp.add(policyLBW);
     }
 }
 

Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client/AddRemoveIdentitiesWidget.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client/AddRemoveIdentitiesWidget.java	2008-02-07 22:14:56 UTC (rev 31469)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client/AddRemoveIdentitiesWidget.java	2008-02-07 23:14:47 UTC (rev 31470)
@@ -71,7 +71,18 @@
             String selectedIdentity = policyLB.getValue(i);
             Window.alert("Remove selected identity " + selectedIdentity + " from policy");
             policyLB.removeItem(i);
-            identitiesLB.addItem(selectedIdentity);
+            identitiesLB.addItem(removeRights(selectedIdentity));
         }
     }
+
+    /**
+     * Remove rights from string, e.g. "U: alice (Read, Write)" -> "U: alice"
+     */
+    private String removeRights(String identity) {
+        if (identity.indexOf("(") > 0) {
+            return identity.substring(0, identity.indexOf("("));
+        } else {
+            return identity;
+        }
+    }
 }

Added: 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	                        (rev 0)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/yanel/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java	2008-02-07 23:14:47 UTC (rev 31470)
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2008 Wyona
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.wyona.yanel.gwt.accesspolicyeditor.client;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.CheckBox;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ *
+ */
+public class PolicyListBoxWidget extends Composite implements ClickListener {
+
+    private ListBox lb;
+    private CheckBox readCB;
+    private CheckBox writeCB;
+
+    private VerticalPanel vp = new VerticalPanel();
+
+    /**
+     *
+     */
+    public PolicyListBoxWidget(int visibleItemCount) {
+        initWidget(vp);
+
+        vp.add(new Label("Policy"));
+
+        lb = new ListBox(true);
+        lb.addClickListener(this);
+        lb.setVisibleItemCount(visibleItemCount);
+        lb.addItem("U: alice (Read, Write)");
+        lb.addItem("U: karin (Read)");
+        vp.add(lb);
+
+        readCB = new CheckBox("Read");
+        readCB.addClickListener(this);
+        vp.add(readCB);
+        writeCB = new CheckBox("Write");
+        writeCB.addClickListener(this);
+        vp.add(writeCB);
+    }
+
+    /**
+     *
+     */
+    public ListBox getListBox() {
+        return lb;
+    }
+
+    /**
+     *
+     */
+    public void onClick(Widget sender) {
+        if (sender == readCB || sender == writeCB) {
+            int i = lb.getSelectedIndex();
+            if (i > 0) {
+                String selectedIdentity = lb.getValue(i);
+                if (sender == readCB) {
+                    Window.alert("Add/Remove Read right from selected identity " + selectedIdentity + " from policy");
+                } else if (sender == writeCB) {
+                    Window.alert("Add/Remove Write right from selected identity " + selectedIdentity + " from policy");
+                }
+            } else {
+                Window.alert("No identity has been selected! Please select an identity in order to assign rights.");
+            }
+        } else if (sender == lb) {
+                Window.alert("Update check boxes!");
+        }
+    }
+}



More information about the Yanel-commits mailing list