How to use GWT 2.1 Data Presentation Widgets

后端 未结 6 1684
深忆病人
深忆病人 2020-11-30 19:05

At the 2010 Google IO it was announced that GWT 2.1 would include new Data Presentation Widgets. 2.1M is available for download, and presumably the widgets are included, but

6条回答
  •  再見小時候
    2020-11-30 19:43

    Google I/O 2010 - GWT's UI overhaul

    javadocs package com.google.gwt.cell.client in 2.1

    Eclipse update site for milestone 2

    While the code is in bikeshed, add this line to your gwt.xml file:

    
    

    The following examples follow:

    • CellList of TextCells with PageSizePager
    • CellList of TextCells with a SimplePager
    • CellList of TextCells with a SimplePager and PageSizePager(buggy) and
    • CellTable with String header and TextCell header

    package dpw.client;
    
    import java.util.ArrayList;
    
    import com.google.gwt.cell.client.TextCell;
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.cellview.client.CellList;
    import com.google.gwt.user.cellview.client.CellTable;
    import com.google.gwt.user.cellview.client.PageSizePager;
    import com.google.gwt.user.cellview.client.SimplePager;
    import com.google.gwt.user.cellview.client.TextColumn;
    import com.google.gwt.user.cellview.client.Header;
    import com.google.gwt.user.client.ui.HTML;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.google.gwt.view.client.ListViewAdapter;
    
    public class Index implements EntryPoint {
    
        public void onModuleLoad() {
    
            // create some data
            ArrayList values = new ArrayList();
            values.add("one");
            values.add("two");
            values.add("three");
            values.add("four");
            values.add("five");
            values.add("six");
    
            // create a ListViewAdapter
            ListViewAdapter lva = new ListViewAdapter();
            // give the ListViewAdapter our data
            lva.setList(values);
    
            {
                // CellList of TextCells with PageSizePager
                CellList cl = new CellList(new TextCell());
                // set the initial pagesize to 2
                cl.setPageSize(2);
    
                // add the CellLists to the adaptor
                lva.addView(cl);
    
                // create a PageSizePager, giving it a handle to the CellList
                PageSizePager psp = new PageSizePager(cl, 2);
    
                // add the CellList to the page
                RootPanel.get().add(cl);
    
                // add the PageSizePager to the page
                RootPanel.get().add(psp);
            }
    
            RootPanel.get().add(new HTML("
    ")); { // CellList of TextCells with a SimplePager CellList cl = new CellList(new TextCell()); // set the initial pageSize to 2 cl.setPageSize(2); // add the CellLists to the adaptor lva.addView(cl); // create a pager, giving it a handle to the CellList SimplePager pager = new SimplePager(cl, SimplePager.TextLocation.CENTER); // add the CellList to the page RootPanel.get().add(cl); // add the Pager to the page RootPanel.get().add(pager); } RootPanel.get().add(new HTML("
    ")); { // CellList of TextCells with a SimplePager and PageSizePager CellList cl = new CellList(new TextCell()); // set the initial pageSize to 2 cl.setPageSize(2); // add the CellLists to the adaptor lva.addView(cl); // create a PageSizePager, giving it a handle to the CellList PageSizePager psp = new PageSizePager(cl, 1); // create a pager, giving it a handle to the CellList SimplePager pager = new SimplePager(cl, SimplePager.TextLocation.CENTER); // add the CellList to the page RootPanel.get().add(cl); // add the Pager to the page RootPanel.get().add(pager); // add the PageSizePager to the page RootPanel.get().add(psp); } RootPanel.get().add(new HTML("
    ")); { // CellTable CellTable ct = new CellTable(); ct.setPageSize(2); lva.addView(ct); // add a column with a simple string header ct.addColumn(new TextColumn() { @Override public String getValue(String object) { return object; } }, "String Header"); //add a column with a TextCell header ct.addColumn(new TextColumn() { @Override public String getValue(String object) { return "%" + object + "%"; } }, new Header(new TextCell()) { @Override public String getValue() { return "TextCell Header"; } }); // create a pager, giving it a handle to the CellTable SimplePager pager = new SimplePager(ct, SimplePager.TextLocation.CENTER); // add the CellList to the page RootPanel.get().add(ct); // add the Pager to the page RootPanel.get().add(pager); } } }

提交回复
热议问题