I used modifed CwCellList example to display custom Cells in a pager,
I couldn't display and scroll the celllist inside Pager, here is the
code for Pager:

public class PagerPanel extends AbstractPager {
          /**
           * The default increment size.
           */
          private static final int DEFAULT_INCREMENT = 20;

          /**
           * The increment size.
           */
          private int incrementSize = DEFAULT_INCREMENT;

          /**
           * The last scroll position.
           */
          private int lastScrollPos = 0;

          /**
           * The scrollable panel.
           */
          private final ScrollPanel scrollable = new Scrollable();

          /**
           * Construct a new {@link ShowMorePagerPanel}.
           */
          public PagerPanel() {
            // Do not let the scrollable take tab focus.
            initWidget(scrollable);
            scrollable.getElement().setTabIndex(-1);

            //setSize("200","200");
            // Handle scroll events.
            /*scrollable.addScrollHandler(new ScrollHandler() {
              public void onScroll(ScrollEvent event) {
                // If scrolling up, ignore the event.
                int oldScrollPos = lastScrollPos;
                lastScrollPos = scrollable.getVerticalScrollPosition();
                if (oldScrollPos >= lastScrollPos) {
                  return;
                }

                HasRows display = getDisplay();
                if (display == null) {
                  return;
                }
                int maxScrollTop = scrollable.getWidget().getOffsetHeight()
                    - scrollable.getOffsetHeight();
                if (lastScrollPos >= maxScrollTop) {
                  // We are near the end, so increase the page size.
                  int newPageSize = Math.min(
                      display.getVisibleRange().getLength() + incrementSize,
                      display.getRowCount());
                          display.setVisibleRange(0, newPageSize);
                }
              }
            });*/
          }

         /* public void onScroll(Widget widget, int start, int end) {
                    ScrollPanel scrollPanel = (ScrollPanel) widget;

                // If scrolling up, ignore the event.
                int oldScrollPos = lastScrollPos;
                lastScrollPos = scrollPanel.getVerticalScrollPosition();
                if (oldScrollPos >= lastScrollPos) {
                  return;
                }

                HasRows display = getDisplay();
                if (display == null) {
                  return;
                }
                int maxScrollTop = scrollPanel.getWidget().getOffsetHeight()
                    - scrollPanel.getOffsetHeight();
                if (lastScrollPos >= maxScrollTop) {
                  // We are near the end, so increase the page size.
                  int newPageSize = Math.min(
                      display.getVisibleRange().getLength() + incrementSize,
                      display.getRowCount());
                          display.setVisibleRange(0, newPageSize);
                }
              }*/



          /**
           * Get the number of rows by which the range is increased when the
scrollbar
           * reaches the bottom.
           *
           * @return the increment size
           */
          public int getIncrementSize() {
            return incrementSize;
          }

          @Override
          public void setDisplay(HasRows display) {
            assert display instanceof Widget : "display must extend Widget";
            scrollable.setWidget((Widget) display);
            super.setDisplay(display);
          }

          /**
           * @param incrementSize the incremental number of rows
           */
          public void setIncrementSize(int incrementSize) {
            this.incrementSize = incrementSize;
          }

          @Override
          protected void onRangeOrRowCountChanged() {
          }

          class Scrollable extends ScrollPanel implements ScrollHandler {

                  public Scrollable() {
                          sinkEvents(Event.ONSCROLL);
                          addScrollHandler(this);
                          setSize("200px","200px");
                  }

                public void onScroll(ScrollEvent event) {
                        GWT.log("scrolling?");
                }

                /*public void onBrowserEvent(Event event) {
                        if (DOM.eventGetType(event) == Event.ONSCROLL) {
                                GWT.log("on scroll event!");
                        } else {
                                super.onBrowserEvent(event);
                        }
                }*/
        }
}
--------------------------CwCellList---------------------------------
public class CwCellList extends Composite {

          /**
           * The UiBinder interface used by this example.
           */
          //@ShowcaseSource
         // interface Binder extends UiBinder<Widget, CwCellList> {
          //}

          /**
           * The constants used in this Content Widget.
           */
          //@ShowcaseSource
         /* public static interface CwConstants extends Constants {
                String cwCellListName();
            String cwCellListDescription();
            String cwCellListOther();
          }*/

          /**
           * The images used for this example.
           */
         // @ShowcaseSource
          static interface Images extends ClientBundle {
                //@Source("listImage.png")
            ImageResource listImage();
          }

          /**
           * The Cell used to render a {@link Listing Info}.
           */
          //@ShowcaseSource
          static class AddCell extends AbstractCell<AddTarget> {

            /**
             * The html of the image used for contacts.
             */
            private final String imageHtml;

            public AddCell(ImageResource image) {
              this.imageHtml =
AbstractImagePrototype.create(image).getHTML();
            }

            @Override
            public void render(Cell.Context key, AddTarget value,
SafeHtmlBuilder sb) {
              // Value can be null, so do a null check..
              if (value == null) {
                return;
              }

              sb.appendHtmlConstant("<table>");

              // Add the contact image.
              sb.appendHtmlConstant("<tr><td rowspan='3'>");
              sb.appendHtmlConstant(imageHtml);
              sb.appendHtmlConstant("</td>");

              // Add the name and address.
              sb.appendHtmlConstant("<td style='font-size:95%;'>");
              sb.appendEscaped(value.getTagLine());//getListingName());
              sb.appendHtmlConstant("</td></tr><tr><td>");
              sb.appendEscaped(value.getDescription());
              sb.appendHtmlConstant("</td></tr></table>");
            }
          }

          /**
           * The pager used to change the range of data.
           */
          //@ShowcaseData
          //@UiField
          private PagerPanel pagerPanel;

          /**
           * The pager used to display the current range.
           */
          //@ShowcaseData
          //@UiField
          private RangeLabelPager rangeLabelPager;

          private static List<AddTarget> newTargets;

          /**
           * The CellList.
           */
         // @ShowcaseData
          private static CellList<AddTarget> cellList;

          private DataProvider dataProvider;

          private Panel contentContainer;

          /**
           * Constructor.
           *
           * @param constants the constants
           */
          public CwCellList(PagerPanel pagerPanel, Panel contentContainer) {
          //public CwCellList(CwConstants constants) {
            //super(constants.cwCellListName(),
constants.cwCellListDescription(), false,
                //"ContactDatabase.java", "CwCellList.ui.xml",
"ContactInfoForm.java",
                //"PagerPanel.java", "RangeLabelPager.java");
                  this.pagerPanel = pagerPanel;
                  this.contentContainer = contentContainer;
                  onInitialize();
          }

          /**
           * Initialize this example.
           */
          //@ShowcaseSource
          //@Override
          public void onInitialize() {
            Images images = GWT.create(Images.class);

            // Create a CellList.
            AddCell addCell = new AddCell(images.listImage());

            // Set a key provider that provides a unique key for each
contact. If key is
            // used to identify contacts when fields (such as the name and
address)
            cellList = new CellList<AddTarget>(addCell,
AddTarget.KEY_PROVIDER);
            cellList.setPageSize(20);
        
cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE);
        
cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);

            // Add a selection model so we can select cells.
            final SingleSelectionModel<AddTarget> selectionModel = new
SingleSelectionModel<AddTarget>(
                        AddTarget.KEY_PROVIDER);
            cellList.setSelectionModel(selectionModel);
            selectionModel.addSelectionChangeHandler(new
SelectionChangeEvent.Handler() {
              public void onSelectionChange(SelectionChangeEvent event) {
          //do stuff
              }
            });

            dataProvider = new DataProvider();
            dataProvider.addDataDisplay(cellList);
            initWidget(cellList);
            //return widget;
          }

        private static class DataProvider extends
AsyncDataProvider<AddTarget> {
                @Override
                protected void onRangeChanged(HasData<AddTarget> display) {
                        // Get the new range.
                        final Range range = display.getVisibleRange();
                        int start = range.getStart();
                        int length = range.getLength();
                        if (newTargets != null)
                                //cellList.setRowData(start, newTargets);
                        updateRowData(start, newTargets);
                }

        }
          //update celllist from server
          public void populate(List<AddTarget> addTargets) {
                this.newTargets = addTargets;
                if (newTargets != null) {
                        cellList.setRowCount(newTargets.size(), true);
                        this.cellList.setRowData(0,addTargets);
                        pagerPanel.setDisplay(cellList);
                        History.newItem("Search", false);
                }

          }

}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to