Search in sources :

Example 1 with PerunStatusCell

use of cz.metacentrum.perun.webgui.widgets.cells.PerunStatusCell in project perun by CESNET.

the class GetCompleteCandidates method getEmptyTable.

/**
 * Returns the empty table widget
 *
 * @return table widget
 */
public CellTable<MemberCandidate> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<MemberCandidate>(list);
    // Cell table
    table = new PerunTable<MemberCandidate>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<MemberCandidate> columnSortHandler = new ListHandler<MemberCandidate>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // Table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<MemberCandidate>createCheckboxManager());
    // Set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    // checkbox column column
    Column<MemberCandidate, MemberCandidate> checkBoxColumn = new Column<MemberCandidate, MemberCandidate>(new PerunCheckboxCell<MemberCandidate>(true, false, (groupId == 0))) {

        @Override
        public MemberCandidate getValue(MemberCandidate object) {
            // Get the value from the selection model.
            GeneralObject go = object.cast();
            go.setChecked(selectionModel.isSelected(object));
            return go.cast();
        }
    };
    // updates the columns size
    table.setColumnWidth(checkBoxColumn, 40.0, Style.Unit.PX);
    table.addColumn(checkBoxColumn);
    // is member
    TextColumn<MemberCandidate> memberColumn = new TextColumn<MemberCandidate>() {

        @Override
        public String getValue(MemberCandidate candidate) {
            if (groupId == 0) {
                if (candidate.getMember() != null)
                    return "Member of VO";
            } else {
                if (candidate.getMember() != null && candidate.getMember().getSourceGroupId() != 0 && "DIRECT".equalsIgnoreCase(candidate.getMember().getMembershipType()))
                    return "Member of Group";
                if (candidate.getMember() != null && candidate.getMember().getSourceGroupId() != 0 && "INDIRECT".equalsIgnoreCase(candidate.getMember().getMembershipType()))
                    return "Indirect member of Group";
                if (candidate.getMember() != null)
                    return "Member of VO";
            }
            return "";
        }
    };
    // Status column
    final Column<MemberCandidate, String> statusColumn = new Column<MemberCandidate, String>(new PerunStatusCell()) {

        @Override
        public String getValue(MemberCandidate object) {
            if (object.getMember() != null) {
                return object.getMember().getStatus();
            } else {
                return null;
            }
        }
    };
    // Full Name Column
    TextColumn<MemberCandidate> fullNameColumn = new TextColumn<MemberCandidate>() {

        @Override
        public String getValue(MemberCandidate candidate) {
            return getFullNameColumnValue(candidate);
        }
    };
    // E-mail column
    TextColumn<MemberCandidate> emailColumn = new TextColumn<MemberCandidate>() {

        @Override
        public String getValue(MemberCandidate candidate) {
            return getEmailColumnValue(candidate);
        }
    };
    // Login Column
    TextColumn<MemberCandidate> loginColumn = new TextColumn<MemberCandidate>() {

        @Override
        public String getValue(MemberCandidate candidate) {
            return getLoginFromExtSourceOrAllLogins(candidate);
        }
    };
    // Ext Source Column
    TextColumn<MemberCandidate> extSourceColumn = new TextColumn<MemberCandidate>() {

        @Override
        public String getValue(MemberCandidate candidate) {
            return getExtSourceNameOrOrganizationColumn(candidate);
        }
    };
    // already Column
    TextColumn<MemberCandidate> alreadyInPerunColumn = new TextColumn<MemberCandidate>() {

        @Override
        public String getValue(MemberCandidate candidate) {
            if (candidate.getRichUser() != null) {
                return "Local";
            } else {
                return "External identity";
            }
        }
    };
    alreadyInPerunColumn.setSortable(true);
    columnSortHandler.setComparator(alreadyInPerunColumn, new Comparator<MemberCandidate>() {

        public int compare(MemberCandidate o1, MemberCandidate o2) {
            String o1Val = "External identity";
            String o2Val = "External identity";
            if (o1.getRichUser() != null) {
                o1Val = "Local";
            }
            if (o2.getRichUser() != null) {
                o2Val = "Local";
            }
            return o1Val.compareTo(o2Val);
        }
    });
    memberColumn.setSortable(true);
    columnSortHandler.setComparator(memberColumn, new Comparator<MemberCandidate>() {

        public int compare(MemberCandidate o1, MemberCandidate o2) {
            String o1Val = "1";
            String o2Val = "1";
            if (o1.getMember() != null)
                o1Val = "0";
            if (o2.getMember() != null)
                o2Val = "0";
            o1Val += getFullNameColumnValue(o1);
            o2Val += getFullNameColumnValue(o2);
            return o1Val.compareTo(o2Val);
        }
    });
    loginColumn.setSortable(true);
    columnSortHandler.setComparator(loginColumn, new Comparator<MemberCandidate>() {

        public int compare(MemberCandidate o1, MemberCandidate o2) {
            return getLoginFromExtSourceOrAllLogins(o1).compareToIgnoreCase(getLoginFromExtSourceOrAllLogins(o2));
        }
    });
    fullNameColumn.setSortable(true);
    columnSortHandler.setComparator(fullNameColumn, new Comparator<MemberCandidate>() {

        public int compare(MemberCandidate o1, MemberCandidate o2) {
            return getFullNameColumnValue(o1).compareToIgnoreCase(getFullNameColumnValue(o2));
        }
    });
    extSourceColumn.setSortable(true);
    columnSortHandler.setComparator(extSourceColumn, new Comparator<MemberCandidate>() {

        public int compare(MemberCandidate o1, MemberCandidate o2) {
            return getExtSourceNameOrOrganizationColumn(o1).compareToIgnoreCase(getExtSourceNameOrOrganizationColumn(o2));
        }
    });
    emailColumn.setSortable(true);
    columnSortHandler.setComparator(emailColumn, new Comparator<MemberCandidate>() {

        public int compare(MemberCandidate o1, MemberCandidate o2) {
            return getEmailColumnValue(o1).compareToIgnoreCase(getEmailColumnValue(o2));
        }
    });
    table.addColumnSortHandler(columnSortHandler);
    // Add the columns.
    table.addColumn(statusColumn, "Status");
    table.addColumn(fullNameColumn, "Full name");
    table.addColumn(extSourceColumn, "Organization or Ext source");
    table.addColumn(emailColumn, "E-mail");
    table.addColumn(loginColumn, "Logins");
    table.addColumn(memberColumn, "Already member");
    table.addColumn(alreadyInPerunColumn, "Source");
    return table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) MemberCandidate(cz.metacentrum.perun.webgui.model.MemberCandidate) TextColumn(com.google.gwt.user.cellview.client.TextColumn) Column(com.google.gwt.user.cellview.client.Column) PerunStatusCell(cz.metacentrum.perun.webgui.widgets.cells.PerunStatusCell) GeneralObject(cz.metacentrum.perun.webgui.model.GeneralObject) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Example 2 with PerunStatusCell

use of cz.metacentrum.perun.webgui.widgets.cells.PerunStatusCell in project perun by CESNET.

the class GetMembers method getEmptyTable.

/**
 * Returns empty table definition
 * @return
 */
public CellTable<Member> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<Member>(list);
    // Cell table
    table = new PerunTable<Member>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<Member> columnSortHandler = new ListHandler<Member>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Member>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    // columns
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("Member ID", tableFieldUpdater);
    Column<Member, String> voIdColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Member, String>() {

        public String getValue(Member member) {
            return "" + member.getVoId();
        }
    }, tableFieldUpdater);
    voIdColumn.setSortable(true);
    columnSortHandler.setComparator(voIdColumn, new Comparator<Member>() {

        public int compare(Member o1, Member o2) {
            return (o1.getVoId() + "").compareTo(o2.getVoId() + "");
        }
    });
    Column<Member, String> userIdColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Member, String>() {

        public String getValue(Member resource) {
            return "" + resource.getUserId();
        }
    }, tableFieldUpdater);
    userIdColumn.setSortable(true);
    columnSortHandler.setComparator(userIdColumn, new Comparator<Member>() {

        public int compare(Member o1, Member o2) {
            return (o1.getUserId() + "").compareTo(o2.getUserId() + "");
        }
    });
    table.addColumn(voIdColumn, "Vo ID");
    table.addColumn(userIdColumn, "User ID");
    // Status column
    final Column<Member, String> statusColumn = new Column<Member, String>(new PerunStatusCell()) {

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

        @Override
        public void update(final int index, final Member object, final String value) {
            PerunWebSession.getInstance().getTabManager().addTabToCurrentTab(new ChangeStatusTabItem(object.cast(), new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    Member m = jso.cast();
                    // set status to object in cell to change rendered value
                    object.setStatus(m.getStatus());
                    dataProvider.refresh();
                    dataProvider.flush();
                }
            }));
        }
    });
    // add column
    table.addColumn(statusColumn, "Status");
    // status column sortable
    statusColumn.setSortable(true);
    table.getColumnSortHandler().setComparator(statusColumn, new GeneralComparator<Member>(GeneralComparator.Column.STATUS));
    return table;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) JSONString(com.google.gwt.json.client.JSONString) JsonUtils(cz.metacentrum.perun.webgui.json.JsonUtils) Column(com.google.gwt.user.cellview.client.Column) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) PerunStatusCell(cz.metacentrum.perun.webgui.widgets.cells.PerunStatusCell) ChangeStatusTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.ChangeStatusTabItem) Member(cz.metacentrum.perun.webgui.model.Member)

Example 3 with PerunStatusCell

use of cz.metacentrum.perun.webgui.widgets.cells.PerunStatusCell 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) {
            PerunWebSession.getInstance().getTabManager().addTabToCurrentTab(new ChangeStatusTabItem(object.cast(), new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    clearTable();
                    retrieveData();
                }
            }));
        }
    });
    // 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) 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) ChangeStatusTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.ChangeStatusTabItem) RichMemberComparator(cz.metacentrum.perun.webgui.json.comparators.RichMemberComparator)

Example 4 with PerunStatusCell

use of cz.metacentrum.perun.webgui.widgets.cells.PerunStatusCell in project perun by CESNET.

the class MemberColumnProvider method addStatusColumn.

public void addStatusColumn(IsClickableCell authz, int width) {
    // Status column
    final 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>() {

        @Override
        public void update(final int index, final RichMember object, final String value) {
            PerunWebSession.getInstance().getTabManager().addTabToCurrentTab(new ChangeStatusTabItem(object.cast(), new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    // passed object might not be relevant for this action
                    if (jso == null)
                        return;
                    Member m = jso.cast();
                    // set status to object in cell to change rendered value
                    object.setStatus(m.getStatus());
                    // because they are not updated during .update() on cell
                    for (RichMember rm : dataProvider.getList()) {
                        if (rm.getId() == m.getId()) {
                            rm.setStatus(m.getStatus());
                        }
                    }
                    if (backupList != null) {
                        for (RichMember rm : backupList) {
                            if (rm.getId() == m.getId()) {
                                rm.setStatus(m.getStatus());
                            }
                        }
                    }
                    dataProvider.refresh();
                    dataProvider.flush();
                }
            }));
        }
    });
    // add column
    table.addColumn(statusColumn, "Status");
    if (width != 0) {
        table.setColumnWidth(statusColumn, width, Style.Unit.PX);
    }
    // status column sortable
    statusColumn.setSortable(true);
    table.getColumnSortHandler().setComparator(statusColumn, new GeneralComparator<RichMember>(GeneralComparator.Column.STATUS));
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) 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) ChangeStatusTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.ChangeStatusTabItem) Member(cz.metacentrum.perun.webgui.model.Member) RichMember(cz.metacentrum.perun.webgui.model.RichMember)

Example 5 with PerunStatusCell

use of cz.metacentrum.perun.webgui.widgets.cells.PerunStatusCell 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

Column (com.google.gwt.user.cellview.client.Column)5 PerunStatusCell (cz.metacentrum.perun.webgui.widgets.cells.PerunStatusCell)5 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)4 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)3 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)3 Member (cz.metacentrum.perun.webgui.model.Member)3 RichMember (cz.metacentrum.perun.webgui.model.RichMember)3 ChangeStatusTabItem (cz.metacentrum.perun.webgui.tabs.memberstabs.ChangeStatusTabItem)3 RichMemberComparator (cz.metacentrum.perun.webgui.json.comparators.RichMemberComparator)2 JSONString (com.google.gwt.json.client.JSONString)1 TextColumn (com.google.gwt.user.cellview.client.TextColumn)1 JsonUtils (cz.metacentrum.perun.webgui.json.JsonUtils)1 GeneralObject (cz.metacentrum.perun.webgui.model.GeneralObject)1 MemberCandidate (cz.metacentrum.perun.webgui.model.MemberCandidate)1 ChangeGroupStatusTabItem (cz.metacentrum.perun.webgui.tabs.memberstabs.ChangeGroupStatusTabItem)1