Example usage for org.apache.wicket.markup.repeater.data GridView setRows

List of usage examples for org.apache.wicket.markup.repeater.data GridView setRows

Introduction

In this page you can find the example usage for org.apache.wicket.markup.repeater.data GridView setRows.

Prototype

public GridView<T> setRows(int rows) 

Source Link

Document

Sets number of rows per page

Usage

From source file:com.evolveum.midpoint.web.component.assignment.GridViewComponent.java

License:Apache License

private void initLayout() {
    GridView gridView = new GridView(ID_ROWS, getModelObject()) {
        private static final long serialVersionUID = 1L;

        @Override//from   ww w .jav  a 2 s.  c  o m
        protected void populateEmptyItem(Item item) {
            GridViewComponent.this.populateEmptyItem(item);
        }

        @Override
        protected void populateItem(Item item) {
            GridViewComponent.this.populateItem(item);
            item.add(AttributeAppender.append("class", getGridItemStyleClass(item.getModel())));
        }

    };
    gridView.add(new VisibleEnableBehaviour() {
        public boolean isVisible() {
            BaseSortableDataProvider p = (BaseSortableDataProvider) GridViewComponent.this.getModelObject();
            List<AssignmentEditorDto> l = p.getAvailableData();

            if (l != null) {
            }
            return true;
        }
    });
    gridView.setRows(getRowsCount());
    gridView.setColumns(getColsCount());
    gridView.setOutputMarkupId(true);
    gridView.setItemsPerPage(getColsCount() * getRowsCount());
    add(gridView);

    add(createFooter());
}

From source file:com.locke.library.web.wow.layout.layouts.ColumnLayout.java

License:Apache License

/**
 * Construct.//from   ww w. ja v  a 2s  .  co  m
 * 
 * @param id
 *            Component id
 * @param panels
 *            Source of panels
 * @param columnCount
 *            Number of columns in the grid
 */
public ColumnLayout(final String id, final IPanelSource panels, final int columnCount) {
    super(id, panels);

    if (columnCount < 1) {
        throw new IllegalArgumentException("Invalid column count: " + columnCount);
    }

    final GridView<Panel> grid = new GridView<Panel>("rows", getProvider()) {

        private static final long serialVersionUID = -5420713157033336965L;

        @Override
        protected void populateEmptyItem(Item<Panel> item) {
            item.add(new EmptyPanel(CHILD_ID));
        }

        @Override
        protected void populateItem(Item<Panel> item) {
            item.add(item.getModelObject());
        }
    };
    grid.setRows(Integer.MAX_VALUE);
    grid.setColumns(columnCount);
    add(grid);
}

From source file:org.dcm4chee.web.war.tc.TCDetailsImagesTab.java

License:LGPL

public TCDetailsImagesTab(final String id, TCAttributeVisibilityStrategy attrVisibilityStrategy) {
    super(id, attrVisibilityStrategy);

    WadoImage.setDefaultWadoBaseUrl(WADODelegate.getInstance().getWadoBaseUrl());

    final IModel<Integer> width = new Model<Integer>(64);
    final int cols = 5;
    final int rows = 5;

    final ReferencedImageProvider imageProvider = new ReferencedImageProvider();
    GridView<TCReferencedImage> view = new GridView<TCReferencedImage>("details-image-row", imageProvider) {

        private static final long serialVersionUID = 1L;

        @Override/*w w  w.  ja  v  a  2  s  . c  om*/
        protected void populateItem(final Item<TCReferencedImage> item) {
            TCReferencedInstance ref = item.getModelObject();

            if (WADODelegate.getInstance().getRenderType(ref.getClassUID()) == WADODelegate.IMAGE) {
                item.add(new WadoImage("image", ref.getInstanceUID(), ref.getSeriesUID(), ref.getStudyUID(),
                        width)).setOutputMarkupId(true);
            } else {
                item.add(new Image("image", ImageManager.IMAGE_TC_IMAGE_PLACEHOLDER).setOutputMarkupId(true));
            }
        }

        @Override
        protected void populateEmptyItem(final Item<TCReferencedImage> item) {
            item.add(new Image("image", ImageManager.IMAGE_TC_IMAGE_PLACEHOLDER).setOutputMarkupId(true));
        }
    };

    view.setColumns(cols);
    view.setRows(rows);

    navWmc = new WebMarkupContainer("details-images-nav-container") {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            int nImages = imageProvider.size();
            return nImages > cols * rows;
        }
    };
    navWmc.add(new PagingNavigator("details-images-nav", view));
    navWmc.setOutputMarkupPlaceholderTag(true);
    navWmc.setOutputMarkupId(true);
    navWmc.setMarkupId("details-images-nav-container");

    add(navWmc);
    add(view);
}

From source file:org.sakaiproject.myconnections.ui.components.ConnectionsGrid.java

License:Educational Community License

@Override
public void onInitialize() {
    super.onInitialize();

    @SuppressWarnings("unchecked")
    final List<WidgetPage.GridPerson> connections = (List<WidgetPage.GridPerson>) getDefaultModelObject();

    final int nUsers = connections.size();
    int rows = (nUsers + cols - 1) / cols; /* round up number of rows */

    final ListDataProvider<WidgetPage.GridPerson> dataProvider = new ListDataProvider<WidgetPage.GridPerson>(
            connections);/*from  ww  w  .  j  a v  a  2  s  . com*/

    final GridView<WidgetPage.GridPerson> gridView = new GridView<WidgetPage.GridPerson>("rows", dataProvider) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<WidgetPage.GridPerson> item) {
            final WidgetPage.GridPerson connection = item.getModelObject();
            final String connection_uuid = connection.uuid;
            final ProfileThumbnail img = new ProfileThumbnail("img", Model.of(connection_uuid));

            final String url = "javascript:;";

            img.add(new AttributeModifier("href", url));
            img.add(new AttributeModifier("target", "_top"));
            img.add(new AttributeModifier("data-user-id", connection_uuid));
            item.add(img);

            //name link
            ExternalLink l = new ExternalLink("name", url, connection.displayName);
            l.add(new AttributeModifier("data-user-id", connection_uuid));
            item.add(l);

            //role
            if (connection.role == "request") {
                ResourceModel rm = new ResourceModel("heading.request");
                item.add(new Label("role", rm.getObject()));
            } else {
                item.add(new EmptyPanel("role"));
            }

            String t = "online-status";
            if (connection.onlineStatus == ProfileConstants.ONLINE_STATUS_ONLINE) {
                t += " online";
            } else if (connection.onlineStatus == ProfileConstants.ONLINE_STATUS_AWAY) {
                t += " away";
            } else {
                t += " offline";
            }

            Label lbl = new Label("online_status", "");
            lbl.add(new AttributeModifier("class", t));

            item.add(lbl);
        }

        @Override
        protected void populateEmptyItem(final Item<WidgetPage.GridPerson> item) {
            item.add(new EmptyPanel("img"));
            item.add(new EmptyPanel("name"));
            item.add(new EmptyPanel("role"));
            item.setVisible(false);
        }
    };

    /* handle case where nUsers=0 */
    if (rows <= 0) {
        rows = 1;
    }
    gridView.setRows(rows);
    gridView.setColumns(cols);

    add(gridView);
}

From source file:org.sakaiproject.profile2.tool.pages.panels.GalleryFeed.java

License:Educational Community License

@SuppressWarnings("unchecked")
public GalleryFeed(String id, final String ownerUserId, final String viewingUserId) {

    super(id);/* w w w .ja v a 2  s .  c o  m*/

    log.debug("GalleryFeed()");

    Label heading;
    if (viewingUserId.equals(ownerUserId)) {
        heading = new Label("heading", new ResourceModel("heading.widget.my.pictures"));
    } else {
        heading = new Label("heading", new StringResourceModel("heading.widget.view.pictures", null,
                new Object[] { sakaiProxy.getUserDisplayName(ownerUserId) }));
    }
    add(heading);

    IDataProvider dataProvider = new GalleryImageRandomizedDataProvider(ownerUserId);

    GridView dataView = new GridView("rows", dataProvider) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateEmptyItem(Item item) {
            // TODO make "fake" clickable
            Link emptyImageLink = new Link("galleryFeedItem") {
                public void onClick() {
                }

            };

            Label galleryFeedPicture = new Label("galleryImageThumbnailRenderer", "");
            emptyImageLink.add(galleryFeedPicture);

            item.add(emptyImageLink);
        }

        @Override
        protected void populateItem(Item item) {

            final GalleryImage image = (GalleryImage) item.getModelObject();

            GalleryImageRenderer galleryImageThumbnailRenderer = new GalleryImageRenderer(
                    "galleryImageThumbnailRenderer", image.getThumbnailResource());

            AjaxLink galleryFeedItem = new AjaxLink("galleryFeedItem") {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    // view-only (i.e. no edit functionality)
                    setResponsePage(new ViewPicture(image));
                }
            };
            galleryFeedItem.add(galleryImageThumbnailRenderer);

            item.add(galleryFeedItem);

        }

    };
    // limit gallery to 3x2 thumbnails
    dataView.setColumns(3);
    dataView.setRows(2);

    add(dataView);

    AjaxLink viewPicturesLink = new AjaxLink("viewPicturesLink") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {

            if (sakaiProxy.isSuperUserAndProxiedToUser(ownerUserId)) {
                setResponsePage(new ViewPictures(ownerUserId));
            } else if (viewingUserId.equals(ownerUserId)) {
                setResponsePage(new MyPictures());
            } else {
                setResponsePage(new ViewPictures(ownerUserId));
            }
        }

    };

    Label numPicturesLabel = new Label("numPicturesLabel");
    add(numPicturesLabel);

    Label viewPicturesLabel;

    if (dataView.getItemCount() == 0) {
        numPicturesLabel.setDefaultModel(new ResourceModel("text.gallery.feed.num.none"));
        viewPicturesLabel = new Label("viewPicturesLabel", new ResourceModel("link.gallery.feed.addnew"));

        if (!viewingUserId.equals(ownerUserId) || sakaiProxy.isSuperUserAndProxiedToUser(ownerUserId)) {
            viewPicturesLink.setVisible(false);
        }

    } else {
        numPicturesLabel.setVisible(false);
        viewPicturesLabel = new Label("viewPicturesLabel", new ResourceModel("link.gallery.feed.view"));
    }

    viewPicturesLink.add(viewPicturesLabel);

    add(viewPicturesLink);
}

From source file:org.sakaiproject.sitemembers.ui.components.ConnectionsGrid.java

License:Educational Community License

@Override
public void onInitialize() {
    super.onInitialize();

    @SuppressWarnings("unchecked")
    final List<WidgetPage.GridPerson> connections = (List<WidgetPage.GridPerson>) getDefaultModelObject();

    final int nUsers = connections.size();
    int rows = (nUsers + cols - 1) / cols; /* round up number of rows */

    final ListDataProvider<WidgetPage.GridPerson> dataProvider = new ListDataProvider<WidgetPage.GridPerson>(
            connections);/*  www  .j  av  a  2 s.c o m*/

    final GridView<WidgetPage.GridPerson> gridView = new GridView<WidgetPage.GridPerson>("rows", dataProvider) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<WidgetPage.GridPerson> item) {
            final WidgetPage.GridPerson connection = item.getModelObject();
            final String connection_uuid = connection.uuid;
            final ProfileThumbnail img = new ProfileThumbnail("img", Model.of(connection_uuid));

            final String url = "javascript:;";

            img.add(new AttributeModifier("href", url));
            img.add(new AttributeModifier("target", "_top"));
            img.add(new AttributeModifier("data-user-id", connection_uuid));
            item.add(img);

            //name link
            ExternalLink l = new ExternalLink("name", url, connection.displayName);
            l.add(new AttributeModifier("data-user-id", connection_uuid));
            item.add(l);

            //role
            if (connection.role != "STUDENT") {
                ResourceModel rm = new ResourceModel(prefix + connection.role.toLowerCase());
                item.add(new Label("role", rm.getObject()));
            } else {
                item.add(new EmptyPanel("role"));
            }

            String t = "online-status";
            if (connection.onlineStatus == ProfileConstants.ONLINE_STATUS_ONLINE) {
                t += " online";
            } else if (connection.onlineStatus == ProfileConstants.ONLINE_STATUS_AWAY) {
                t += " away";
            } else {
                t += " offline";
            }

            Label lbl = new Label("online_status", "");
            lbl.add(new AttributeModifier("class", t));

            item.add(lbl);
        }

        @Override
        protected void populateEmptyItem(final Item<WidgetPage.GridPerson> item) {
            item.add(new EmptyPanel("img"));
            item.add(new EmptyPanel("name"));
            item.add(new EmptyPanel("role"));
            item.setVisible(false);
        }
    };

    /* handle case where nUsers=0 */
    if (rows <= 0) {
        rows = 1;
    }
    gridView.setRows(rows);
    gridView.setColumns(cols);

    add(gridView);
}

From source file:org.yes.cart.web.page.component.ProductsCentralView.java

License:Apache License

/**
 * {@inheritDoc}// w w  w.ja  va 2 s .c om
 */
@Override
protected void onBeforeRender() {

    final long configShopId = getCurrentShopId();
    final long categoryId = getCategoryId();
    final NavigationContext context = getNavigationContext();

    add(new TopCategories("topCategories"));
    add(new BrandProductFilter("brandFilter", categoryId, context));
    add(new AttributeProductFilter("attributeFilter", categoryId, context));
    add(new PriceProductFilter("priceFilter", categoryId, context));

    final List<String> itemsPerPageValues = categoryServiceFacade.getItemsPerPageOptionsConfig(categoryId,
            configShopId);
    final List<String> pageSortingValues = categoryServiceFacade.getPageSortingOptionsConfig(categoryId,
            configShopId);
    final Pair<String, String> widthHeight = categoryServiceFacade.getProductListImageSizeConfig(categoryId,
            configShopId);
    final int columns = categoryServiceFacade.getProductListColumnOptionsConfig(categoryId, configShopId);

    final PageParameters pageParameters = getPage().getPageParameters();
    final PaginationSupport pagination = getWicketSupportFacade().pagination();
    int currentPageIdx = pagination.getCurrentPage(pageParameters);
    if (currentPageIdx < 0) {
        // if we have gone overboard restart from 0 by redirect!
        final PageParameters params = new PageParameters(getPage().getPageParameters());
        getWicketSupportFacade().pagination().removePageParam(params);
        setResponsePage(getPage().getClass(), params);
        currentPageIdx = 0;
    }

    final int selectedItemPerPage = pagination.getCurrentItemsPerPage(pageParameters, itemsPerPageValues);
    final Pair<String, Boolean> sortResult = getSortField();

    ProductSearchResultPageDTO products = productServiceFacade.getListProducts(context,
            currentPageIdx * selectedItemPerPage, selectedItemPerPage, sortResult.getFirst(),
            sortResult.getSecond());

    if (currentPageIdx * selectedItemPerPage > products.getTotalHits()) {
        // if we have gone overboard restart from 0 by redirect!
        final PageParameters params = new PageParameters(getPage().getPageParameters());
        getWicketSupportFacade().pagination().removePageParam(params);
        setResponsePage(getPage().getClass(), params);
    }

    final boolean hasResults = products.getTotalHits() > 0L;

    final SortableProductDataProvider dataProvider = new SortableProductDataProvider(products);

    final GridView<ProductSearchResultDTO> productDataView = new GridView<ProductSearchResultDTO>(PRODUCT_LIST,
            dataProvider) {

        protected void populateItem(Item<ProductSearchResultDTO> productItem) {
            productItem.add(new ProductInListView(PRODUCT, productItem.getModelObject(), widthHeight));
        }

        protected void populateEmptyItem(Item<ProductSearchResultDTO> productItem) {
            productItem.add(new Label(PRODUCT, StringUtils.EMPTY).setVisible(false));

        }

    };

    productDataView.setColumns(columns);
    productDataView.setRows(selectedItemPerPage / columns);
    productDataView.setCurrentPage(currentPageIdx);

    add(new ProductSorter(SORTER, pageSortingValues).setVisible(hasResults));
    add(new URLPagingNavigator(PAGINATOR, productDataView, getPage().getPageParameters())
            .setVisible(hasResults));
    add(new URLPagingNavigator(PAGINATOR2, productDataView, getPage().getPageParameters())
            .setVisible(hasResults));
    add(new ProductPerPageListView(ITEMS_PER_PAGE_LIST, itemsPerPageValues).setVisible(hasResults));
    add(productDataView.setVisible(hasResults));

    if (!hasResults) {
        info(getLocalizer().getString("noResultsFound", this));
    }

    super.onBeforeRender();
}