Example usage for org.apache.wicket.extensions.markup.html.repeater.data.table DataTable getCurrentPage

List of usage examples for org.apache.wicket.extensions.markup.html.repeater.data.table DataTable getCurrentPage

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.markup.html.repeater.data.table DataTable getCurrentPage.

Prototype

@Override
public final long getCurrentPage() 

Source Link

Usage

From source file:com.zh.snmp.snmpweb.components.ZhNavigatorLabel.java

License:Open Source License

/**
 * @param id/*w w  w .  j  av a2s.  co m*/
 *            component id
 * @param table
 *            table
 */
public ZhNavigatorLabel(final String id, final DataTable<?> table) {
    this(id, new PageableComponent() {

        private static final long serialVersionUID = 1L;

        @Override
        public int getCurrentPage() {
            return table.getCurrentPage();
        }

        @Override
        public int getRowCount() {
            return table.getRowCount();
        }

        @Override
        public int getRowsPerPage() {
            return table.getRowsPerPage();
        }
    });

}

From source file:de.tudarmstadt.ukp.csniper.webapp.support.wicket.ExtendedNavigationToolbar.java

License:Apache License

/**
 * Constructor//from  www .j a v  a 2 s. c o  m
 * 
 * @param table
 *            data table this toolbar will be attached to
 */
@SuppressWarnings("rawtypes")
public ExtendedNavigationToolbar(final DataTable<?, String> table) {
    super(table);

    WebMarkupContainer span = (WebMarkupContainer) get("span");
    span.add(new Form("form") {
        private static final long serialVersionUID = 1L;

        {
            final NumberTextField<Long> jumpto = new NumberTextField<Long>("jumpto", new Model<Long>()) {
                private static final long serialVersionUID = 1L;

                @Override
                public void onConfigure() {
                    super.onConfigure();
                    setModelObject(table.getCurrentPage() + 1);
                    setMinimum(1L);
                    setMaximum(table.getPageCount());
                }
            };
            jumpto.setType(Long.class);
            add(jumpto);
            add(new Button("jumptoButton") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onSubmit() {
                    table.setCurrentPage(jumpto.getModelObject() - 1);
                }
            });
        }
    });
}

From source file:dk.teachus.frontend.components.list.ListPanel.java

License:Apache License

private AjaxNavigationToolbar createNavigationToolbar(DataTable<T> dataTable) {
    return new AjaxNavigationToolbar(dataTable) {
        private static final long serialVersionUID = 1L;

        @Override/*from w  ww .j  ava2s  .  co m*/
        protected WebComponent newNavigatorLabel(String navigatorId, final DataTable<?> table) {
            Label label = new Label(navigatorId, new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    int of = table.getRowCount();
                    int from = table.getCurrentPage() * table.getItemsPerPage();
                    int to = Math.min(of, from + table.getItemsPerPage());

                    from++;

                    if (of == 0) {
                        from = 0;
                        to = 0;
                    }

                    String label = TeachUsSession.get().getString("ListPanel.navigatorLabel");
                    label = label.replace("${from}", "" + from);
                    label = label.replace("${to}", "" + to);
                    label = label.replace("${of}", "" + of);

                    return label;
                }
            });
            label.setRenderBodyOnly(true);
            return label;
        }

        @Override
        protected PagingNavigator newPagingNavigator(String navigatorId, DataTable<?> table) {
            return new AjaxPagingNavigator(navigatorId, table) {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onAjaxEvent(final AjaxRequestTarget target) {
                    target.add(getTable());
                }

                @Override
                protected Link<?> newPagingNavigationLink(String id, IPageable pageable, final int pageNumber) {
                    final Link<?> pagingNavigationLink = super.newPagingNavigationLink(id, pageable,
                            pageNumber);
                    pagingNavigationLink.setBody(Model.of(""));
                    pagingNavigationLink
                            .add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
                                private static final long serialVersionUID = 1L;

                                @Override
                                public String getObject() {
                                    String cls = "btn btn-mini";
                                    if (pageNumber == 0) {
                                        cls += " icon-fast-backward";
                                    } else {
                                        cls += " icon-fast-forward";
                                    }
                                    if (false == pagingNavigationLink.isEnabled()) {
                                        cls += " disabled";
                                    }
                                    return cls;
                                }
                            }));
                    return pagingNavigationLink;
                }

                @Override
                protected Link<?> newPagingNavigationIncrementLink(String id, IPageable pageable,
                        final int increment) {
                    final Link<?> pagingNavigationIncrementLink = super.newPagingNavigationIncrementLink(id,
                            pageable, increment);
                    pagingNavigationIncrementLink.setBody(Model.of(""));
                    pagingNavigationIncrementLink
                            .add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
                                private static final long serialVersionUID = 1L;

                                @Override
                                public String getObject() {
                                    String cls = "btn btn-mini";
                                    if (increment < 0) {
                                        cls += " icon-backward";
                                    } else {
                                        cls += " icon-forward";
                                    }
                                    if (false == pagingNavigationIncrementLink.isEnabled()) {
                                        cls += " disabled";
                                    }
                                    return cls;
                                }
                            }));
                    return pagingNavigationIncrementLink;
                }

                @Override
                protected PagingNavigation newNavigation(String id, IPageable pageable,
                        IPagingLabelProvider labelProvider) {
                    return new AjaxPagingNavigation(id, pageable, labelProvider) {
                        private static final long serialVersionUID = 1L;

                        @Override
                        protected Link<?> newPagingNavigationLink(String id, IPageable pageable,
                                int pageIndex) {
                            final Link<?> pagingNavigationLink = super.newPagingNavigationLink(id, pageable,
                                    pageIndex);
                            pagingNavigationLink
                                    .add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
                                        private static final long serialVersionUID = 1L;

                                        @Override
                                        public String getObject() {
                                            StringBuilder cls = new StringBuilder();
                                            cls.append("btn btn-mini");
                                            if (false == pagingNavigationLink.isEnabled()) {
                                                cls.append(" btn-primary disabled");
                                            }
                                            return cls.toString();
                                        }
                                    }));
                            return pagingNavigationLink;
                        }
                    };
                }
            };
        }
    };
}

From source file:org.sakaiproject.sitestats.tool.wicket.components.SakaiNavigatorLabel.java

License:Educational Community License

/**
 * @param id component id//from   w w  w.ja  v a  2  s  .  co  m
 * @param table dataview
 */
public SakaiNavigatorLabel(final String id, final DataTable table) {
    this(id, new PageableComponent() {

        private static final long serialVersionUID = 1L;

        @Override
        public int getCurrentPage() {
            return (int) table.getCurrentPage();
        }

        @Override
        public int getRowCount() {
            return (int) table.getRowCount();
        }

        @Override
        public int getRowsPerPage() {
            return (int) table.getItemsPerPage();
        }

    });

}

From source file:org.sakaiproject.wicket.markup.html.repeater.data.table.ClassicNavigatorLabel.java

License:Educational Community License

/**
 * @param id//from w  w  w.  j a va 2s.  c o  m
 *            component id
 * @param table
 *            dataview
 */
public ClassicNavigatorLabel(final String id, final DataTable table) {
    this(id, new PageableComponent() {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        public int getCurrentPage() {
            return table.getCurrentPage();
        }

        public int getRowCount() {
            return table.getRowCount();
        }

        public int getRowsPerPage() {
            return table.getRowsPerPage();
        }

    });

}

From source file:sk.lazyman.gizmo.component.data.CountToolbar.java

License:Apache License

private IModel<String> createModel() {
    return new LoadableModel<String>() {

        @Override// w ww  .  j a va2s.c om
        protected String load() {
            long from = 0;
            long to = 0;
            long count = 0;

            IPageable pageable = getTable();
            if (pageable instanceof DataViewBase) {
                DataViewBase view = (DataViewBase) pageable;

                from = view.getFirstItemOffset() + 1;
                to = from + view.getItemsPerPage() - 1;
                long itemCount = view.getItemCount();
                if (to > itemCount) {
                    to = itemCount;
                }
                count = itemCount;
            } else if (pageable instanceof DataTable) {
                DataTable table = (DataTable) pageable;

                from = table.getCurrentPage() * table.getItemsPerPage() + 1;
                to = from + table.getItemsPerPage() - 1;
                long itemCount = table.getItemCount();
                if (to > itemCount) {
                    to = itemCount;
                }
                count = itemCount;
            }

            if (count > 0) {
                return new StringResourceModel("CountToolbar.label", CountToolbar.this, null,
                        new Object[] { from, to, count }).getString();
            }

            return new StringResourceModel("CountToolbar.noFound", CountToolbar.this, null).getString();
        }
    };
}