/*
- * 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
*/
package gr.grnet.pithos.web.client;
-import com.google.gwt.user.client.ui.TextBox;
-
import gr.grnet.pithos.web.client.grouptree.Group;
import java.util.List;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.RadioButton;
+import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
public class PermissionsAddDialog extends DialogBox {
private ListBox groupBox = new ListBox();
- private CheckBox read = new CheckBox();
+ private RadioButton read = new RadioButton("permissions");
- private CheckBox write = new CheckBox();
+ private RadioButton write = new RadioButton("permissions");
private PermissionsList permList;
userAdd = _userAdd;
permList = _permList;
- Anchor close = new Anchor();
+ Anchor close = new Anchor("close");
close.addStyleName("close");
close.addClickHandler(new ClickHandler() {
final FlexTable permTable = new FlexTable();
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.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels");
permTable.getFlexCellFormatter().setStyleName(0, 1, "props-toplabels");
permTable.getFlexCellFormatter().setStyleName(0, 2, "props-toplabels");
groupBox.addItem(group.getName(), group.getName());
permTable.setWidget(1, 0, groupBox);
}
-
+
+ read.setValue(true);
permTable.setWidget(1, 1, read);
permTable.setWidget(1, 2, write);
final Button ok = new Button("OK", new ClickHandler() {
@Override
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {
+ public void onClick(ClickEvent event) {
addPermission();
hide();
}
String selected = null;
if (userAdd) {
selected = userBox.getText();
- } else {
+ } else if (groupBox.getSelectedIndex() > -1) {
String groupName = groupBox.getValue(groupBox.getSelectedIndex());
- selected = app.getUsername() + ":" + groupName;
+ selected = app.getUsername() + ":" + groupName;
}
if (permList.getPermissions().get(selected) != null) {
return;
}
+ if (selected == null || selected.length() == 0 || selected.equals(app.getUsername() + ":")) {
+ app.displayError("You have to select o username or group");
+ return;
+ }
boolean readValue = read.getValue();
boolean writeValue = write.getValue();