Search in sources :

Example 21 with FieldUpdater

use of com.google.gwt.cell.client.FieldUpdater in project perun by CESNET.

the class CreateFacilityTabItem method fillContentUsers.

private Widget fillContentUsers(final GetRichAdminsWithAttributes jsonCallback, TabMenu menu) {
    jsonCallback.clearTableSelectedSet();
    // get the table
    CellTable<User> table;
    if (session.isPerunAdmin()) {
        table = jsonCallback.getTable(new FieldUpdater<User, String>() {

            @Override
            public void update(int i, User user, String s) {
                session.getTabManager().addTab(new UserDetailTabItem(user));
            }
        });
    } else {
        table = jsonCallback.getTable();
    }
    menu.addWidget(0, TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerToFacility(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddFacilityManagerTabItem(facility), true);
        }
    }));
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerFromFacility());
    menu.addWidget(1, removeButton);
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<User> list = jsonCallback.getTableSelectedList();
            String text = "Following users won't be facility managers anymore and won't be able to manage this facility in Perun.";
            UiElements.showDeleteConfirm(list, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < list.size(); i++) {
                        if (i == list.size() - 1) {
                            RemoveAdmin request = new RemoveAdmin(PerunEntity.FACILITY, JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(jsonCallback)));
                            request.removeFacilityAdmin(facility, list.get(i));
                        } else {
                            RemoveAdmin request = new RemoveAdmin(PerunEntity.FACILITY, JsonCallbackEvents.disableButtonEvents(removeButton));
                            request.removeFacilityAdmin(facility, list.get(i));
                        }
                    }
                }
            });
        }
    });
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(jsonCallback, table, removeButton);
    table.addStyleName("perun-table");
    return table;
}
Also used : FieldUpdater(com.google.gwt.cell.client.FieldUpdater) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) ArrayList(java.util.ArrayList)

Example 22 with FieldUpdater

use of com.google.gwt.cell.client.FieldUpdater in project perun by CESNET.

the class SelfSponsoredUsersTabItem method draw.

@Override
public Widget draw() {
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    if (user.isSponsoredUser()) {
        // SERVICE TYPE user
        this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": Sponsors");
        // request
        final GetUsersBySpecificUser request = new GetUsersBySpecificUser(userId);
        // menu
        TabMenu menu = new TabMenu();
        vp.add(menu);
        vp.setCellHeight(menu, "30px");
        menu.addWidget(UiElements.getRefreshButton(this));
        // 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 SelfDetailTabItem(user));
                }
            });
        } else {
            table = request.getTable();
        }
        table.addStyleName("perun-table");
        table.setWidth("100%");
        ScrollPanel sp = new ScrollPanel(table);
        sp.addStyleName("perun-tableScrollPanel");
        vp.add(sp);
        session.getUiElements().resizePerunTable(sp, 350, this);
    } else {
        // PERSON TYPE user
        this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": Sponsored users");
        // request
        final GetSpecificUsersByUser request = new GetSpecificUsersByUser(userId);
        request.setHideService(true);
        // menu
        TabMenu menu = new TabMenu();
        vp.add(menu);
        vp.setCellHeight(menu, "30px");
        menu.addWidget(UiElements.getRefreshButton(this));
        // 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 SelfDetailTabItem(user));
                }
            });
        } else {
            table = request.getTable();
        }
        table.addStyleName("perun-table");
        table.setWidth("100%");
        ScrollPanel sp = new ScrollPanel(table);
        sp.addStyleName("perun-tableScrollPanel");
        vp.add(sp);
        session.getUiElements().resizePerunTable(sp, 350, this);
    }
    contentWidget.setWidget(vp);
    return getWidget();
}
Also used : VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) GetUsersBySpecificUser(cz.metacentrum.perun.webgui.json.usersManager.GetUsersBySpecificUser) GetSpecificUsersByUser(cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser) GetSpecificUsersByUser(cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser) GetUsersBySpecificUser(cz.metacentrum.perun.webgui.json.usersManager.GetUsersBySpecificUser) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu)

Example 23 with FieldUpdater

use of com.google.gwt.cell.client.FieldUpdater in project perun by CESNET.

the class AddUserToBlacklistTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add to blacklist");
    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.addSelectedUsersToBlacklist());
    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)) {
                FlexTable layout = new FlexTable();
                layout.setStyleName("inputFormFlexTable");
                final TextArea textArea = new TextArea();
                textArea.setSize("250px", "120px");
                layout.getFlexCellFormatter().addStyleName(0, 0, "itemName");
                layout.setHTML(0, 0, "Reason:");
                layout.setWidget(1, 0, textArea);
                layout.setHTML(2, 0, "Please specify why users are blacklisted.");
                layout.getFlexCellFormatter().addStyleName(2, 0, "inputFormInlineComment");
                Confirm c = new Confirm("Add user(s) to blacklist", layout, new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent event) {
                        for (int i = 0; i < list.size(); i++) {
                            // FIXME - Should have only one callback to core
                            final int n = i;
                            AddUserToBlacklist request = new AddUserToBlacklist(securityTeamId, 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.addUserToBlacklist(list.get(i).getId(), textArea.getText().trim());
                        }
                    }
                }, "Add", true);
                c.show();
            }
        }
    });
    // 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();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) AddUserToBlacklist(cz.metacentrum.perun.webgui.json.securityTeamsManager.AddUserToBlacklist) FindCompleteRichUsers(cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers) ArrayList(java.util.ArrayList) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) 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 24 with FieldUpdater

use of com.google.gwt.cell.client.FieldUpdater in project perun by CESNET.

the class SecurityTeamBlacklistTabItem method draw.

public Widget draw() {
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(securityTeam.getName()) + ": " + "blacklist");
    // Get vos request
    final GetBlacklistWithDescription teams = new GetBlacklistWithDescription(PerunEntity.SECURITY_TEAM, securityTeamId);
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(teams);
    TabMenu tabMenu = new TabMenu();
    // add menu to the main panel
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    // do not display to sec admins only
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addUsersToBlacklist(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddUserToBlacklistTabItem(securityTeam), true);
        }
    }));
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, buttonTranslation.removeSelectedUsersFromBlacklist());
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<Pair<User, String>> itemsToRemove = teams.getTableSelectedList();
            UiElements.showDeleteConfirm(itemsToRemove, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < itemsToRemove.size(); i++) {
                        RemoveUserFromBlacklist request;
                        if (i == itemsToRemove.size() - 1) {
                            request = new RemoveUserFromBlacklist(securityTeamId, JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new RemoveUserFromBlacklist(securityTeamId, JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.removeUserFromBlacklist(itemsToRemove.get(i).getLeft().getId());
                    }
                }
            });
        }
    });
    tabMenu.addWidget(removeButton);
    // filter
    tabMenu.addFilterWidget(new ExtendedSuggestBox(teams.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            teams.filterTable(text);
        }
    }, buttonTranslation.filterBlacklist());
    final TabItem tab = this;
    CellTable<Pair<User, String>> table;
    if (session.isPerunAdmin()) {
        // get the table with custom onclick
        table = teams.getTable(new FieldUpdater<Pair<User, String>, String>() {

            @Override
            public void update(int i, Pair<User, String> pair, String string) {
                session.getTabManager().addTab(new UserDetailTabItem(pair.getLeft()));
                session.getTabManager().closeTab(tab, false);
            }
        });
    } else {
        table = teams.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 the table to the main panel
    firstTabPanel.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, 0, 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) ArrayList(java.util.ArrayList) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) RemoveUserFromBlacklist(cz.metacentrum.perun.webgui.json.securityTeamsManager.RemoveUserFromBlacklist) 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) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) GetBlacklistWithDescription(cz.metacentrum.perun.webgui.json.securityTeamsManager.GetBlacklistWithDescription) Pair(cz.metacentrum.perun.webgui.model.Pair)

Example 25 with FieldUpdater

use of com.google.gwt.cell.client.FieldUpdater in project perun by CESNET.

the class SecurityTeamMembersTabItem method draw.

public Widget draw() {
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(securityTeam.getName()) + ": " + "members");
    // Get vos request
    final GetAdmins teams = new GetAdmins(PerunEntity.SECURITY_TEAM, securityTeamId);
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(teams);
    TabMenu tabMenu = new TabMenu();
    // add menu to the main panel
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    // do not display to sec admins only
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addMemberToSecurityTeam(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddSecurityTeamManagerTabItem(securityTeam), true);
        }
    }));
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, buttonTranslation.removeMemberOfSecurityTeam());
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<User> itemsToRemove = teams.getTableSelectedList();
            UiElements.showDeleteConfirm(itemsToRemove, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < itemsToRemove.size(); i++) {
                        RemoveAdmin request;
                        if (i == itemsToRemove.size() - 1) {
                            request = new RemoveAdmin(PerunEntity.SECURITY_TEAM, JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new RemoveAdmin(PerunEntity.SECURITY_TEAM, JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.removeSecurityTeamAdmin(securityTeam, itemsToRemove.get(i));
                    }
                }
            });
        }
    });
    tabMenu.addWidget(removeButton);
    final TabItem tab = this;
    CellTable<User> table;
    if (session.isPerunAdmin()) {
        // get the table with custom onclick
        table = teams.getTable(new FieldUpdater<User, String>() {

            @Override
            public void update(int i, User user, String string) {
                session.getTabManager().addTab(new UserDetailTabItem(user));
                session.getTabManager().closeTab(tab, false);
            }
        });
    } else {
        table = teams.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 the table to the main panel
    firstTabPanel.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, 0, 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) ArrayList(java.util.ArrayList) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) 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) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin) GetAdmins(cz.metacentrum.perun.webgui.json.authzResolver.GetAdmins)

Aggregations

FieldUpdater (com.google.gwt.cell.client.FieldUpdater)28 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)19 ArrayList (java.util.ArrayList)19 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)17 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)17 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)17 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)16 User (cz.metacentrum.perun.webgui.model.User)15 UserDetailTabItem (cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem)15 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)10 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)8 Column (com.google.gwt.user.cellview.client.Column)6 FindCompleteRichUsers (cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers)6 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)6 RemoveAdmin (cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)5 AddAdmin (cz.metacentrum.perun.webgui.json.authzResolver.AddAdmin)4 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)4 CheckboxCell (com.google.gwt.cell.client.CheckboxCell)2 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)2 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)2