use of cz.metacentrum.perun.webgui.tabs.vostabs.VoManagersTabItem in project perun by CESNET.
the class GroupManagersTabItem method fillContentGroups.
private Widget fillContentGroups(final GetAdminGroups admins, TabMenu menu) {
admins.clearTableSelectedSet();
boolean isMembersGroup = group.isCoreGroup();
menu.addWidget(0, UiElements.getRefreshButton(this));
// Events for reloading when finished
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(admins);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerGroupFromGroup());
if (!isMembersGroup) {
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerGroupToGroup(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddGroupManagerGroupTabItem(group, events), true);
}
});
if (!session.isVoAdmin(group.getVoId()) && !session.isGroupAdmin(group.getId()))
addButton.setEnabled(false);
menu.addWidget(1, addButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Group> itemsToRemove = admins.getTableSelectedList();
String text = "Members of following groups won't be group managers anymore.";
UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < itemsToRemove.size(); i++) {
RemoveAdmin request;
if (i == itemsToRemove.size() - 1) {
request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.removeGroupAdminGroup(group, itemsToRemove.get(i));
}
}
});
}
});
menu.addWidget(2, removeButton);
} else {
// is core group
menu.addWidget(1, new Image(SmallIcons.INSTANCE.helpIcon()));
Anchor a = new Anchor("<strong>To edit VO managers use VO manager section in menu.</strong>", true);
a.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new VoManagersTabItem(group.getVoId()));
}
});
menu.addWidget(2, a);
}
// get the table
CellTable<Group> table = admins.getTable(new FieldUpdater<Group, String>() {
public void update(int i, Group grp, String s) {
session.getTabManager().addTab(new GroupDetailTabItem(grp));
}
});
removeButton.setEnabled(false);
if (session.isVoAdmin(group.getVoId()) || session.isGroupAdmin(group.getId())) {
JsonUtils.addTableManagedButton(admins, table, removeButton);
}
table.setStyleName("perun-table");
return table;
}
use of cz.metacentrum.perun.webgui.tabs.vostabs.VoManagersTabItem in project perun by CESNET.
the class GroupManagersTabItem method fillContentUsers.
private Widget fillContentUsers(final GetRichAdminsWithAttributes admins, TabMenu menu) {
admins.clearTableSelectedSet();
boolean isMembersGroup = group.isCoreGroup();
menu.addWidget(0, UiElements.getRefreshButton(this));
// Events for reloading when finished
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(admins);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerFromGroup());
if (!isMembersGroup) {
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerToGroup(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddGroupManagerTabItem(group), true);
}
});
if (!session.isVoAdmin(group.getVoId()) && !session.isGroupAdmin(group.getId()))
addButton.setEnabled(false);
menu.addWidget(1, addButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<User> itemsToRemove = admins.getTableSelectedList();
String text = "Following users won't be group managers anymore.";
UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < itemsToRemove.size(); i++) {
RemoveAdmin request;
if (i == itemsToRemove.size() - 1) {
request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.removeGroupAdmin(group, itemsToRemove.get(i));
}
}
});
}
});
menu.addWidget(2, removeButton);
} else {
// is core group
menu.addWidget(1, new Image(SmallIcons.INSTANCE.helpIcon()));
Anchor a = new Anchor("<strong>To edit VO managers use VO manager section in menu.</strong>", true);
a.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new VoManagersTabItem(group.getVoId()));
}
});
menu.addWidget(2, a);
}
// get the table
CellTable<User> table;
if (session.isPerunAdmin()) {
table = admins.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
});
} else {
table = admins.getTable();
}
removeButton.setEnabled(false);
if (session.isVoAdmin(group.getVoId()) || session.isGroupAdmin(group.getId())) {
JsonUtils.addTableManagedButton(admins, table, removeButton);
}
table.setStyleName("perun-table");
return table;
}
Aggregations