use of cz.metacentrum.perun.webgui.json.registrarManager.GetAutoRegistrationGroups in project perun by CESNET.
the class AddAutoRegGroupTabItem method draw.
@Override
public Widget draw() {
titleWidget.setText("Add group for auto registration");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
menu.addWidget(new HTML(""));
final GetAllGroups groups = new GetAllGroups(vo.getId());
groups.setCoreGroupsCheckable(false);
// remove already added union groups from offering
JsonCallbackEvents localEvents = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// second callback
final GetAutoRegistrationGroups alreadySet = new GetAutoRegistrationGroups(vo.getId(), new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
JsArray<Group> esToRemove = JsonUtils.jsoAsArray(jso);
for (int i = 0; i < esToRemove.length(); i++) {
groups.removeFromTable(esToRemove.get(i));
}
}
});
alreadySet.retrieveData();
}
};
groups.setEvents(localEvents);
final ExtendedSuggestBox box = new ExtendedSuggestBox(groups.getOracle());
// button
final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedExtSource());
final TabItem tab = this;
assignButton.addClickHandler(event -> {
final ArrayList<Group> availableGroups = groups.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(availableGroups)) {
AddAutoRegGroups request = new AddAutoRegGroups(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// clear search
box.getSuggestBox().setText("");
groups.retrieveData();
}
}));
request.setAutoRegGroups(availableGroups);
}
});
menu.addFilterWidget(box, new PerunSearchEvent() {
@Override
public void searchFor(String text) {
groups.filterTable(text);
}
}, "Filter by name");
menu.addWidget(assignButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", clickEvent -> session.getTabManager().closeTab(tab, isRefreshParentOnClose())));
vp.add(menu);
vp.setCellHeight(menu, "30px");
CellTable<Group> table = groups.getTable();
assignButton.setEnabled(false);
JsonUtils.addTableManagedButton(groups, table, assignButton);
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
// do not use resizePerunTable() when tab is in overlay - wrong width is calculated
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.registrarManager.GetAutoRegistrationGroups in project perun by CESNET.
the class AutoRegistrationGroupsTabItem method draw.
@Override
public Widget draw() {
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
final GetAutoRegistrationGroups groups = new GetAutoRegistrationGroups(voId);
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(groups);
if (!session.isVoAdmin(voId)) {
groups.setCheckable(false);
}
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addGroupToAutoReg(), event -> session.getTabManager().addTabToCurrentTab(new AddAutoRegGroupTabItem(vo), true));
if (!session.isVoAdmin(voId))
addButton.setEnabled(false);
menu.addWidget(addButton);
// remove selected groups button
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupFromAutoReg());
removeButton.addClickHandler(event -> {
final ArrayList<Group> groupsToRemove = groups.getTableSelectedList();
String text = "Following groups will be removed from the auto registration.";
UiElements.showDeleteConfirm(groupsToRemove, text, clickEvent -> {
RemoveGroupsFromAutoRegistration request = new RemoveGroupsFromAutoRegistration(JsonCallbackEvents.disableButtonEvents(removeButton, events));
request.deleteGroups(groupsToRemove);
});
});
menu.addWidget(removeButton);
// filter box
menu.addFilterWidget(new ExtendedSuggestBox(groups.getOracle()), new PerunSearchEvent() {
public void searchFor(String text) {
groups.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterGroup());
// add a table with a onclick
CellTable<Group> table = groups.getTable();
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(table);
contentWidget.setWidget(vp);
return getWidget();
}
Aggregations