如何使用GWT 2.1数据表示小部件

如何使用GWT 2.1数据表示小部件,第1张

如何使用GWT 2.1数据表示小部件

Google I / O
2010-GWT的UI大修

2.1中的javadocs包com.google.gwt.cell.client

里程碑2的Eclipse更新站点

当代码在Bikeshed中时,将此行添加到gwt.xml文件中:

<inherits name='com.google.gwt.requestfactory.RequestFactory'/>

以下示例如下:

  • 具有PageSizePager的TextCells的CellList
  • 具有SimplePager的TextCells的CellList
  • 具有SimplePager和PageSizePager(buggy)的TextCell的CellList
  • 带字符串标题和TextCell标题的CellTable

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<String> values = new ArrayList<String>();        values.add("one");        values.add("two");        values.add("three");        values.add("four");        values.add("five");        values.add("six");        // create a ListViewAdapter        ListViewAdapter<String> lva = new ListViewAdapter<String>();        // give the ListViewAdapter our data        lva.setList(values);        { // CellList of TextCells with PageSizePager CellList<String> cl = new CellList<String>(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<String> psp = new PageSizePager<String>(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("<hr />"));        { // CellList of TextCells with a SimplePager CellList<String> cl = new CellList<String>(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<String> pager = new SimplePager<String>(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("<hr />"));        { // CellList of TextCells with a SimplePager and PageSizePager CellList<String> cl = new CellList<String>(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<String> psp = new PageSizePager<String>(cl, 1); // create a pager, giving it a handle to the CellList SimplePager<String> pager = new SimplePager<String>(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("<hr />"));        { // CellTable CellTable<String> ct = new CellTable<String>(); ct.setPageSize(2); lva.addView(ct); // add a column with a simple string header        ct.addColumn(new TextColumn<String>() { @Override public String getValue(String object) {     return object; }        }, "String Header");        //add a column with a TextCell header        ct.addColumn(new TextColumn<String>() { @Override public String getValue(String object) {     return "%" + object + "%"; }        }, new Header<String>(new TextCell()) { @Override public String getValue() {     return "TextCell Header"; }        }); // create a pager, giving it a handle to the CellTable SimplePager<String> pager = new SimplePager<String>(ct,         SimplePager.TextLocation.CENTER); // add the CellList to the page RootPanel.get().add(ct); // add the Pager to the page RootPanel.get().add(pager);        }    }}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5478682.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存