X-Git-Url: https://code.grnet.gr/git/pithos-web-client/blobdiff_plain/ebead1b508364bfa1154e40773c659bc61dc87cf..2dfc5957007f644ffd221254b90f5984557d8d1b:/src/gr/grnet/pithos/web/client/PermissionsList.java diff --git a/src/gr/grnet/pithos/web/client/PermissionsList.java b/src/gr/grnet/pithos/web/client/PermissionsList.java index c2e5e30..c7e58d2 100644 --- a/src/gr/grnet/pithos/web/client/PermissionsList.java +++ b/src/gr/grnet/pithos/web/client/PermissionsList.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 GRNET S.A. All rights reserved. + * Copyright 2011-2012 GRNET S.A. All rights reserved. * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following @@ -43,12 +43,14 @@ 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.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 +69,17 @@ public class PermissionsList extends Composite { protected boolean hasChanges = false; private boolean readonly = false; + + Command changePermissionsCallback; - public PermissionsList(final Images theImages, Map thePermissions, String theOwner, boolean inheritsPermissions){ + public PermissionsList(final Images theImages, Map thePermissions, String theOwner, boolean inheritsPermissions, Command _changePermissionsCallback){ + changePermissionsCallback = _changePermissionsCallback; images = theImages; owner = theOwner; permissions = new HashMap(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 +108,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 +131,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,15 +147,21 @@ public class PermissionsList extends Composite { public void onValueChange(ValueChangeEvent 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() { @Override public void onValueChange(ValueChangeEvent 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() { @@ -158,8 +170,11 @@ public class PermissionsList extends Composite { permissions.remove(user); updatePermissionTable(); hasChanges = true; + if (changePermissionsCallback != null) + changePermissionsCallback.execute(); } }); + removeButton.setTitle("Remove"); permTable.setWidget(i, 3, removeButton); permTable.getFlexCellFormatter().setHorizontalAlignment(i, 3, HasHorizontalAlignment.ALIGN_CENTER); }