Search in sources :

Example 11 with User

use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.

the class MemberSponsoredUsersTabItem method draw.

public Widget draw() {
    if (member.getUser().isSponsoredUser()) {
        this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(member.getUser().getFullNameWithTitles().trim()) + ": sponsors");
    } else {
        this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(member.getUser().getFullNameWithTitles().trim()) + ": sponsored users");
    }
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // MENU
    TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    menu.addWidget(UiElements.getRefreshButton(this));
    if (member.getUser().isSponsoredUser()) {
        // request
        final GetUsersBySpecificUser request = new GetUsersBySpecificUser(member.getUserId());
        request.setCheckable(false);
        // table
        CellTable<User> table;
        if (session.isPerunAdmin()) {
            table = request.getTable(new FieldUpdater<User, String>() {

                public void update(int i, User user, String s) {
                    session.getTabManager().addTab(new UserDetailTabItem(user));
                }
            });
        } else {
            table = request.getTable();
        }
        table.addStyleName("perun-table");
        table.setWidth("100%");
        ScrollPanel sp = new ScrollPanel(table);
        sp.addStyleName("perun-tableScrollPanel");
        vp.add(sp);
    } else {
        final GetSpecificUsersByUser request = new GetSpecificUsersByUser(member.getUserId());
        request.setCheckable(false);
        request.setHideService(true);
        // table
        CellTable<User> table;
        if (session.isPerunAdmin()) {
            table = request.getTable(new FieldUpdater<User, String>() {

                public void update(int i, User user, String s) {
                    session.getTabManager().addTab(new UserDetailTabItem(user));
                }
            });
        } else {
            table = request.getTable();
        }
        table.addStyleName("perun-table");
        table.setWidth("100%");
        ScrollPanel sp = new ScrollPanel(table);
        sp.addStyleName("perun-tableScrollPanel");
        vp.add(sp);
    }
    contentWidget.setWidget(vp);
    return getWidget();
}
Also used : VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) GetUsersBySpecificUser(cz.metacentrum.perun.webgui.json.usersManager.GetUsersBySpecificUser) User(cz.metacentrum.perun.webgui.model.User) GetSpecificUsersByUser(cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser) GetSpecificUsersByUser(cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) GetUsersBySpecificUser(cz.metacentrum.perun.webgui.json.usersManager.GetUsersBySpecificUser) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu)

Example 12 with User

use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.

the class VoManagersTabItem method fillContentUsers.

private Widget fillContentUsers(final GetRichAdminsWithAttributes admins, TabMenu menu) {
    admins.clearTableSelectedSet();
    // refresh
    menu.addWidget(0, UiElements.getRefreshButton(this));
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(admins);
    CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerToVo(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddVoManagerTabItem(vo), true);
        }
    });
    if (!session.isVoAdmin(voId))
        addButton.setEnabled(false);
    menu.addWidget(1, addButton);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerFromVo());
    menu.addWidget(2, removeButton);
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<User> adminsForRemoving = admins.getTableSelectedList();
            String text = "Following users won't be VO managers anymore.";
            UiElements.showDeleteConfirm(adminsForRemoving, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < adminsForRemoving.size(); i++) {
                        RemoveAdmin request;
                        if (i == adminsForRemoving.size() - 1) {
                            request = new RemoveAdmin(PerunEntity.VIRTUAL_ORGANIZATION, JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new RemoveAdmin(PerunEntity.VIRTUAL_ORGANIZATION, JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.removeVoAdmin(vo, adminsForRemoving.get(i));
                    }
                }
            });
        }
    });
    // get the table
    CellTable<User> table;
    if (session.isPerunAdmin()) {
        table = admins.getTable(new FieldUpdater<User, String>() {

            public void update(int i, User user, String s) {
                session.getTabManager().addTab(new UserDetailTabItem(user));
            }
        });
    } else {
        table = admins.getTable();
    }
    // add a class to the table and wrap it into scroll panel
    table.addStyleName("perun-table");
    removeButton.setEnabled(false);
    if (session.isVoAdmin(voId))
        JsonUtils.addTableManagedButton(admins, table, removeButton);
    return table;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)

Example 13 with User

use of cz.metacentrum.perun.webgui.model.User 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, !alreadyAddedList.isEmpty());
        }
    }));
    // 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();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FindCompleteRichUsers(cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers) ArrayList(java.util.ArrayList) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) AddAdmin(cz.metacentrum.perun.webgui.json.authzResolver.AddAdmin) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 14 with User

use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.

the class AddAuthorTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add author");
    this.users = new FindCompleteRichUsers("", null);
    // MAIN TAB PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // PUB-INFO
    TabMenu info = new TabMenu();
    info.addWidget(new HTML("<strong>FULL&nbsp;CITE: </strong>" + publication.getMain()));
    firstTabPanel.add(info);
    // 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 index, User object, String value) {
                session.getTabManager().addTab(new UserDetailTabItem(object));
            }
        });
    } else {
        table = users.getTable();
    }
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, "Add selected user(s) as author(s) of publication: " + publication.getTitle());
    tabMenu.addWidget(addButton);
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(users, table, addButton);
    final TabItem tab = this;
    addButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            ArrayList<User> list = users.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                // proceed
                for (int i = 0; i < list.size(); i++) {
                    final String name = list.get(i).getFullNameWithTitles();
                    // add name events
                    JsonCallbackEvents authorshipEvents = new JsonCallbackEvents() {

                        public void onFinished(JavaScriptObject jso) {
                            updateAlreadyAdded(name);
                        }
                    };
                    // merge with refresh?
                    if (i == list.size() - 1 && events != null) {
                        authorshipEvents = JsonCallbackEvents.mergeEvents(authorshipEvents, events);
                    }
                    // call
                    CreateAuthorship request = new CreateAuthorship(JsonCallbackEvents.disableButtonEvents(addButton, authorshipEvents));
                    request.createAuthorship(publicationId, list.get(i).getId());
                    if (i == list.size() - 1) {
                        users.clearTableSelectedSet();
                    }
                }
            }
        }
    });
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // trigger refresh of sub-tab via event
            events.onFinished(null);
            session.getTabManager().closeTab(tab, false);
        }
    }));
    tabMenu.addSearchWidget(new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            users.searchFor(text);
            searchString = text;
        }
    }, ButtonTranslation.INSTANCE.searchUsers());
    // 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 to the main panel
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    // add already added
    firstTabPanel.add(alreadyAddedAuthors);
    firstTabPanel.setCellHeight(alreadyAddedAuthors, "30px");
    // add table to the main panel
    firstTabPanel.add(sp);
    // do not resize like perun table to prevent wrong width in inner tab
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CreateAuthorship(cz.metacentrum.perun.webgui.json.cabinetManager.CreateAuthorship) FindCompleteRichUsers(cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 15 with User

use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.

the class FacilityBlacklistTabItem method draw.

public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Blacklist");
    // main panel
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    final GetBlacklistWithDescription securityTeams = new GetBlacklistWithDescription(PerunEntity.FACILITY, facilityId);
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    menu.addFilterWidget(new ExtendedSuggestBox(securityTeams.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            securityTeams.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterSecurityTeam());
    CellTable<Pair<User, String>> table;
    if (session.isPerunAdmin() || session.isSecurityAdmin()) {
        table = securityTeams.getTable(new FieldUpdater<Pair<User, String>, String>() {

            @Override
            public void update(int index, Pair<User, String> object, String value) {
                session.getTabManager().addTab(new UserDetailTabItem(object.getLeft()));
            }
        });
    } else {
        table = securityTeams.getTable();
    }
    // 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(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    firstTabPanel.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) GetBlacklistWithDescription(cz.metacentrum.perun.webgui.json.securityTeamsManager.GetBlacklistWithDescription) Pair(cz.metacentrum.perun.webgui.model.Pair)

Aggregations

User (cz.metacentrum.perun.webgui.model.User)48 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)22 ArrayList (java.util.ArrayList)20 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)19 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)19 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)18 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)18 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)17 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)15 UserDetailTabItem (cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem)15 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)13 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)9 FindCompleteRichUsers (cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers)8 Attribute (cz.metacentrum.perun.webgui.model.Attribute)6 PerunError (cz.metacentrum.perun.webgui.model.PerunError)6 FindUsersByIdsNotInRpc (cz.metacentrum.perun.webgui.json.usersManager.FindUsersByIdsNotInRpc)5 GetSpecificUsersByUser (cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser)5 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)4 AddAdmin (cz.metacentrum.perun.webgui.json.authzResolver.AddAdmin)4 RemoveAdmin (cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)4