use of cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers in project perun by CESNET.
the class AddSecurityTeamManagerTabItem method draw.
public Widget draw() {
titleWidget.setText("Add member");
final CustomButton searchButton = new CustomButton("Search", ButtonTranslation.INSTANCE.searchUsers(), SmallIcons.INSTANCE.findIcon());
this.users = new FindCompleteRichUsers("", null, JsonCallbackEvents.disableButtonEvents(searchButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// if found 1 item, select
ArrayList<User> list = JsonUtils.jsoAsList(jso);
if (list != null && list.size() == 1) {
users.getSelectionModel().setSelected(list.get(0), true);
}
}
}));
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu tabMenu = new TabMenu();
// get the table
final CellTable<User> table;
if (session.isPerunAdmin()) {
table = users.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
});
} else {
table = users.getTable();
}
rebuildAlreadyAddedWidget();
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersToSecurityTeam());
final TabItem tab = this;
// search textbox
final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {
@Override
public void searchFor(String text) {
startSearching(text);
searchString = text;
}
}, searchButton);
tabMenu.addWidget(addButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
}));
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<User> list = users.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i = 0; i < list.size(); i++) {
// FIXME - Should have only one callback to core
final int n = i;
AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// put names to already added
alreadyAddedList.add(list.get(n));
rebuildAlreadyAddedWidget();
// unselect added person
users.getSelectionModel().setSelected(list.get(n), false);
// clear search
searchBox.getTextBox().setText("");
}
}));
request.addSecurityTeamAdmin(securityTeam, list.get(i));
}
}
}
});
// if some text has been searched before
if (!searchString.equals("")) {
searchBox.getTextBox().setText(searchString);
startSearching(searchString);
}
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(users, table, addButton);
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
// add menu and the table to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(alreadyAdded);
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers in project perun by CESNET.
the class AddGroupManagerTabItem method draw.
public Widget draw() {
titleWidget.setText("Add manager");
// MAIN PANEL
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// if members or admins group, hide
if (group.isCoreGroup()) {
vp.add(new HTML("<p>Group \"" + group.getName() + "\" can't have managers managed from Group manager section. Please use VO manager section.</p>"));
this.contentWidget.setWidget(vp);
return getWidget();
}
final CustomButton searchButton = new CustomButton("Search", ButtonTranslation.INSTANCE.searchUsers(), SmallIcons.INSTANCE.findIcon());
this.users = new FindCompleteRichUsers("", null, JsonCallbackEvents.disableButtonEvents(searchButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// if found 1 item, select
ArrayList<User> list = JsonUtils.jsoAsList(jso);
if (list != null && list.size() == 1) {
users.getSelectionModel().setSelected(list.get(0), true);
}
}
}));
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(UiElements.getRefreshButton(this));
// get the table
final CellTable<User> table;
if (session.isPerunAdmin()) {
table = users.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
});
} else {
table = users.getTable();
}
final TabItem tab = this;
// already added
rebuildAlreadyAddedWidget();
// search textbox
final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {
@Override
public void searchFor(String text) {
startSearching(text);
searchString = text;
}
}, searchButton);
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersToGroup());
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
final ArrayList<User> list = users.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i = 0; i < list.size(); i++) {
final int n = i;
AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// put names to already added
alreadyAddedList.add(list.get(n));
rebuildAlreadyAddedWidget();
// unselect added person
users.getSelectionModel().setSelected(list.get(n), false);
// clear search
searchBox.getTextBox().setText("");
}
}));
request.addGroupAdmin(group, list.get(i));
}
}
}
});
tabMenu.addWidget(addButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
}));
// if some text has been searched before
if (!searchString.equals("")) {
searchBox.getTextBox().setText(searchString);
startSearching(searchString);
}
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(users, table, addButton);
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
// add menu and the table to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(alreadyAdded);
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers in project perun by CESNET.
the class AddFacilityManagerTabItem method draw.
public Widget draw() {
titleWidget.setText("Add manager");
final CustomButton searchButton = new CustomButton("Search", ButtonTranslation.INSTANCE.searchUsers(), SmallIcons.INSTANCE.findIcon());
this.users = new FindCompleteRichUsers("", null, JsonCallbackEvents.disableButtonEvents(searchButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// if found 1 item, select
ArrayList<User> list = JsonUtils.jsoAsList(jso);
if (list != null && list.size() == 1) {
users.getSelectionModel().setSelected(list.get(0), true);
}
}
}));
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu tabMenu = new TabMenu();
// get the table
final CellTable<User> table;
if (session.isPerunAdmin()) {
table = users.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
});
} else {
table = users.getTable();
}
final TabItem tab = this;
// already added
rebuildAlreadyAddedWidget();
// search textbox
final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {
@Override
public void searchFor(String text) {
startSearching(text);
searchString = text;
}
}, searchButton);
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersToFacility());
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<User> list = users.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// proceed
for (int i = 0; i < list.size(); i++) {
final int n = i;
AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// put names to already added
alreadyAddedList.add(list.get(n));
rebuildAlreadyAddedWidget();
// unselect added person
users.getSelectionModel().setSelected(list.get(n), false);
// clear search
searchBox.getTextBox().setText("");
}
}));
request.addFacilityAdmin(facility, list.get(i));
}
}
}
});
tabMenu.addWidget(addButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
}));
// if some text has been searched before
if (!searchString.equals("")) {
searchBox.getTextBox().setText(searchString);
startSearching(searchString);
}
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
// add menu and the table to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(alreadyAdded);
firstTabPanel.add(sp);
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(users, table, addButton);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers 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, isRefreshParentOnClose());
}
}));
// 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, true));
} 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();
}
use of cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers in project perun by CESNET.
the class UsersTabItem method draw.
public Widget draw() {
CustomButton searchButton = new CustomButton("Search", ButtonTranslation.INSTANCE.searchUsers(), SmallIcons.INSTANCE.findIcon());
this.users = new FindCompleteRichUsers("", null, JsonCallbackEvents.disableButtonEvents(searchButton));
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu tabMenu = new TabMenu();
// search textbox
ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {
@Override
public void searchFor(String text) {
startSearching(text);
searchString = text;
}
}, searchButton);
// get the table
final CellTable<User> table = users.getTable(new FieldUpdater<User, String>() {
public void update(int index, User object, String value) {
// opens the tab
session.getTabManager().addTab(new UserDetailTabItem(object));
}
});
// if some text has been searched before
if (!searchString.equals("")) {
searchBox.getTextBox().setText(searchString);
startSearching(searchString);
}
/*
Button b1 = tabMenu.addButton("List all", SmallIcons.INSTANCE.userGrayIcon(), new ClickHandler(){
public void onClick(ClickEvent event) {
GetCompleteRichUsers callback = new GetCompleteRichUsers(new JsonCallbackEvents(){
public void onLoadingStart() {
table.setEmptyTableWidget(new AjaxLoaderImage().loadingStart());
}
public void onFinished(JavaScriptObject jso) {
users.setList(JsonUtils.<User>jsoAsList(jso));
users.sortTable();
table.setEmptyTableWidget(new AjaxLoaderImage().loadingFinished());
}
public void onError(PerunError error){
users.clearTable();
table.setEmptyTableWidget(new AjaxLoaderImage().loadingError(error));
}
});
callback.retrieveData();
}
});
b1.setTitle("List of all users in Perun");
*/
final CustomButton withoutVoButton = new CustomButton(ButtonTranslation.INSTANCE.listUsersWithoutVoButton(), ButtonTranslation.INSTANCE.listUsersWithoutVo(), SmallIcons.INSTANCE.userRedIcon());
withoutVoButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
GetCompleteRichUsers callback = new GetCompleteRichUsers(null, new JsonCallbackEvents() {
public void onLoadingStart() {
users.clearTable();
table.setEmptyTableWidget(new AjaxLoaderImage().loadingStart());
withoutVoButton.setProcessing(true);
}
public void onFinished(JavaScriptObject jso) {
users.setList(JsonUtils.<User>jsoAsList(jso));
users.sortTable();
table.setEmptyTableWidget(new AjaxLoaderImage().loadingFinished());
withoutVoButton.setProcessing(false);
}
public void onError(PerunError error) {
table.setEmptyTableWidget(new AjaxLoaderImage().loadingError(error));
withoutVoButton.setProcessing(false);
}
});
callback.getWithoutVo(true);
callback.retrieveData();
}
});
tabMenu.addWidget(withoutVoButton);
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
// add menu and the table to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
Aggregations