Search in sources :

Example 1 with MemberColumnProvider

use of cz.metacentrum.perun.webgui.json.columnProviders.MemberColumnProvider in project perun by CESNET.

the class FindCompleteRichMembers method getEmptyTable.

/**
 * Returns table with RichMembers
 *
 * @return CellTable widget
 */
public CellTable<RichMember> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<RichMember>(list);
    // Cell table
    table = new PerunTable<RichMember>(list);
    table.setHyperlinksAllowed(false);
    // 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);
    loaderImage.setEmptyResultMessage("No member found.");
    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, null, 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);
    if (!hideGroupStatusColumn) {
        columnProvider.addGroupStatusColumn(authz, entityId, 120);
    }
    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 2 with MemberColumnProvider

use of cz.metacentrum.perun.webgui.json.columnProviders.MemberColumnProvider 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);
    if (entity.equals(PerunEntity.GROUP)) {
        columnProvider.addGroupStatusColumn(authz, entityId, 120);
    }
    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)

Aggregations

CheckboxCell (com.google.gwt.cell.client.CheckboxCell)2 Column (com.google.gwt.user.cellview.client.Column)2 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)2 Header (com.google.gwt.user.cellview.client.Header)2 IsClickableCell (cz.metacentrum.perun.webgui.json.columnProviders.IsClickableCell)2 MemberColumnProvider (cz.metacentrum.perun.webgui.json.columnProviders.MemberColumnProvider)2 RichMember (cz.metacentrum.perun.webgui.model.RichMember)2 PerunCheckboxCell (cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell)2