Search in sources :

Example 1 with Application

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);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) PerunPrincipal(cz.metacentrum.perun.webgui.model.PerunPrincipal) GetApplicationsForUserForAppFormGui(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForUserForAppFormGui) PerunError(cz.metacentrum.perun.webgui.model.PerunError) Application(cz.metacentrum.perun.webgui.model.Application)

Example 2 with Application

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();
}
Also used : GetApplicationsForUser(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForUser) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) Application(cz.metacentrum.perun.webgui.model.Application)

Example 3 with Application

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();
}
Also used : Application(cz.metacentrum.perun.webgui.model.Application)

Example 4 with Application

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();
}
Also used : Application(cz.metacentrum.perun.webgui.model.Application)

Example 5 with Application

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();
}
Also used : Application(cz.metacentrum.perun.webgui.model.Application)

Aggregations

Application (cz.metacentrum.perun.webgui.model.Application)20 Column (com.google.gwt.user.cellview.client.Column)5 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)5 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)5 CustomClickableTextCell (cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell)5 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)4 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)4 Cell (com.google.gwt.cell.client.Cell)3 ClickableTextCell (com.google.gwt.cell.client.ClickableTextCell)3 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)3 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)3 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)3 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)3 HandleApplication (cz.metacentrum.perun.webgui.json.registrarManager.HandleApplication)3 ApplicationDetailTabItem (cz.metacentrum.perun.webgui.tabs.registrartabs.ApplicationDetailTabItem)3 PerunAppTypeCell (cz.metacentrum.perun.webgui.widgets.cells.PerunAppTypeCell)3 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1