Search in sources :

Example 16 with RichMember

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

the class GetCompleteRichMembers method getEmptyTable.

/**
	 * Returns empty table
	 *
	 * @return CellTable widget
	 */
public CellTable<RichMember> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<RichMember>(list);
    // Cell table
    table = new PerunTable<RichMember>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<RichMember> columnSortHandler = new ListHandler<RichMember>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<RichMember>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity)) {
        loaderImage.setEmptyResultMessage("VO has no members.");
    } else {
        loaderImage.setEmptyResultMessage("Group has no members.");
    }
    Column<RichMember, RichMember> checkBoxColumn = new Column<RichMember, RichMember>(new PerunCheckboxCell<RichMember>(true, false, indirectCheckable)) {

        @Override
        public RichMember getValue(RichMember object) {
            // Get the value from the selection model.
            object.setChecked(selectionModel.isSelected(object));
            return object;
        }
    };
    // updates the columns size
    table.setColumnWidth(checkBoxColumn, 40.0, Style.Unit.PX);
    // Add the columns
    // Checkbox column header
    CheckboxCell cb = new CheckboxCell();
    Header<Boolean> checkBoxHeader = new Header<Boolean>(cb) {

        public Boolean getValue() {
            //return true to see a checked checkbox.
            return false;
        }
    };
    checkBoxHeader.setUpdater(new ValueUpdater<Boolean>() {

        public void update(Boolean value) {
            // sets selected to all, if value = true, unselect otherwise
            for (RichMember obj : list) {
                if (!"INDIRECT".equalsIgnoreCase(obj.getMembershipType())) {
                    selectionModel.setSelected(obj, value);
                }
            }
        }
    });
    if (checkable) {
        table.addColumn(checkBoxColumn, checkBoxHeader);
    }
    MemberColumnProvider columnProvider = new MemberColumnProvider(dataProvider, backupList, table, tableFieldUpdater);
    IsClickableCell<RichMember> authz = new IsClickableCell<RichMember>() {

        @Override
        public boolean isClickable(RichMember object) {
            return true;
        }

        @Override
        public String linkUrl(RichMember object) {
            return null;
        }
    };
    columnProvider.addIdColumn(authz, 110);
    columnProvider.addUserIdColumn(authz, 110);
    columnProvider.addStatusColumn(authz, 20);
    columnProvider.addNameColumn(authz);
    columnProvider.addOrganizationColumn(authz);
    columnProvider.addEmailColumn(authz);
    columnProvider.addLoginsColumn(authz);
    return table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) MemberColumnProvider(cz.metacentrum.perun.webgui.json.columnProviders.MemberColumnProvider) RichMember(cz.metacentrum.perun.webgui.model.RichMember) Header(com.google.gwt.user.cellview.client.Header) Column(com.google.gwt.user.cellview.client.Column) IsClickableCell(cz.metacentrum.perun.webgui.json.columnProviders.IsClickableCell) CheckboxCell(com.google.gwt.cell.client.CheckboxCell) PerunCheckboxCell(cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell)

Example 17 with RichMember

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

the class GetGroupRichMembers method getTable.

/**
	 * Returns the table with rich members of group
	 *
	 * @return table widget
	 */
public CellTable<RichMember> getTable() {
    // retrieves data
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<RichMember>(list);
    // Cell table
    table = new PerunTable<RichMember>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<RichMember> columnSortHandler = new ListHandler<RichMember>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // Table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<RichMember>createCheckboxManager());
    // Set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    // Checkbox column column
    table.addCheckBoxColumn();
    // Status column
    Column<RichMember, String> statusColumn = new Column<RichMember, String>(new PerunStatusCell()) {

        @Override
        public String getValue(RichMember object) {
            return object.getStatus();
        }
    };
    // own onClick tab for changing member's status
    statusColumn.setFieldUpdater(new FieldUpdater<RichMember, String>() {

        public void update(int index, final RichMember object, String value) {
            FlexTable widget = new FlexTable();
            final ListBox lb = new ListBox(false);
            lb.addItem("VALID", "VALID");
            lb.addItem("INVALID", "INVALID");
            lb.addItem("SUSPENDED", "SUSPENDED");
            lb.addItem("EXPIRED", "EXPIRED");
            lb.addItem("DISABLED", "DISABLED");
            widget.setHTML(0, 0, "<strong>Status: </strong>");
            widget.setWidget(0, 1, lb);
            // pick which one is already set
            for (int i = 0; i < lb.getItemCount(); i++) {
                if (lb.getItemText(i).equalsIgnoreCase(object.getStatus())) {
                    lb.setSelectedIndex(i);
                }
            }
            Confirm conf = new Confirm("Change member's status: " + object.getUser().getFullName(), widget, true);
            conf.setCancelButtonText("Cancel");
            conf.setOkButtonText("Change status");
            conf.setOkClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    SetStatus call = new SetStatus(object.getId(), new JsonCallbackEvents() {

                        public void onFinished(JavaScriptObject jso) {
                            clearTable();
                            retrieveData();
                        }

                        public void onError(PerunError error) {
                            clearTable();
                            retrieveData();
                        }
                    });
                    call.setStatus(lb.getValue(lb.getSelectedIndex()));
                }
            });
            conf.show();
        }
    });
    // status column sortable
    statusColumn.setSortable(true);
    columnSortHandler.setComparator(statusColumn, new GeneralComparator<RichMember>(GeneralComparator.Column.STATUS));
    table.addColumn(statusColumn, "Status");
    table.setColumnWidth(statusColumn, 20, Unit.PX);
    // Create member ID column.
    Column<RichMember, String> memberIdColumn = JsonUtils.addColumn(new JsonUtils.GetValue<RichMember, String>() {

        public String getValue(RichMember object) {
            return String.valueOf(object.getId());
        }
    }, this.tableFieldUpdater);
    // Create User ID column.
    Column<RichMember, String> userIdColumn = JsonUtils.addColumn(new JsonUtils.GetValue<RichMember, String>() {

        public String getValue(RichMember object) {
            return String.valueOf(object.getUser().getId());
        }
    }, this.tableFieldUpdater);
    columnSortHandler.setComparator(memberIdColumn, new RichMemberComparator(RichMemberComparator.Column.MEMBER_ID));
    memberIdColumn.setSortable(true);
    userIdColumn.setSortable(true);
    columnSortHandler.setComparator(userIdColumn, new RichMemberComparator(RichMemberComparator.Column.USER_ID));
    table.setColumnWidth(memberIdColumn, 110.0, Unit.PX);
    table.setColumnWidth(userIdColumn, 110.0, Unit.PX);
    // headers
    if (JsonUtils.isExtendedInfoVisible()) {
        table.addColumn(memberIdColumn, "Member ID");
        table.addColumn(userIdColumn, "User ID");
    }
    table.addNameColumn(tableFieldUpdater);
    return table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlexTable(com.google.gwt.user.client.ui.FlexTable) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) RichMember(cz.metacentrum.perun.webgui.model.RichMember) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Column(com.google.gwt.user.cellview.client.Column) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) PerunStatusCell(cz.metacentrum.perun.webgui.widgets.cells.PerunStatusCell) SetStatus(cz.metacentrum.perun.webgui.json.membersManager.SetStatus) RichMemberComparator(cz.metacentrum.perun.webgui.json.comparators.RichMemberComparator) PerunError(cz.metacentrum.perun.webgui.model.PerunError) ListBox(com.google.gwt.user.client.ui.ListBox)

Example 18 with RichMember

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

the class AddMemberToGroupTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add member(s)");
    // MAIN PANEL
    final VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    boolean isMembersGroup = group.isCoreGroup();
    // if members or admins group, hide
    if (isMembersGroup) {
        firstTabPanel.add(new HTML("<p>Group \"" + group.getName() + "\" can't have members managed from Group admin. Please use VO admin section.</p>"));
        this.contentWidget.setWidget(firstTabPanel);
        return getWidget();
    }
    // MENU
    TabMenu tabMenu = new TabMenu();
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    // for resize
    final TabItem tab = this;
    // CALLBACKS
    // for both
    final FindCompleteRichMembers findMembers;
    // for both
    final GetCompleteRichMembers getAllMembers;
    // for VO/group admin differs search
    final FindCandidatesOrUsersToAddToVo findCandidatesOrUsersToAddToVo;
    // elements handled by callback events
    final CustomButton searchButton = new CustomButton("Search in VO", ButtonTranslation.INSTANCE.searchMemberInVo(), SmallIcons.INSTANCE.findIcon());
    final CustomButton searchGloballyButton = new CustomButton("Search globally", ButtonTranslation.INSTANCE.searchForMembersInExtSources(), SmallIcons.INSTANCE.findIcon());
    final CustomButton listAllButton = new CustomButton("List all VO members", ButtonTranslation.INSTANCE.listAllMembersInVo(), SmallIcons.INSTANCE.userGreenIcon());
    final CheckBox disabled = new CheckBox(WidgetTranslation.INSTANCE.showDisabledMembers());
    // search through whole VO
    findMembers = new FindCompleteRichMembers(PerunEntity.VIRTUAL_ORGANIZATION, group.getVoId(), "", null);
    getAllMembers = new GetCompleteRichMembers(PerunEntity.VIRTUAL_ORGANIZATION, group.getVoId(), null);
    if (session.isVoAdmin(group.getVoId())) {
        // will search vo ext sources and users
        findCandidatesOrUsersToAddToVo = new FindCandidatesOrUsersToAddToVo(group.getVoId(), 0, "", null);
    } else {
        // will search group ext sources only
        findCandidatesOrUsersToAddToVo = new FindCandidatesOrUsersToAddToVo(group.getVoId(), group.getId(), "", null);
    }
    final CellTable<Candidate> candidatesTable = findCandidatesOrUsersToAddToVo.getEmptyTable();
    final CellTable<RichMember> table = findMembers.getEmptyTable(new FieldUpdater<RichMember, RichMember>() {

        // when user click on a row -> open new tab
        public void update(int index, RichMember object, RichMember value) {
            session.getTabManager().addTab(new MemberDetailTabItem(object.getId(), groupId));
        }
    });
    final CustomButton inviteButton = new CustomButton("Invite selected", SmallIcons.INSTANCE.emailIcon());
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedMemberToGroup());
    final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {

        public void searchFor(String text) {
            searchString = text;
            findMembers.searchFor(searchString);
            search = true;
            searchCandidates = false;
            // remove previous table
            firstTabPanel.getWidget(2).removeFromParent();
            firstTabPanel.add(sp);
            UiElements.runResizeCommands(tab);
        }
    }, searchButton);
    searchBox.getTextBox().setText(searchString);
    // bind text box also to search globally
    searchBox.getTextBox().addKeyUpHandler(new KeyUpHandler() {

        public void onKeyUp(KeyUpEvent event) {
            if (!searchBox.getTextBox().getText().trim().isEmpty()) {
                searchGloballyButton.setEnabled(true);
            // do not trigger search on both !!
            } else {
                searchGloballyButton.setEnabled(false);
            }
        }
    });
    searchBox.getTextBox().addBlurHandler(new BlurHandler() {

        @Override
        public void onBlur(BlurEvent event) {
            // fake some meaningless KeyUpEvent
            DomEvent.fireNativeEvent(Document.get().createKeyUpEvent(false, false, false, false, KeyCodes.KEY_DOWN), searchBox.getTextBox());
        }
    });
    searchBox.getTextBox().addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            // fake some meaningless KeyUpEvent
            DomEvent.fireNativeEvent(Document.get().createKeyUpEvent(false, false, false, false, KeyCodes.KEY_DOWN), searchBox.getTextBox());
        }
    });
    // button click triggers action
    searchGloballyButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            if (UiElements.searchStingCantBeEmpty(searchBox.getTextBox().getText().trim())) {
                new PerunSearchEvent() {

                    public void searchFor(String text) {
                        searchString = text;
                        findCandidatesOrUsersToAddToVo.searchFor(searchString);
                        searchCandidates = true;
                        search = false;
                        // remove previous table
                        firstTabPanel.getWidget(2).removeFromParent();
                        firstTabPanel.add(sp2);
                        UiElements.runResizeCommands(tab);
                    }
                }.searchFor(searchBox.getTextBox().getText().trim());
            }
        }
    });
    searchGloballyButton.setEnabled(false);
    findMembers.setEvents(JsonCallbackEvents.disableButtonEvents(searchButton, new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // if found 1 item, select
            listAllButton.setEnabled(true);
            searchGloballyButton.setEnabled(true);
            searchBox.getTextBox().setEnabled(true);
            ArrayList<RichMember> list = JsonUtils.jsoAsList(jso);
            if (list != null && list.size() == 1) {
                findMembers.getSelectionModel().setSelected(list.get(0), true);
            }
        }

        @Override
        public void onError(PerunError error) {
            listAllButton.setEnabled(true);
            searchGloballyButton.setEnabled(true);
            searchBox.getTextBox().setEnabled(true);
        }

        @Override
        public void onLoadingStart() {
            listAllButton.setEnabled(false);
            searchGloballyButton.setEnabled(false);
            disabled.setVisible(false);
            searchBox.getTextBox().setEnabled(false);
            addButton.setEnabled(false);
            inviteButton.setEnabled(false);
        }
    }));
    getAllMembers.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(listAllButton, JsonCallbackEvents.disableCheckboxEvents(disabled)), new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // pass data to table handling callback
            findMembers.onFinished(jso);
            ((AjaxLoaderImage) table.getEmptyTableWidget()).setEmptyResultMessage("VO has no members.");
            searchButton.setEnabled(true);
            searchBox.getTextBox().setEnabled(true);
        }

        @Override
        public void onError(PerunError error) {
            // pass data to table handling callback
            findMembers.onError(error);
            searchButton.setEnabled(true);
            searchBox.getTextBox().setEnabled(true);
        }

        @Override
        public void onLoadingStart() {
            searchButton.setEnabled(false);
            disabled.setVisible(true);
            searchBox.getTextBox().setEnabled(false);
            addButton.setEnabled(false);
            inviteButton.setEnabled(false);
        }
    }));
    findCandidatesOrUsersToAddToVo.setEvents(JsonCallbackEvents.disableButtonEvents(searchGloballyButton, new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // if found 1 item, select
            listAllButton.setEnabled(true);
            searchButton.setEnabled(true);
            searchBox.getTextBox().setEnabled(true);
            ArrayList<Candidate> list = JsonUtils.jsoAsList(jso);
            if (list != null && list.size() == 1) {
                findCandidatesOrUsersToAddToVo.setSelected(list.get(0));
            }
        }

        @Override
        public void onError(PerunError error) {
            listAllButton.setEnabled(true);
            searchButton.setEnabled(true);
            searchBox.getTextBox().setEnabled(true);
        }

        @Override
        public void onLoadingStart() {
            disabled.setVisible(false);
            listAllButton.setEnabled(false);
            searchButton.setEnabled(false);
            searchBox.getTextBox().setEnabled(false);
            addButton.setEnabled(false);
            inviteButton.setEnabled(false);
        }
    }));
    // DISABLED CHECKBOX
    disabled.setTitle(WidgetTranslation.INSTANCE.showDisabledMembersTitle());
    disabled.setVisible(false);
    // checkbox click handler
    disabled.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            getAllMembers.excludeDisabled(!disabled.getValue());
            findMembers.clearTable();
            getAllMembers.retrieveData();
        }
    });
    listAllButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            search = false;
            searchCandidates = false;
            searchString = "";
            searchBox.getTextBox().setText("");
            findMembers.clearTable();
            findCandidatesOrUsersToAddToVo.clearTable();
            getAllMembers.retrieveData();
            // remove previous table
            firstTabPanel.getWidget(2).removeFromParent();
            firstTabPanel.add(sp);
            UiElements.runResizeCommands(tab);
        }
    });
    // click handler
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (searchCandidates) {
                // searched users or candidates
                Candidate candidateToBeAdded = findCandidatesOrUsersToAddToVo.getSelected();
                if (candidateToBeAdded == null) {
                    UiElements.cantSaveEmptyListDialogBox(null);
                } else {
                    if (candidateToBeAdded.getObjectType().equalsIgnoreCase("Candidate")) {
                        CreateMember request = new CreateMember(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {

                            private Candidate saveSelected;

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                // put names to already added
                                if (saveSelected != null) {
                                    GeneralObject go = saveSelected.cast();
                                    alreadyAddedList.add(go);
                                }
                                findCandidatesOrUsersToAddToVo.clearTableSelectedSet();
                                rebuildAlreadyAddedWidget();
                                // clear search
                                searchBox.getTextBox().setText("");
                            }

                            @Override
                            public void onLoadingStart() {
                                saveSelected = findCandidatesOrUsersToAddToVo.getSelected();
                            }
                        }));
                        request.createMember(group.getVoId(), group, candidateToBeAdded);
                    } else {
                        CreateMember request = new CreateMember(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {

                            private User saveSelected;

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                // put names to already added
                                if (saveSelected != null) {
                                    GeneralObject go = saveSelected.cast();
                                    alreadyAddedList.add(go);
                                    findCandidatesOrUsersToAddToVo.clearTableSelectedSet();
                                    rebuildAlreadyAddedWidget();
                                    // clear search
                                    searchBox.getTextBox().setText("");
                                }
                            }

                            @Override
                            public void onLoadingStart() {
                                Candidate cand = findCandidatesOrUsersToAddToVo.getSelected();
                                saveSelected = cand.cast();
                            }
                        }));
                        User user = candidateToBeAdded.cast();
                        request.createMember(group.getVoId(), group, user);
                    }
                }
            } else {
                // searched members / all members
                final ArrayList<RichMember> membersToAdd = findMembers.getTableSelectedList();
                if (UiElements.cantSaveEmptyListDialogBox(membersToAdd)) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < membersToAdd.size(); i++) {
                        final int n = i;
                        AddMember request = new AddMember(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {

                            private RichMember saveSelected;

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                // unselect added person
                                findMembers.getSelectionModel().setSelected(saveSelected, false);
                                // put names to already added
                                GeneralObject go = saveSelected.cast();
                                alreadyAddedList.add(go);
                                rebuildAlreadyAddedWidget();
                                // clear search
                                searchBox.getTextBox().setText("");
                            }

                            @Override
                            public void onLoadingStart() {
                                saveSelected = membersToAdd.get(n);
                            }
                        }));
                        request.addMemberToGroup(group, membersToAdd.get(i));
                    }
                }
            }
        }
    });
    tabMenu.addWidget(searchGloballyButton);
    tabMenu.addWidget(listAllButton);
    tabMenu.addWidget(addButton);
    tabMenu.addWidget(inviteButton);
    inviteButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (searchCandidates) {
                // we expect, that candidate is always single
                Candidate candid = findCandidatesOrUsersToAddToVo.getSelected();
                if (candid != null) {
                    if (candid.getObjectType().equalsIgnoreCase("Candidate")) {
                        SendInvitation invite = new SendInvitation(group.getVoId(), groupId);
                        invite.setEvents(JsonCallbackEvents.disableButtonEvents(inviteButton, new JsonCallbackEvents() {

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                findCandidatesOrUsersToAddToVo.clearTableSelectedSet();
                            }
                        }));
                        invite.inviteUser(candid);
                    } else {
                        SendInvitation invite = new SendInvitation(group.getVoId(), groupId);
                        invite.setEvents(JsonCallbackEvents.disableButtonEvents(inviteButton, new JsonCallbackEvents() {

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                findCandidatesOrUsersToAddToVo.clearTableSelectedSet();
                            }
                        }));
                        User user = candid.cast();
                        invite.inviteUser(user);
                    }
                }
            } else {
                // members / all members
                SendInvitation invite = new SendInvitation(group.getVoId(), groupId);
                ArrayList<RichMember> usrs = findMembers.getTableSelectedList();
                for (int i = 0; i < usrs.size(); i++) {
                    if (i == usrs.size() - 1) {
                        invite.setEvents(JsonCallbackEvents.disableButtonEvents(inviteButton, new JsonCallbackEvents() {

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                findMembers.clearTableSelectedSet();
                            }
                        }));
                    } else {
                        invite.setEvents(JsonCallbackEvents.disableButtonEvents(inviteButton));
                    }
                    invite.inviteUser(usrs.get(i).getUser());
                }
            }
        }
    });
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            // with refresh if somebody was added
            session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
        }
    }));
    tabMenu.addWidget(disabled);
    rebuildAlreadyAddedWidget();
    firstTabPanel.add(alreadyAdded);
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(findMembers, table, addButton);
    inviteButton.setEnabled(false);
    JsonUtils.addTableManagedButton(findMembers, table, inviteButton);
    JsonUtils.addTableManagedButton(findCandidatesOrUsersToAddToVo, candidatesTable, addButton);
    JsonUtils.addTableManagedButton(findCandidatesOrUsersToAddToVo, candidatesTable, inviteButton);
    table.addStyleName("perun-table");
    sp.setWidget(table);
    sp.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    candidatesTable.addStyleName("perun-table");
    sp2.setWidget(candidatesTable);
    sp2.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizeSmallTabPanel(sp2, 350, this);
    // if not empty - start searching
    if (search) {
        findMembers.searchFor(searchString);
        firstTabPanel.add(sp);
    } else if (searchCandidates) {
        findCandidatesOrUsersToAddToVo.searchFor(searchString);
        firstTabPanel.add(sp2);
    } else {
        getAllMembers.excludeDisabled(!disabled.getValue());
        getAllMembers.retrieveData();
        firstTabPanel.add(sp);
    }
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) BlurHandler(com.google.gwt.event.dom.client.BlurHandler) User(cz.metacentrum.perun.webgui.model.User) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler) CreateMember(cz.metacentrum.perun.webgui.json.membersManager.CreateMember) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) AddMember(cz.metacentrum.perun.webgui.json.groupsManager.AddMember) GeneralObject(cz.metacentrum.perun.webgui.model.GeneralObject) Candidate(cz.metacentrum.perun.webgui.model.Candidate) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) RichMember(cz.metacentrum.perun.webgui.model.RichMember) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetCompleteRichMembers(cz.metacentrum.perun.webgui.json.membersManager.GetCompleteRichMembers) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) FindCandidatesOrUsersToAddToVo(cz.metacentrum.perun.webgui.json.vosManager.FindCandidatesOrUsersToAddToVo) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) SendInvitation(cz.metacentrum.perun.webgui.json.registrarManager.SendInvitation) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) PerunError(cz.metacentrum.perun.webgui.model.PerunError) FindCompleteRichMembers(cz.metacentrum.perun.webgui.json.membersManager.FindCompleteRichMembers)

Example 19 with RichMember

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

the class MemberOverviewTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(member.getUser().getFullNameWithTitles().trim()));
    // main widget panel
    ScrollPanel vp = new ScrollPanel();
    vp.setSize("100%", "100%");
    VerticalPanel innerVp = new VerticalPanel();
    innerVp.setSize("100%", "100%");
    vp.add(innerVp);
    TabMenu menu = new TabMenu();
    innerVp.add(menu);
    innerVp.setCellHeight(menu, "30px");
    menu.addWidget(UiElements.getRefreshButton(this));
    session.getUiElements().resizeSmallTabPanel(vp, 400);
    FlexTable layout = new FlexTable();
    layout.setSize("100%", "100%");
    innerVp.add(layout);
    layout.setHTML(0, 0, "<p>Personal:");
    layout.setHTML(0, 1, "<p>Membership:");
    layout.getFlexCellFormatter().setWidth(0, 0, "50%");
    layout.getFlexCellFormatter().setWidth(0, 1, "50%");
    layout.getFlexCellFormatter().setStyleName(0, 0, "subsection-heading");
    layout.getFlexCellFormatter().setStyleName(0, 1, "subsection-heading");
    // if attribute not set
    final String notSet = "<i>N/A</i>";
    final FlexTable personalLayout = new FlexTable();
    layout.setWidget(1, 0, personalLayout);
    personalLayout.setStyleName("inputFormFlexTableDark");
    personalLayout.setHTML(0, 0, "Organization:");
    personalLayout.setHTML(1, 0, "Workplace:");
    personalLayout.setHTML(2, 0, "Research group:");
    personalLayout.setHTML(3, 0, "Preferred mail:");
    personalLayout.setHTML(4, 0, "Mail:");
    personalLayout.setHTML(5, 0, "Phone:");
    personalLayout.setHTML(6, 0, "Address:");
    personalLayout.setHTML(7, 0, "Preferred language:");
    personalLayout.setHTML(8, 0, "LoA:");
    personalLayout.setHTML(9, 0, "EDU person affiliation:");
    // one empty cell to create empty column
    personalLayout.setHTML(0, 1, "&nbsp;");
    personalLayout.getFlexCellFormatter().setWidth(0, 1, "70%");
    // style personal table
    for (int i = 0; i < personalLayout.getRowCount(); i++) {
        personalLayout.getFlexCellFormatter().addStyleName(i, 0, "itemName");
    }
    // Membership table
    final FlexTable memberLayout = new FlexTable();
    layout.setWidget(1, 1, memberLayout);
    layout.getFlexCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);
    memberLayout.setStyleName("inputFormFlexTableDark");
    memberLayout.setHTML(0, 0, "Status:");
    final PerunStatusWidget<RichMember> statusWidget;
    if (session.isVoAdmin(member.getVoId())) {
        JsonCallbackEvents event = new JsonCallbackEvents() {

            @Override
            public void onFinished(JavaScriptObject jso) {
                // UPDATE OBJECT
                Member m = jso.cast();
                member.setStatus(m.getStatus());
            }
        };
        statusWidget = new PerunStatusWidget<RichMember>(member, member.getUser().getFullName(), event);
    } else {
        statusWidget = new PerunStatusWidget<RichMember>(member, member.getUser().getFullName(), null);
    }
    memberLayout.setWidget(0, 1, statusWidget);
    memberLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
    if (member.getStatus().equalsIgnoreCase("VALID")) {
        memberLayout.setHTML(1, 0, "Member is properly configured and have access on provided resources.");
    } else if (member.getStatus().equalsIgnoreCase("INVALID")) {
        memberLayout.setHTML(1, 0, "Member have configuration error and DON'T have access on provided resources. You can check what is wrong by changing member's status to VALID. If possible, procedure will configure all necessary settings by itself.");
    } else if (member.getStatus().equalsIgnoreCase("SUSPENDED")) {
        memberLayout.setHTML(1, 0, "Member violated some rules and DON'T have access on provided resources.");
    } else if (member.getStatus().equalsIgnoreCase("EXPIRED")) {
        memberLayout.setHTML(1, 0, "Member didn't extend membership and DON'T have access on provided resources.");
    } else if (member.getStatus().equalsIgnoreCase("DISABLED")) {
        memberLayout.setHTML(1, 0, "Member didn't extend membership long time ago or was manually disabled and DON'T have access on provided resources.");
    }
    memberLayout.getFlexCellFormatter().setStyleName(1, 0, "inputFormInlineComment");
    memberLayout.setHTML(2, 0, "Expiration:");
    memberLayout.setHTML(3, 0, "Member type:");
    if (member.getUser().isServiceUser()) {
        memberLayout.setHTML(3, 1, "Service");
    } else if (member.getUser().isSponsoredUser()) {
        memberLayout.setHTML(3, 1, "Sponsored");
    } else {
        memberLayout.setHTML(3, 1, "Person");
    }
    memberLayout.setHTML(4, 0, "Sponsored by:");
    memberLayout.setHTML(5, 0, "Member ID:");
    memberLayout.setHTML(5, 1, member.getId() + "");
    memberLayout.setHTML(6, 0, "User ID:");
    memberLayout.setHTML(6, 1, member.getUser().getId() + "");
    if (session.isVoAdmin(member.getVoId())) {
        CustomButton resetButton = new CustomButton("Send password reset request…", "", SmallIcons.INSTANCE.keyIcon(), new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new SendPasswordResetRequestTabItem(member));
            }
        });
        memberLayout.setHTML(7, 0, "Password reset");
        memberLayout.setWidget(7, 1, resetButton);
    }
    // style member table
    for (int i = 0; i < memberLayout.getRowCount(); i++) {
        if (i != 1) {
            memberLayout.getFlexCellFormatter().addStyleName(i, 0, "itemName");
        }
    }
    // attributes to load
    ArrayList<String> attrs = new ArrayList<String>();
    // TODO - switch all personal to member attrs
    attrs.add("urn:perun:user:attribute-def:def:organization");
    attrs.add("urn:perun:user:attribute-def:def:workplace");
    attrs.add("urn:perun:user:attribute-def:opt:researchGroup");
    attrs.add("urn:perun:member:attribute-def:def:mail");
    attrs.add("urn:perun:user:attribute-def:def:preferredMail");
    attrs.add("urn:perun:user:attribute-def:def:phone");
    attrs.add("urn:perun:user:attribute-def:def:address");
    attrs.add("urn:perun:user:attribute-def:def:preferredLanguage");
    attrs.add("urn:perun:member:attribute-def:virt:loa");
    attrs.add("urn:perun:member:attribute-def:def:membershipExpiration");
    attrs.add("urn:perun:member:attribute-def:opt:eduPersonAffiliation");
    attrs.add("urn:perun:member:attribute-def:def:sponzoredMember");
    HashMap<String, Integer> ids = new HashMap<String, Integer>();
    ids.put("member", memberId);
    ids.put("workWithUserAttributes", 1);
    GetListOfAttributes attrsCall = new GetListOfAttributes();
    attrsCall.setEvents(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            ArrayList<Attribute> list = JsonUtils.jsoAsList(jso);
            if (list != null && !list.isEmpty()) {
                for (Attribute a : list) {
                    String value = a.getValue();
                    if (a.getName().equalsIgnoreCase("urn:perun:user:attribute-def:def:organization")) {
                        if (!"null".equals(value)) {
                            personalLayout.setHTML(0, 1, value);
                        } else {
                            personalLayout.setHTML(0, 1, notSet);
                        }
                    // set default value width
                    } else if (a.getName().equalsIgnoreCase("urn:perun:user:attribute-def:def:workplace")) {
                        if (!"null".equals(value)) {
                            personalLayout.setHTML(1, 1, value);
                        } else {
                            personalLayout.setHTML(1, 1, notSet);
                        }
                    } else if (a.getName().equalsIgnoreCase("urn:perun:user:attribute-def:opt:researchGroup")) {
                        if (!"null".equals(value)) {
                            personalLayout.setHTML(2, 1, value);
                        } else {
                            personalLayout.setHTML(2, 1, notSet);
                        }
                    } else if (a.getName().equalsIgnoreCase("urn:perun:user:attribute-def:def:preferredMail")) {
                        if (!"null".equals(value)) {
                            personalLayout.setHTML(3, 1, value);
                        } else {
                            personalLayout.setHTML(3, 1, notSet);
                        }
                    } else if (a.getName().equalsIgnoreCase("urn:perun:member:attribute-def:def:mail")) {
                        if (!"null".equals(value)) {
                            personalLayout.setHTML(4, 1, value);
                        } else {
                            personalLayout.setHTML(4, 1, notSet);
                        }
                    } else if (a.getName().equalsIgnoreCase("urn:perun:user:attribute-def:def:phone")) {
                        if (!"null".equals(value)) {
                            personalLayout.setHTML(5, 1, value);
                        } else {
                            personalLayout.setHTML(5, 1, notSet);
                        }
                    } else if (a.getName().equalsIgnoreCase("urn:perun:user:attribute-def:def:address")) {
                        if (!"null".equals(value)) {
                            personalLayout.setHTML(6, 1, value);
                        } else {
                            personalLayout.setHTML(6, 1, notSet);
                        }
                    } else if (a.getName().equalsIgnoreCase("urn:perun:user:attribute-def:def:preferredLanguage")) {
                        if (!"null".equals(value)) {
                            personalLayout.setHTML(7, 1, value);
                        } else {
                            personalLayout.setHTML(7, 1, notSet);
                        }
                    } else if (a.getName().equalsIgnoreCase("urn:perun:member:attribute-def:virt:loa")) {
                        if (!"null".equals(value)) {
                            String text = "";
                            if (value.equals("0")) {
                                text = " (not verified = default)";
                            } else if (value.equals("1")) {
                                text = " (verified email)";
                            } else if (value.equals("2")) {
                                text = " (verified identity)";
                            } else if (value.equals("3")) {
                                text = " (verified identity, strict password strength)";
                            }
                            personalLayout.setHTML(8, 1, value + text);
                        } else {
                            personalLayout.setHTML(8, 1, notSet);
                        }
                    } else if (a.getName().equalsIgnoreCase("urn:perun:member:attribute-def:opt:eduPersonAffiliation")) {
                        if (!"null".equals(value)) {
                            personalLayout.setHTML(9, 1, value);
                        } else {
                            personalLayout.setHTML(9, 1, notSet);
                        }
                    } else if (a.getName().equalsIgnoreCase("urn:perun:member:attribute-def:def:membershipExpiration")) {
                        // set attribute inside member
                        member.setAttribute(a);
                        memberLayout.setWidget(2, 1, new MembershipExpirationWidget(member));
                    } else if (a.getName().equalsIgnoreCase("urn:perun:member:attribute-def:def:sponzoredMember")) {
                        if (!"null".equals(value)) {
                            memberLayout.setHTML(4, 1, value + " (ID of RT ticket with explanation)");
                        } else {
                            memberLayout.setHTML(4, 1, "<i>N/A</i>");
                        }
                    }
                }
            }
        }

        @Override
        public void onError(PerunError error) {
            String text = "<span style=\"color: red\">Error while loading";
            for (int i = 0; i < personalLayout.getRowCount(); i++) {
                personalLayout.setHTML(i, 1, text);
            }
            memberLayout.setHTML(2, 1, text);
            memberLayout.setHTML(4, 1, text);
        }

        @Override
        public void onLoadingStart() {
            for (int i = 0; i < personalLayout.getRowCount(); i++) {
                personalLayout.setWidget(i, 1, new Image(AjaxLoaderImage.SMALL_IMAGE_URL));
            }
            memberLayout.setWidget(2, 1, new Image(AjaxLoaderImage.SMALL_IMAGE_URL));
            memberLayout.setWidget(4, 1, new Image(AjaxLoaderImage.SMALL_IMAGE_URL));
        }
    });
    attrsCall.getListOfAttributes(ids, attrs);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) HashMap(java.util.HashMap) Attribute(cz.metacentrum.perun.webgui.model.Attribute) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) Member(cz.metacentrum.perun.webgui.model.Member) RichMember(cz.metacentrum.perun.webgui.model.RichMember) MembershipExpirationWidget(cz.metacentrum.perun.webgui.widgets.MembershipExpirationWidget) GetListOfAttributes(cz.metacentrum.perun.webgui.json.attributesManager.GetListOfAttributes) RichMember(cz.metacentrum.perun.webgui.model.RichMember) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 20 with RichMember

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

the class GroupMembersTabItem method draw.

public Widget draw() {
    // SET TAB NAME
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": members");
    // MAIN PANEL
    final VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // MENU
    final TabMenu tabMenu = new TabMenu();
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    // DISABLED CHECKBOX
    final CheckBox disabled = new CheckBox(WidgetTranslation.INSTANCE.showDisabledMembers());
    disabled.setTitle(WidgetTranslation.INSTANCE.showDisabledMembersTitle());
    disabled.setValue(wasDisabled);
    // CALLBACKS
    final GetCompleteRichMembers members = new GetCompleteRichMembers(PerunEntity.GROUP, groupId, null);
    final FindCompleteRichMembers findMembers = new FindCompleteRichMembers(PerunEntity.GROUP, groupId, "", null);
    members.excludeDisabled(!wasDisabled);
    members.setIndirectCheckable(false);
    findMembers.setIndirectCheckable(false);
    final CustomButton searchButton = TabMenu.getPredefinedButton(ButtonType.SEARCH, ButtonTranslation.INSTANCE.searchMemberInGroup());
    final CustomButton listAllButton = TabMenu.getPredefinedButton(ButtonType.LIST_ALL_MEMBERS, ButtonTranslation.INSTANCE.listAllMembersInGroup());
    if ((!session.isVoAdmin(group.getVoId()) && !session.isGroupAdmin(groupId)) || group.isCoreGroup()) {
        findMembers.setCheckable(false);
    }
    table = findMembers.getEmptyTable(new FieldUpdater<RichMember, RichMember>() {

        // when user click on a row -> open new tab
        public void update(int index, RichMember object, RichMember value) {
            session.getTabManager().addTab(new MemberDetailTabItem(object.getId(), groupId));
        }
    });
    tableWidget = table.getEmptyTableWidget();
    // refresh
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    // ADD
    CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addMemberToGroup(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddMemberToGroupTabItem(groupId), true);
        }
    });
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
        addButton.setEnabled(false);
    CustomButton inviteButton = new CustomButton("Invite member…", SmallIcons.INSTANCE.emailAddIcon(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new InviteUserTabItem(group.getVoId(), group));
        }
    });
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
        inviteButton.setEnabled(false);
    // REMOVE
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeMemberFromGroup());
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
        removeButton.setEnabled(false);
    if (!group.isCoreGroup()) {
        tabMenu.addWidget(addButton);
        tabMenu.addWidget(inviteButton);
        tabMenu.addWidget(removeButton);
    }
    // refreshMembers
    final JsonCallbackEvents refreshEvent = new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            if (search) {
                findMembers.searchFor(searchString);
            } else {
                findMembers.clearTable();
                members.retrieveData();
            }
        }
    };
    // add click handler for remove button
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // state specific events
            final ArrayList<RichMember> membersForRemoving = findMembers.getTableSelectedList();
            String text = "Following members will be removed from group. They will lose access to resources provided by this group.";
            UiElements.showDeleteConfirm(membersForRemoving, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < membersForRemoving.size(); i++) {
                        RemoveMember request;
                        if (i == membersForRemoving.size() - 1) {
                            request = new RemoveMember(JsonCallbackEvents.disableButtonEvents(removeButton, refreshEvent));
                        } else {
                            request = new RemoveMember(JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.removeMemberFromGroup(group, membersForRemoving.get(i));
                    }
                }
            });
        }
    });
    final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {

        public void searchFor(String text) {
            table.setEmptyTableWidget(tableWidget);
            searchString = text;
            search = true;
            findMembers.searchFor(text);
        }
    }, searchButton);
    searchBox.getTextBox().setText(searchString);
    // checkbox click handler
    disabled.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            wasDisabled = disabled.getValue();
            if (search) {
                // case when update but not triggered by button
                searchString = searchBox.getTextBox().getText();
                members.excludeDisabled(!disabled.getValue());
            } else {
                members.excludeDisabled(!disabled.getValue());
                members.retrieveData();
            }
        }
    });
    findMembers.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(searchButton, JsonCallbackEvents.disableCheckboxEvents(disabled)), new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            searchBox.getTextBox().setEnabled(true);
            listAllButton.setEnabled(true);
        }

        @Override
        public void onError(PerunError error) {
            searchBox.getTextBox().setEnabled(true);
            listAllButton.setEnabled(true);
        }

        @Override
        public void onLoadingStart() {
            searchBox.getTextBox().setEnabled(false);
            listAllButton.setEnabled(false);
            disabled.setVisible(false);
        }
    }));
    members.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(listAllButton, JsonCallbackEvents.disableCheckboxEvents(disabled)), new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // pass data to table handling callback
            findMembers.onFinished(jso);
            ((AjaxLoaderImage) table.getEmptyTableWidget()).setEmptyResultMessage("Group has no members.");
            searchBox.getTextBox().setEnabled(true);
            searchButton.setEnabled(true);
        }

        @Override
        public void onError(PerunError error) {
            // pass data to table handling callback
            findMembers.onError(error);
            searchBox.getTextBox().setEnabled(true);
            searchButton.setEnabled(true);
        }

        @Override
        public void onLoadingStart() {
            table.setEmptyTableWidget(tableWidget);
            searchBox.getTextBox().setEnabled(false);
            searchButton.setEnabled(false);
            disabled.setVisible(true);
            // to show progress when reloading
            ((AjaxLoaderImage) table.getEmptyTableWidget()).loadingStart();
        }
    }));
    // LIST ALL BUTTON
    listAllButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            table.setEmptyTableWidget(tableWidget);
            search = false;
            searchString = "";
            searchBox.getTextBox().setText("");
            findMembers.clearTable();
            members.retrieveData();
        }
    });
    tabMenu.addWidget(listAllButton);
    tabMenu.addWidget(disabled);
    /* WHEN TAB RELOADS, CHECK THE STATE */
    if (search) {
        findMembers.searchFor(searchString);
    } else {
        GetGroupMembersCount count = new GetGroupMembersCount(groupId, new JsonCallbackEvents() {

            @Override
            public void onFinished(JavaScriptObject jso) {
                int membersCount = ((BasicOverlayType) jso.cast()).getInt();
                if (membersCount > 1000) {
                    FlexTable panel = new FlexTable();
                    panel.setSize("100%", "150px");
                    HTML label = new HTML();
                    label.setHTML("<h2>Group has " + membersCount + " members. We suggest you to use search instead.</h2><h2>You can search member by name, login, email or click List all to see all members.</h2>");
                    panel.setWidget(0, 0, label);
                    panel.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
                    table.setEmptyTableWidget(panel);
                } else {
                    // load all members
                    members.excludeDisabled(!disabled.getValue());
                    members.retrieveData();
                }
                onceAsked = true;
            }

            @Override
            public void onError(PerunError error) {
                // load all members
                members.excludeDisabled(!disabled.getValue());
                members.retrieveData();
            }

            @Override
            public void onLoadingStart() {
            }
        });
        if (!onceAsked) {
            count.retrieveData();
        } else {
            // load all members
            members.excludeDisabled(!disabled.getValue());
            members.retrieveData();
        }
    }
    ScrollPanel tableWrapper = new ScrollPanel();
    table.addStyleName("perun-table");
    tableWrapper.setWidget(table);
    tableWrapper.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(tableWrapper, 350, this);
    // add menu and the table to the main panel
    firstTabPanel.add(tableWrapper);
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(findMembers, table, removeButton);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RemoveMember(cz.metacentrum.perun.webgui.json.groupsManager.RemoveMember) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) GetGroupMembersCount(cz.metacentrum.perun.webgui.json.groupsManager.GetGroupMembersCount) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) MemberDetailTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.MemberDetailTabItem) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) RichMember(cz.metacentrum.perun.webgui.model.RichMember) InviteUserTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.InviteUserTabItem) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetCompleteRichMembers(cz.metacentrum.perun.webgui.json.membersManager.GetCompleteRichMembers) AddMemberToGroupTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.AddMemberToGroupTabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) PerunError(cz.metacentrum.perun.webgui.model.PerunError) FindCompleteRichMembers(cz.metacentrum.perun.webgui.json.membersManager.FindCompleteRichMembers)

Aggregations

RichMember (cz.metacentrum.perun.webgui.model.RichMember)20 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)7 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)7 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)7 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)6 RichMemberComparator (cz.metacentrum.perun.webgui.json.comparators.RichMemberComparator)6 JsonUtils (cz.metacentrum.perun.webgui.json.JsonUtils)5 PerunError (cz.metacentrum.perun.webgui.model.PerunError)5 Column (com.google.gwt.user.cellview.client.Column)4 Member (cz.metacentrum.perun.webgui.model.Member)4 User (cz.metacentrum.perun.webgui.model.User)4 AjaxLoaderImage (cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage)4 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)4 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)4 ArrayList (java.util.ArrayList)4 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)3 FindCompleteRichMembers (cz.metacentrum.perun.webgui.json.membersManager.FindCompleteRichMembers)3 GetCompleteRichMembers (cz.metacentrum.perun.webgui.json.membersManager.GetCompleteRichMembers)3 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)3 CheckboxCell (com.google.gwt.cell.client.CheckboxCell)2