use of cz.metacentrum.perun.webgui.model.Group in project perun by CESNET.
the class AddFacilityManagerGroupTabItem method fillGroupsContent.
private Widget fillGroupsContent(GetAllGroups groups, TabMenu tabMenu, final ListBoxWithObjects<VirtualOrganization> box) {
getAllGroups = groups;
getAllGroups.setCoreGroupsCheckable(true);
final CellTable<Group> table = getAllGroups.getTable();
getAllGroups.getSelectionModel().addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
private boolean found = false;
@Override
public void onSelectionChange(SelectionChangeEvent event) {
for (Group g : getAllGroups.getTableSelectedList()) {
if (g.isCoreGroup()) {
if (!found) {
// display only once
UiElements.generateInfo("You have selected 'all vo members' group", "If this group will be added as 'manager group', all new members of VO " + box.getSelectedObject().getName() + " will be automatically managers of your Facility and all removed members will lose management rights.");
}
found = true;
return;
}
}
found = false;
}
});
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersGroupToGroup());
tabMenu.addWidget(0, addButton);
final TabItem tab = this;
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Group> list = getAllGroups.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
// close tab and refresh table
if (refreshEvents != null)
refreshEvents.onFinished(null);
session.getTabManager().closeTab(tab, false);
}
}));
request.addFacilityAdminGroup(facility, list.get(i));
} else {
AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton));
request.addFacilityAdminGroup(facility, list.get(i));
}
}
}
}
});
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(getAllGroups, table, addButton);
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
return table;
}
use of cz.metacentrum.perun.webgui.model.Group in project perun by CESNET.
the class CreateGroupTabItem method draw.
public Widget draw() {
VerticalPanel vp = new VerticalPanel();
// used for closing
final TabItem tab = this;
// form inputs
final ExtendedTextBox groupNameTextBox = new ExtendedTextBox();
final TextBox groupDescriptionTextBox = new TextBox();
final ListBoxWithObjects<Group> vosGroups = new ListBoxWithObjects<Group>();
vosGroups.setVisible(false);
final CheckBox asSubGroup = new CheckBox("", false);
TabMenu menu = new TabMenu();
final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, "");
final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
final HTML parentGroupText = new HTML("Parent group:");
parentGroupText.setVisible(false);
final GetAllGroups groupsCall = new GetAllGroups(voId, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
vosGroups.clear();
ArrayList<Group> retGroups = JsonUtils.jsoAsList(jso);
retGroups = new TableSorter<Group>().sortByName(retGroups);
for (Group g : retGroups) {
if (!g.isCoreGroup()) {
// SKIP CORE GROUPS !!
vosGroups.addItem(g);
if (g.getId() == groupId) {
// select default if passed to tab
vosGroups.setSelected(g, true);
}
}
}
if (vosGroups.getAllObjects().isEmpty()) {
vosGroups.addItem("No groups found");
} else {
createButton.setEnabled(true);
}
// call finished when user changed his mind
if (!asSubGroup.getValue()) {
createButton.setEnabled(true);
}
}
public void onLoadingStart() {
vosGroups.clear();
vosGroups.addItem("Loading...");
createButton.setEnabled(false);
}
public void onError(PerunError error) {
vosGroups.clear();
vosGroups.addItem("Error while loading");
if (!asSubGroup.getValue()) {
createButton.setEnabled(true);
}
}
});
// set title
if (PerunEntity.GROUP.equals(entity)) {
this.titleWidget.setText("Create sub-group");
asSubGroup.setValue(true);
createButton.setTitle(ButtonTranslation.INSTANCE.createSubGroup());
parentGroupText.setVisible(true);
vosGroups.setVisible(true);
groupsCall.retrieveData();
} else {
this.titleWidget.setText("Create group");
createButton.setTitle(ButtonTranslation.INSTANCE.createGroup());
}
asSubGroup.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
if (booleanValueChangeEvent.getValue() == true) {
// set title
titleWidget.setText("Create sub-group");
vosGroups.setVisible(true);
parentGroupText.setVisible(true);
groupsCall.retrieveData();
createButton.setTitle(ButtonTranslation.INSTANCE.createSubGroup());
} else {
titleWidget.setText("Create group");
vosGroups.setVisible(false);
parentGroupText.setVisible(false);
createButton.setTitle(ButtonTranslation.INSTANCE.createGroup());
createButton.setEnabled(true);
}
}
});
// layout
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (groupNameTextBox.getTextBox().getText().trim().isEmpty()) {
groupNameTextBox.setError("Name can't be empty.");
} else if (!groupNameTextBox.getTextBox().getText().trim().matches(Utils.GROUP_SHORT_NAME_MATCHER)) {
groupNameTextBox.setError("Name can contain only a-z, A-Z, numbers, spaces, dots, '_' and '-'.");
} else {
groupNameTextBox.setOk();
return true;
}
return false;
}
};
groupNameTextBox.setValidator(validator);
// send button
createButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (!validator.validateTextBox())
return;
// creates a new request
CreateGroup cg = new CreateGroup(JsonCallbackEvents.closeTabDisableButtonEvents(createButton, tab));
if (asSubGroup.getValue()) {
if (vosGroups.getSelectedObject() != null) {
cg.createGroupInGroup(vosGroups.getSelectedObject().getId(), groupNameTextBox.getTextBox().getText().trim(), groupDescriptionTextBox.getText().trim());
} else {
UiElements.generateInfo("No parent group selected", "You checked create this group as sub-group, but no parent group is selected. Please select parent group.");
}
} else {
cg.createGroupInVo(voId, groupNameTextBox.getTextBox().getText().trim(), groupDescriptionTextBox.getText().trim());
}
}
});
// cancel button
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
});
// Add some standard form options
layout.setHTML(0, 0, "Name:");
layout.setWidget(0, 1, groupNameTextBox);
layout.setHTML(1, 0, "Description:");
layout.setWidget(1, 1, groupDescriptionTextBox);
layout.setHTML(2, 0, "As sub-group:");
layout.setWidget(2, 1, asSubGroup);
layout.setWidget(3, 0, parentGroupText);
layout.setWidget(3, 1, vosGroups);
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
// button align
menu.addWidget(createButton);
menu.addWidget(cancelButton);
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.model.Group in project perun by CESNET.
the class EditGroupDetailsTabItem method draw.
public Widget draw() {
titleWidget = new Label("Edit group");
VerticalPanel vp = new VerticalPanel();
// textboxes which set the class data when updated
final ExtendedTextBox descriptionTextBox = new ExtendedTextBox();
descriptionTextBox.getTextBox().setText(group.getDescription());
final ExtendedTextBox nameTextBox = new ExtendedTextBox();
nameTextBox.getTextBox().setText(group.getShortName());
// disable name change for core groups
nameTextBox.getTextBox().setEnabled(!group.isCoreGroup());
// prepares layout
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
// close tab events
final TabItem tab = this;
TabMenu menu = new TabMenu();
// send button
final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, buttonTranslation.saveGroupDetails());
final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (nameTextBox.getTextBox().getText().trim().isEmpty()) {
nameTextBox.setError("Name can't be empty.");
} else if (!nameTextBox.getTextBox().getText().trim().matches(Utils.GROUP_SHORT_NAME_MATCHER)) {
nameTextBox.setError("Name can contain only a-z, A-Z, numbers, spaces, dots, '_' and '-'.");
} else {
nameTextBox.setOk();
return true;
}
return false;
}
};
nameTextBox.setValidator(validator);
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (!validator.validateTextBox())
return;
Group g = JsonUtils.clone(group).cast();
g.setDescription(descriptionTextBox.getTextBox().getText().trim());
String value = nameTextBox.getTextBox().getText().trim();
g.setShortName(value);
int index = g.getName().lastIndexOf(":");
if (index > 0) {
// short name append to base name
String baseName = g.getName().substring(0, index);
baseName += ":" + g.getShortName();
g.setName(baseName);
} else {
// short name is whole name
g.setName(value);
}
;
UpdateGroup request = new UpdateGroup(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, events));
request.updateGroup(g);
}
});
// cancel button
final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
});
// Add some standard form options
layout.setHTML(0, 0, "Name:");
layout.setWidget(0, 1, nameTextBox);
layout.setHTML(1, 0, "Description:");
layout.setWidget(1, 1, descriptionTextBox);
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
menu.addWidget(saveButton);
menu.addWidget(cancelButton);
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.model.Group in project perun by CESNET.
the class AddVoManagerGroupTabItem method fillGroupsContent.
private Widget fillGroupsContent(GetAllGroups groups, TabMenu tabMenu, final ListBoxWithObjects<VirtualOrganization> box) {
getAllGroups = groups;
getAllGroups.setCoreGroupsCheckable(true);
final CellTable<Group> table = getAllGroups.getTable();
getAllGroups.getSelectionModel().addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
private boolean found = false;
@Override
public void onSelectionChange(SelectionChangeEvent event) {
for (Group g : getAllGroups.getTableSelectedList()) {
if (g.isCoreGroup()) {
if (!found) {
// display only once
UiElements.generateInfo("You have selected 'all vo members' group", "If this group will be added as 'manager group', all new members of VO " + box.getSelectedObject().getName() + " will be automatically managers of your VO and all removed members will lose management rights.");
}
found = true;
return;
}
}
found = false;
}
});
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersGroupToVo());
tabMenu.addWidget(0, addButton);
final TabItem tab = this;
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Group> list = getAllGroups.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
// close tab and refresh table
if (refreshEvents != null)
refreshEvents.onFinished(null);
session.getTabManager().closeTab(tab, false);
}
}));
request.addVoAdminGroup(vo, list.get(i));
} else {
AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton));
request.addVoAdminGroup(vo, list.get(i));
}
}
}
}
});
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(getAllGroups, table, addButton);
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
return table;
}
use of cz.metacentrum.perun.webgui.model.Group in project perun by CESNET.
the class GetSubGroups method setList.
public void setList(ArrayList<Group> list) {
clearTable();
this.list.addAll(list);
for (Group g : list) {
oracle.add(g.getName());
}
dataProvider.flush();
dataProvider.refresh();
}
Aggregations