use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.
the class FindUsers method onFinished.
/**
* Called, when operation finishes successfully.
*/
public void onFinished(JavaScriptObject jso) {
ArrayList<User> list = JsonUtils.jsoAsList(jso);
for (User u : list) {
if (hideService && u.isServiceUser()) {
// if service hidden, skip service users
} else if (hidePerson && !u.isServiceUser() && !u.isSponsoredUser()) {
// if person hidden, skip person
} else if (hideSponsored && !u.isSponsoredUser()) {
// if person hidden, skip person
} else {
addToTable(u);
}
}
sortTable();
loaderImage.loadingFinished();
session.getUiElements().setLogText("Users loaded: " + list.size());
events.onFinished(jso);
}
use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.
the class FindUsersByName method onFinished.
/**
* Called, when operation finishes successfully.
*/
public void onFinished(JavaScriptObject jso) {
for (User u : JsonUtils.<User>jsoAsList(jso)) {
if (excludeService && u.isServiceUser()) {
// skip service
} else if (excludeSponsored && u.isSponsoredUser()) {
// skip sponsored
} else {
addToTable(u);
}
}
sortTable();
session.getUiElements().setLogText("Users loaded: " + list.size());
events.onFinished(jso);
loaderImage.loadingFinished();
}
use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.
the class GetRichUsersWithoutVo method getTable.
/**
* Returns table of users.
* @return
*/
public CellTable<User> getTable() {
// retrieve data
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<User>(list);
// Cell table
table = new PerunTable<User>(list);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<User> columnSortHandler = new ListHandler<User>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<User>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
// columns
table.addCheckBoxColumn();
table.addIdColumn("User ID", tableFieldUpdater);
// NAME COLUMN
Column<User, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {
public String getValue(User user) {
return user.getFullName();
}
}, tableFieldUpdater);
nameColumn.setSortable(true);
columnSortHandler.setComparator(nameColumn, new Comparator<User>() {
public int compare(User o1, User o2) {
return o1.getLastName().compareToIgnoreCase(o2.getLastName());
}
});
// SERVICE COLUMN
Column<User, String> serviceColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {
public String getValue(User user) {
if (user.isServiceUser()) {
return "Service";
} else if (user.isSponsoredUser()) {
return "Sponsored";
} else {
return "Person";
}
}
}, tableFieldUpdater);
serviceColumn.setSortable(true);
columnSortHandler.setComparator(serviceColumn, new Comparator<User>() {
public int compare(User o1, User o2) {
String type1 = "Person";
if (o1.isServiceUser()) {
type1 = "Service";
} else if (o1.isSponsoredUser()) {
type1 = "Sponsored";
}
String type2 = "Person";
if (o2.isServiceUser()) {
type2 = "Service";
} else if (o2.isSponsoredUser()) {
type2 = "Sponsored";
}
return type1.compareTo(type2);
}
});
// Create organization column.
Column<User, String> organizationColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {
public String getValue(User object) {
Attribute at = object.getAttribute("urn:perun:user:attribute-def:def:organization");
if (at != null && at.getValue() != null && !"null".equalsIgnoreCase(at.getValue())) {
return at.getValue();
}
return "";
}
}, this.tableFieldUpdater);
// Create e-mail column.
Column<User, String> emailColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {
public String getValue(User object) {
Attribute at = object.getAttribute("urn:perun:user:attribute-def:def:preferredMail");
if (at != null && at.getValue() != null && !"null".equalsIgnoreCase(at.getValue())) {
return at.getValue().replace(",", " ");
}
return "";
}
}, this.tableFieldUpdater);
// Create name column.
Column<User, String> loginsColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {
public String getValue(User object) {
return object.getUserLogins();
}
}, this.tableFieldUpdater);
organizationColumn.setSortable(true);
columnSortHandler.setComparator(organizationColumn, new RichUserComparator(RichUserComparator.Column.ORGANIZATION));
emailColumn.setSortable(true);
columnSortHandler.setComparator(emailColumn, new RichUserComparator(RichUserComparator.Column.EMAIL));
table.addColumn(nameColumn, "Name");
table.addColumn(organizationColumn, "Organization");
table.addColumn(emailColumn, "E-mail");
table.addColumn(loginsColumn, "Logins");
table.addColumn(serviceColumn, "User type");
return table;
}
use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.
the class AddVoManagerTabItem 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();
}
rebuildAlreadyAddedWidget();
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersToVo());
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, !alreadyAddedList.isEmpty());
}
}));
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.addVoAdmin(vo, 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.model.User in project perun by CESNET.
the class AddVoManagerTabItem method startSearching.
/**
* Starts the search for users
*/
protected void startSearching(String text) {
users.clearTable();
// IS searched string IDs?
if (JsonUtils.isStringWithIds(text)) {
FindUsersByIdsNotInRpc req = new FindUsersByIdsNotInRpc(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
ArrayList<User> usersList = JsonUtils.jsoAsList(jso);
for (User u : usersList) {
users.addToTable(u);
}
}
}, text);
req.retrieveData();
return;
}
users.searchFor(text);
}
Aggregations