Search in sources :

Example 1 with ChangeGroupStatusTabItem

use of cz.metacentrum.perun.webgui.tabs.memberstabs.ChangeGroupStatusTabItem in project perun by CESNET.

the class MemberColumnProvider method addGroupStatusColumn.

public void addGroupStatusColumn(IsClickableCell authz, int groupId, int width) {
    // Status column
    final Column<RichMember, String> statusColumn = new Column<RichMember, String>(new PerunStatusCell()) {

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

        @Override
        public void update(final int index, final RichMember object, final String value) {
            if ("INDIRECT".equalsIgnoreCase(object.getMembershipType())) {
                UiElements.generateInfo("Can't change group membership status!", "INDIRECT members can't have their group membership status changed directly." + "<p>Please change members group status in all sourcing groups." + "<p>In order to expire member in a group, member must be set to EXPIRED in all sourcing groups (sub-groups and groups in relation)." + "<p>In order to validate member, at least one sourcing group must have member with VALID group membership status.");
            } else {
                PerunWebSession.getInstance().getTabManager().addTabToCurrentTab(new ChangeGroupStatusTabItem(object, groupId, new JsonCallbackEvents() {

                    @Override
                    public void onFinished(JavaScriptObject jso) {
                        Member m = jso.cast();
                        // set status to object in cell to change rendered value
                        object.setGroupStatus(m.getGroupStatus());
                        // because they are not updated during .update() on cell
                        for (RichMember rm : dataProvider.getList()) {
                            if (rm.getId() == m.getId()) {
                                rm.setGroupStatus(m.getGroupStatus());
                            }
                        }
                        if (backupList != null) {
                            for (RichMember rm : backupList) {
                                if (rm.getId() == m.getId()) {
                                    rm.setGroupStatus(m.getGroupStatus());
                                }
                            }
                        }
                        dataProvider.refresh();
                        dataProvider.flush();
                    }
                }));
            }
        }
    });
    // add column
    table.addColumn(statusColumn, "Group Status");
    if (width != 0) {
        table.setColumnWidth(statusColumn, width, Style.Unit.PX);
    }
    // status column sortable
    statusColumn.setSortable(true);
    table.getColumnSortHandler().setComparator(statusColumn, new RichMemberComparator(RichMemberComparator.Column.GROUP_STATUS));
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ChangeGroupStatusTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.ChangeGroupStatusTabItem) RichMember(cz.metacentrum.perun.webgui.model.RichMember) Column(com.google.gwt.user.cellview.client.Column) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) PerunStatusCell(cz.metacentrum.perun.webgui.widgets.cells.PerunStatusCell) RichMemberComparator(cz.metacentrum.perun.webgui.json.comparators.RichMemberComparator) Member(cz.metacentrum.perun.webgui.model.Member) RichMember(cz.metacentrum.perun.webgui.model.RichMember)

Aggregations

JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 Column (com.google.gwt.user.cellview.client.Column)1 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)1 RichMemberComparator (cz.metacentrum.perun.webgui.json.comparators.RichMemberComparator)1 Member (cz.metacentrum.perun.webgui.model.Member)1 RichMember (cz.metacentrum.perun.webgui.model.RichMember)1 ChangeGroupStatusTabItem (cz.metacentrum.perun.webgui.tabs.memberstabs.ChangeGroupStatusTabItem)1 PerunStatusCell (cz.metacentrum.perun.webgui.widgets.cells.PerunStatusCell)1