use of cz.metacentrum.perun.webgui.json.usersManager.AddSpecificUserOwner in project perun by CESNET.
the class ConnectServiceIdentityTabItem method draw.
public Widget draw() {
titleWidget.setText("Connect identity");
VerticalPanel content = new VerticalPanel();
content.setSize("100%", "100%");
final TabItem tab = this;
// add button
final CustomButton addButton;
if (user.isServiceUser() || user.isSponsoredUser()) {
addButton = new CustomButton("Connect", "Add selected users to this identity", SmallIcons.INSTANCE.addIcon());
} else {
addButton = new CustomButton("Connect", "Add selected identities to user", SmallIcons.INSTANCE.addIcon());
}
TabMenu menu = new TabMenu();
menu.addWidget(addButton);
content.add(menu);
content.setCellHeight(menu, "30px");
final FindCompleteRichUsers call = new FindCompleteRichUsers("", null);
if (user.isServiceUser()) {
call.hideService(true);
}
if (user.isSponsoredUser()) {
call.hideSponsored(true);
call.hideService(true);
}
if (!user.isSpecificUser()) {
call.hidePerson(true);
}
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
// close tab and refresh
session.getTabManager().closeTab(tab, true);
}
}));
// search textbox
ExtendedTextBox searchBox = menu.addSearchWidget(new PerunSearchEvent() {
@Override
public void searchFor(String text) {
call.searchFor(text);
}
}, "");
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
ArrayList<User> list = call.getTableSelectedList();
for (int i = 0; i < list.size(); i++) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
AddSpecificUserOwner req;
if (i == list.size() - 1) {
req = new AddSpecificUserOwner(JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab));
} else {
req = new AddSpecificUserOwner(JsonCallbackEvents.disableButtonEvents(addButton));
}
if (user.isServiceUser() || user.isSponsoredUser()) {
// service user adds user
req.addSpecificUser(list.get(i), user);
} else {
// user adds service users
req.addSpecificUser(user, list.get(i));
}
}
}
});
FieldUpdater<User, String> fieldUpdater = null;
if (session.isPerunAdmin()) {
fieldUpdater = new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
};
}
CellTable<User> table = call.getTable(fieldUpdater);
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(call, table, addButton);
content.add(sp);
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
this.contentWidget.setWidget(new SimplePanel(content));
return getWidget();
}
Aggregations