/*
- * 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
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;
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() {
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);
}