use of cz.metacentrum.perun.webgui.model.Application in project perun by CESNET.
the class UsersApplicationsPage method refresh.
/**
* Refresh the page
*/
private void refresh() {
bodyContents.clear();
String user = "";
if (session.getUser() != null) {
user = this.session.getUser().getFullNameWithTitles().trim();
} else {
PerunPrincipal pp = session.getPerunPrincipal();
if (!pp.getAdditionInformations("displayName").equals("")) {
user = pp.getAdditionInformations("displayName");
} else if (!pp.getAdditionInformations("cn").equals("")) {
user = pp.getAdditionInformations("cn");
} else {
if (pp.getExtSourceType().equals("cz.metacentrum.perun.core.impl.ExtSourceX509")) {
user = Utils.convertCertCN(pp.getActor());
} else {
user = pp.getActor();
}
}
}
bodyContents.add(new HTML("<h1>" + ApplicationMessages.INSTANCE.applicationsForUser(user) + "</h1>"));
// callback
int userId = 0;
if (session.getUser() != null) {
userId = session.getUser().getId();
}
final GetApplicationsForUserForAppFormGui req = new GetApplicationsForUserForAppFormGui(userId);
final ListBox listBox = new ListBox();
req.setEvents(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
ArrayList<Application> appls = JsonUtils.jsoAsList(jso);
ArrayList<String> vos = new ArrayList<String>();
for (Application app : appls) {
if (!vos.contains(app.getVo().getName())) {
vos.add(app.getVo().getName());
}
}
Collections.sort(vos);
for (String s : vos) {
listBox.addItem(s);
}
if (listBox.getItemCount() > 0) {
listBox.insertItem(WidgetTranslation.INSTANCE.listboxAll(), 0);
}
for (int i = 0; i < listBox.getItemCount(); i++) {
if (listBox.getItemText(i).equals(ApplicationFormGui.getVo().getName())) {
listBox.setSelectedIndex(i);
req.filterTable(ApplicationFormGui.getVo().getName());
break;
}
}
}
@Override
public void onError(PerunError error) {
}
@Override
public void onLoadingStart() {
listBox.clear();
}
});
req.setCheckable(false);
listBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
if (listBox.getSelectedIndex() > 0) {
req.filterTable(listBox.getItemText(listBox.getSelectedIndex()));
} else {
// show all
req.filterTable("");
}
}
});
final TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(new HTML("<strong>" + ApplicationMessages.INSTANCE.filterByVo() + ":</strong>"));
tabMenu.addWidget(listBox);
tabMenu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
tabMenu.addWidget(new HTML("<strong>" + ApplicationMessages.INSTANCE.clickOnApplicationToSee() + "</strong>"));
tabMenu.addStyleName("tabMenu");
final VerticalPanel applicationsWrapper = new VerticalPanel();
applicationsWrapper.setSize("100%", "100%");
applicationsWrapper.add(tabMenu);
final CellTable<Application> appsTable = req.getTable(new FieldUpdater<Application, String>() {
public void update(int index, Application object, String value) {
applicationsWrapper.clear();
applicationsWrapper.add(backButton);
applicationsWrapper.add(getApplicationDetailWidget(object));
}
});
appsTable.addStyleName("perun-table");
applicationsWrapper.add(appsTable);
backButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
applicationsWrapper.clear();
applicationsWrapper.add(tabMenu);
applicationsWrapper.add(appsTable);
}
});
bodyContents.add(applicationsWrapper);
}
use of cz.metacentrum.perun.webgui.model.Application in project perun by CESNET.
the class SelfApplicationsTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": Applications");
VerticalPanel bodyContents = new VerticalPanel();
bodyContents.setWidth("100%");
// callback
final GetApplicationsForUser req = new GetApplicationsForUser(user.getId());
req.setCheckable(false);
// tab menu for filtering
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(UiElements.getRefreshButton(this));
tabMenu.addFilterWidget(new ExtendedSuggestBox(req.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
req.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterByVoOrGroup());
bodyContents.add(tabMenu);
CellTable<Application> appsTable = req.getTable(new FieldUpdater<Application, String>() {
@Override
public void update(int index, Application object, String value) {
session.getTabManager().addTab(new SelfApplicationDetailTabItem(object));
}
});
appsTable.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(appsTable);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(sp, 350, this);
bodyContents.add(sp);
this.contentWidget.setWidget(bodyContents);
return getWidget();
}
use of cz.metacentrum.perun.webgui.model.Application in project perun by CESNET.
the class GetApplicationsForMember method filterTable.
public void filterTable(String filter) {
// store list only for first time
if (backupList.isEmpty() || backupList == null) {
backupList.addAll(list);
}
// always clear selected items
selectionModel.clear();
list.clear();
if (filter.equalsIgnoreCase("")) {
list.addAll(backupList);
} else {
for (Application app : backupList) {
// store app by filter
if (app.getGroup() != null) {
if (app.getGroup().getName().toLowerCase().startsWith(filter.toLowerCase())) {
list.add(app);
}
}
}
}
if (list.isEmpty() && !filter.isEmpty()) {
// filtering is on groups only
loaderImage.setEmptyResultMessage("No member's applications for group matching '" + filter + "' found.");
} else {
if (groupId == 0) {
loaderImage.setEmptyResultMessage("No member's applications found for this VO or it's groups.");
} else {
loaderImage.setEmptyResultMessage("No member's applications found for this group.");
}
}
loaderImage.loadingFinished();
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.Application in project perun by CESNET.
the class GetApplicationsForGroup method filterTable.
public void filterTable(String filter) {
// store list only for first time
if (backupList.isEmpty() || backupList == null) {
backupList.addAll(list);
}
// always clear selected items
selectionModel.clear();
list.clear();
if (filter.equalsIgnoreCase("")) {
list.addAll(backupList);
} else {
for (Application app : backupList) {
// store app by filter
if (app.getUser() != null) {
if (app.getUser().getFullName().toLowerCase().startsWith(filter.toLowerCase())) {
list.add(app);
continue;
} else if (app.getUser().getLastName().toLowerCase().startsWith(filter.toLowerCase())) {
list.add(app);
continue;
} else if (app.getUser().getFirstName().toLowerCase().startsWith(filter.toLowerCase())) {
list.add(app);
continue;
} else if (app.getUser().getMiddleName().toLowerCase().startsWith(filter.toLowerCase())) {
list.add(app);
}
} else {
if (app.getCreatedBy().toLowerCase().startsWith(filter.toLowerCase())) {
list.add(app);
}
}
}
}
if (list.isEmpty() && !filter.isEmpty()) {
loaderImage.setEmptyResultMessage("No applications with username matching '" + filter + "' found for this group.");
} else {
loaderImage.setEmptyResultMessage("No applications matching search criteria found for this group.");
}
dataProvider.flush();
dataProvider.refresh();
loaderImage.loadingFinished();
}
use of cz.metacentrum.perun.webgui.model.Application in project perun by CESNET.
the class GetApplicationsForGroup method setList.
public void setList(ArrayList<Application> list) {
clearTable();
this.list.addAll(list);
for (Application a : list) {
if (a.getUser() != null) {
oracle.add(a.getUser().getFullName());
} else {
oracle.add(Utils.convertCertCN(a.getCreatedBy()));
}
}
dataProvider.flush();
dataProvider.refresh();
}
Aggregations