[Yanel-commits] rev 33420 -
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client
michi at wyona.com
michi at wyona.com
Fri Mar 14 14:20:05 CET 2008
Author: michi
Date: 2008-03-14 14:20:04 +0100 (Fri, 14 Mar 2008)
New Revision: 33420
Modified:
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AccessPolicyEditor.java
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AsynchronousIdentitiesAndRightsGetter.java
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/IdentitiesListBoxWidget.java
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Right.java
Log:
dynamic loading of available rights added
Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AccessPolicyEditor.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AccessPolicyEditor.java 2008-03-14 12:50:20 UTC (rev 33419)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AccessPolicyEditor.java 2008-03-14 13:20:04 UTC (rev 33420)
@@ -38,9 +38,6 @@
*/
public class AccessPolicyEditor implements EntryPoint {
- String[] users;
- String[] groups;
- String[] rights;
User[] policyUsers;
Group[] policyGroups;
boolean useInheritedPolicies = true;
@@ -137,7 +134,7 @@
saveButton.setStyleName("gwt-wyona-CancelButton");
buttonHP.add(cancelButton);
- identitiesLBW = new IdentitiesListBoxWidget(visibleItemCount, users, groups);
+ identitiesLBW = new IdentitiesListBoxWidget(visibleItemCount);
policyLBW = new PolicyListBoxWidget(visibleItemCount, policyUsers, policyGroups, useInheritedPolicies);
@@ -167,11 +164,10 @@
// TODO: Show loading ...
scheduleRepeating(10);
} else {
- users = ag.getUsers();
- groups = ag.getGroups();
- rights = ag.getRights();
// "Redraw" Listbox
- identitiesLBW.set(visibleItemCount, users, groups);
+ identitiesLBW.set(visibleItemCount, ag.getUsers(), ag.getGroups());
+ // TODO: "Redraw" Policy Listbox
+ policyLBW.set(ag.getRights());
this.cancel();
Window.alert("Identities have been loaded!");
}
Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AsynchronousIdentitiesAndRightsGetter.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AsynchronousIdentitiesAndRightsGetter.java 2008-03-14 12:50:20 UTC (rev 33419)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AsynchronousIdentitiesAndRightsGetter.java 2008-03-14 13:20:04 UTC (rev 33420)
@@ -71,8 +71,10 @@
Element rightsElement = getFirstChildElement(rootElement, "rights");
NodeList rightElements = rightsElement.getElementsByTagName("right");
for (int i = 0; i < rightElements.getLength(); i++) {
- rights.add(((Element) rightElements.item(i)).getAttribute("id"));
- //Window.alert("Right: " + (String) rights.elementAt(i));
+ // TODO: Get actual label
+ String label = ((Element) rightElements.item(i)).getAttribute("id");
+ rights.add(new Right(((Element) rightElements.item(i)).getAttribute("id"), label));
+ //Window.alert("Right: " + ((Right) rights.elementAt(i)).getId() + ", " + ((Right) rights.elementAt(i)).getLabel() );
}
}
@@ -104,11 +106,11 @@
/**
* Get rights
*/
- public String[] getRights() {
- String[] r = new String[rights.size()];
+ public Right[] getRights() {
+ Right[] r = new Right[rights.size()];
for (int i = 0; i < rights.size(); i++) {
- r[i] = (String) rights.elementAt(i);
- //Window.alert("Right: " + r[i]);
+ r[i] = (Right) rights.elementAt(i);
+ //Window.alert("Right: " + r[i].getId());
}
return r;
}
Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/IdentitiesListBoxWidget.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/IdentitiesListBoxWidget.java 2008-03-14 12:50:20 UTC (rev 33419)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/IdentitiesListBoxWidget.java 2008-03-14 13:20:04 UTC (rev 33420)
@@ -42,14 +42,14 @@
/**
*
*/
- public IdentitiesListBoxWidget(int visibleItemCount, String[] users, String[] groups) {
+ public IdentitiesListBoxWidget(int visibleItemCount) {
initWidget(vp);
vp.add(new Label("Identities"));
lb = new ListBox(true);
lb.addClickListener(this);
- set(visibleItemCount, users, groups);
+ set(visibleItemCount, null, null);
vp.add(lb);
}
Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java 2008-03-14 12:50:20 UTC (rev 33419)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java 2008-03-14 13:20:04 UTC (rev 33420)
@@ -46,9 +46,9 @@
private String READ_RIGHT = "r";
private String WRITE_RIGHT = "w";
+ private Right[] availableRights;
+ private CheckBox[] availableRightsCB;
- //private String READ_RIGHT = "Read";
- //private String WRITE_RIGHT = "Write";
/**
*
@@ -67,12 +67,7 @@
setIdentities(visibleItemCount, users, groups);
vp.add(lb);
- readCB = new CheckBox("Read");
- readCB.addClickListener(this);
- vp.add(readCB);
- writeCB = new CheckBox("Write");
- writeCB.addClickListener(this);
- vp.add(writeCB);
+ set(null);
}
/**
@@ -190,9 +185,33 @@
*
*/
public void onClick(Widget sender) {
- if (sender == readCB || sender == writeCB) {
+ CheckBox selectedRightCB = null;
+ Right selectedRight = null;
+ for (int i = 0; i < availableRightsCB.length; i++) {
+ if (sender == availableRightsCB[i]) {
+ selectedRightCB = availableRightsCB[i];
+ selectedRight = availableRights[i];
+ break;
+ }
+ }
+ if (selectedRightCB != null) {
+ Window.alert("Right checkbox has been selected, but implementation is not finished yet!");
String selectedIdentity = getSelectedItemText();
if (selectedIdentity != null) {
+ if (selectedRightCB.isChecked()) {
+ Window.alert("Add " + selectedRight.getLabel() + " right of selected identity " + selectedIdentity + " to policy");
+ //newRights = addRight(currentRights, READ_RIGHT);
+ } else {
+ Window.alert("Remove " + selectedRight.getLabel() + " right of selected identity " + selectedIdentity + " from policy");
+ //newRights = removeRight(currentRights, READ_RIGHT);
+ }
+ } else {
+ Window.alert("No identity has been selected! Please select an identity in order to assign rights.");
+ selectedRightCB.setChecked(false);
+ }
+ } else if (sender == readCB || sender == writeCB) {
+ String selectedIdentity = getSelectedItemText();
+ if (selectedIdentity != null) {
if (sender == readCB) {
Right[] currentRights = getRights(selectedIdentity);
String[] newRights;
@@ -469,4 +488,30 @@
public boolean getUseInheritedPolicies() {
return policyInheritanceCB.isChecked();
}
+
+ /**
+ * Set available rights (checkboxes)
+ */
+ public void set(Right[] availableRights) {
+ this.availableRights = availableRights;
+ if (availableRights != null) {
+ availableRightsCB = new CheckBox[availableRights.length];
+ for (int i = 0; i < availableRightsCB.length; i++) {
+ // TODO: Also set label
+ availableRightsCB[i] = new CheckBox(availableRights[i].getId());
+ availableRightsCB[i].addClickListener(this);
+ vp.add(availableRightsCB[i]);
+ }
+
+ // TODO: Remove as soon as the array is working
+ readCB = new CheckBox("Read");
+ readCB.addClickListener(this);
+ vp.add(readCB);
+ writeCB = new CheckBox("Write");
+ writeCB.addClickListener(this);
+ vp.add(writeCB);
+ } else {
+ Window.alert("Available rights not loaded yet! Please don't worry, they will arrive soon hopefully!");
+ }
+ }
}
Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Right.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Right.java 2008-03-14 12:50:20 UTC (rev 33419)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Right.java 2008-03-14 13:20:04 UTC (rev 33420)
@@ -21,6 +21,7 @@
public class Right {
private String id;
+ private String label;
private boolean permission;
/**
@@ -32,6 +33,16 @@
}
/**
+ * @param id ID of right, for example "r" or "open"
+ * @param label Label of right, for example "Read" or "Open for editing"
+ */
+ public Right(String id, String label) {
+ this.id = id;
+ this.label = label;
+ this.permission = false;
+ }
+
+ /**
*
*/
public String getId() {
@@ -41,6 +52,13 @@
/**
*
*/
+ public String getLabel() {
+ return label;
+ }
+
+ /**
+ *
+ */
public boolean getPermission() {
return permission;
}
More information about the Yanel-commits
mailing list