Smaller font for the statistics (issue #2239)
[pithos-web-client] / src / gr / grnet / pithos / web / client / PermissionsList.java
index 728d0ca..7d89e5c 100644 (file)
@@ -43,12 +43,15 @@ import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.event.logical.shared.ValueChangeEvent;
 import com.google.gwt.event.logical.shared.ValueChangeHandler;
+import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.Anchor;
 import com.google.gwt.user.client.ui.CheckBox;
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.FlexTable;
 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
 import com.google.gwt.user.client.ui.PushButton;
+import com.google.gwt.user.client.ui.RadioButton;
 import com.google.gwt.user.client.ui.VerticalPanel;
 
 
@@ -67,15 +70,17 @@ public class PermissionsList extends Composite {
        protected boolean hasChanges = false;
 
     private boolean readonly = false;
+    
+    Command changePermissionsCallback;
        
-       public PermissionsList(final Images theImages, Map<String, Boolean[]> thePermissions, String theOwner, boolean inheritsPermissions){
+       public PermissionsList(final Images theImages, Map<String, Boolean[]> thePermissions, String theOwner, boolean inheritsPermissions, Command _changePermissionsCallback){
+               changePermissionsCallback = _changePermissionsCallback;
                images = theImages;
                owner = theOwner;
                permissions =  new HashMap<String, Boolean[]>(thePermissions);
-        readonly = inheritsPermissions;
                permTable.setText(0, 0, "Users/Groups");
-               permTable.setText(0, 1, "Read");
-               permTable.setText(0, 2, "Write");
+               permTable.setText(0, 1, "Read Only");
+               permTable.setText(0, 2, "Read/Write");
                permTable.setText(0, 3, "");
                permTable.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels");
                permTable.getFlexCellFormatter().setStyleName(0, 1, "props-toplabels");
@@ -104,6 +109,8 @@ public class PermissionsList extends Composite {
                permissions.put(user, new Boolean[] {Boolean.valueOf(read), Boolean.valueOf(write)});
                hasChanges = true;
         updatePermissionTable();
+        if (changePermissionsCallback != null)
+               changePermissionsCallback.execute();
        }
 
        /**
@@ -125,12 +132,12 @@ public class PermissionsList extends Composite {
             Boolean readP = userPerms[0];
             Boolean writeP = userPerms[1];
 
-                       CheckBox read = new CheckBox();
+                       RadioButton read = new RadioButton("permissions" + i);
                        read.setValue(readP != null ? readP : false);
             permTable.setWidget(i, 1, read);
             permTable.getFlexCellFormatter().setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_CENTER);
 
-            CheckBox write = new CheckBox();
+            RadioButton write = new RadioButton("permissions" + i);
             write.setValue(writeP != null ? writeP : false);
             permTable.setWidget(i, 2, write);
             permTable.getFlexCellFormatter().setHorizontalAlignment(i, 2, HasHorizontalAlignment.ALIGN_CENTER);
@@ -141,23 +148,33 @@ public class PermissionsList extends Composite {
                     public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
                         Boolean[] ps = permissions.get(user);
                         ps[0] = booleanValueChangeEvent.getValue();
+                        ps[1] = !booleanValueChangeEvent.getValue();
                         hasChanges = true;
+                        if (changePermissionsCallback != null)
+                               changePermissionsCallback.execute();
                     }
                 });
                 write.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
                     @Override
                     public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
                         Boolean[] ps = permissions.get(user);
+                        ps[0] = !booleanValueChangeEvent.getValue();
                         ps[1] = booleanValueChangeEvent.getValue();
                         hasChanges = true;
+                        if (changePermissionsCallback != null)
+                               changePermissionsCallback.execute();
                     }
                 });
-                PushButton removeButton = new PushButton(AbstractImagePrototype.create(images.delete()).createImage(), new ClickHandler() {
+                Anchor removeButton = new Anchor("remove");
+                removeButton.addStyleName(Pithos.resources.pithosCss().commandAnchor());
+                removeButton.addClickHandler(new ClickHandler() {
                     @Override
                     public void onClick(ClickEvent event) {
                         permissions.remove(user);
                         updatePermissionTable();
                         hasChanges = true;
+                        if (changePermissionsCallback != null)
+                               changePermissionsCallback.execute();
                     }
                 });
                 permTable.setWidget(i, 3, removeButton);