Search in sources :

Example 6 with FindCompleteRichUsers

use of cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers 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();
}
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 7 with FindCompleteRichUsers

use of cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers in project perun by CESNET.

the class UsersTabItem method draw.

public Widget draw() {
    CustomButton searchButton = new CustomButton("Search", ButtonTranslation.INSTANCE.searchUsers(), SmallIcons.INSTANCE.findIcon());
    this.users = new FindCompleteRichUsers("", null, JsonCallbackEvents.disableButtonEvents(searchButton));
    // MAIN TAB PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu tabMenu = new TabMenu();
    // search textbox
    ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            startSearching(text);
            searchString = text;
        }
    }, searchButton);
    // get the table
    final CellTable<User> table = users.getTable(new FieldUpdater<User, String>() {

        public void update(int index, User object, String value) {
            // opens the tab
            session.getTabManager().addTab(new UserDetailTabItem(object));
        }
    });
    // if some text has been searched before
    if (!searchString.equals("")) {
        searchBox.getTextBox().setText(searchString);
        startSearching(searchString);
    }
    /*
			 Button b1 = tabMenu.addButton("List all", SmallIcons.INSTANCE.userGrayIcon(), new ClickHandler(){
			 public void onClick(ClickEvent event) {
			 GetCompleteRichUsers callback = new GetCompleteRichUsers(new JsonCallbackEvents(){
			 public void onLoadingStart() {
			 table.setEmptyTableWidget(new AjaxLoaderImage().loadingStart());
			 }
			 public void onFinished(JavaScriptObject jso) {
			 users.setList(JsonUtils.<User>jsoAsList(jso));
			 users.sortTable();
			 table.setEmptyTableWidget(new AjaxLoaderImage().loadingFinished());
			 }
			 public void onError(PerunError error){
			 users.clearTable();
			 table.setEmptyTableWidget(new AjaxLoaderImage().loadingError(error));
			 }
			 });
			 callback.retrieveData();
			 }
			 });
			 b1.setTitle("List of all users in Perun");
			 */
    final CustomButton withoutVoButton = new CustomButton(ButtonTranslation.INSTANCE.listUsersWithoutVoButton(), ButtonTranslation.INSTANCE.listUsersWithoutVo(), SmallIcons.INSTANCE.userRedIcon());
    withoutVoButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            GetCompleteRichUsers callback = new GetCompleteRichUsers(null, new JsonCallbackEvents() {

                public void onLoadingStart() {
                    users.clearTable();
                    table.setEmptyTableWidget(new AjaxLoaderImage().loadingStart());
                    withoutVoButton.setProcessing(true);
                }

                public void onFinished(JavaScriptObject jso) {
                    users.setList(JsonUtils.<User>jsoAsList(jso));
                    users.sortTable();
                    table.setEmptyTableWidget(new AjaxLoaderImage().loadingFinished());
                    withoutVoButton.setProcessing(false);
                }

                public void onError(PerunError error) {
                    table.setEmptyTableWidget(new AjaxLoaderImage().loadingError(error));
                    withoutVoButton.setProcessing(false);
                }
            });
            callback.getWithoutVo(true);
            callback.retrieveData();
        }
    });
    tabMenu.addWidget(withoutVoButton);
    // 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(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) User(cz.metacentrum.perun.webgui.model.User) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FindCompleteRichUsers(cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) PerunError(cz.metacentrum.perun.webgui.model.PerunError) GetCompleteRichUsers(cz.metacentrum.perun.webgui.json.usersManager.GetCompleteRichUsers)

Example 8 with FindCompleteRichUsers

use of cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers 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)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)8 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)8 FindCompleteRichUsers (cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers)8 User (cz.metacentrum.perun.webgui.model.User)8 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)8 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)8 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)7 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)7 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)7 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)7 ArrayList (java.util.ArrayList)7 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)6 UserDetailTabItem (cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem)6 AddAdmin (cz.metacentrum.perun.webgui.json.authzResolver.AddAdmin)4 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)3 CreateAuthorship (cz.metacentrum.perun.webgui.json.cabinetManager.CreateAuthorship)1 AddUserToBlacklist (cz.metacentrum.perun.webgui.json.securityTeamsManager.AddUserToBlacklist)1 AddSpecificUserOwner (cz.metacentrum.perun.webgui.json.usersManager.AddSpecificUserOwner)1 GetCompleteRichUsers (cz.metacentrum.perun.webgui.json.usersManager.GetCompleteRichUsers)1 PerunError (cz.metacentrum.perun.webgui.model.PerunError)1