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;
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");
permissions.put(user, new Boolean[] {Boolean.valueOf(read), Boolean.valueOf(write)});
hasChanges = true;
updatePermissionTable();
+ if (changePermissionsCallback != null)
+ changePermissionsCallback.execute();
}
/**
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);
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);