如何使用GWT 2.1数据演示组件 [英] How to use GWT 2.1 Data Presentation Widgets

查看:126
本文介绍了如何使用GWT 2.1数据演示组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在2010年的Google IO中,宣布GWT 2.1将包含新的数据演示小部件。 2.1M可以下载,大概包含了小部件,但还没有文档出现。



是否有一个简短的教程或例子来说明如何使用它们?我曾看到一则传闻称 CellList CellTable 是有问题的类。对于他们来说,Javadoc充斥着大量的TODO,所以在使用方面仍然缺少一些。

ht =http://www.youtube.com/watch?v=g2XclEOJdIc&feature=PlayList&p=F01F46882D8A90AF&playnext_from=PL&index=0 =noreferrer> Google I / O 2010 - GWT的UI大修



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



Eclipse更新网站里程碑2



当代码处于自行车状态时,将此行添加到您的gwt.xml文件中:

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

以下示例:


  • 具有
    的TextCells的CellList PageSizePager
  • 带有
    SimplePager的TextCell的CellList

  • TextCells的CellList
    SimplePager和PageSizePager(buggy)

  • 带有String标题和
    的CellTable TextCell标题






  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;
导入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实现EntryPoint {

public void onModuleLoad(){

//创建一些数据
ArrayList< String> values = new ArrayList< String>();
values.add(one);
values.add(two);
values.add(three);
values.add(four);
values.add(five);
values.add(six);

//创建一个ListViewAdapter
ListViewAdapter< String> lva = new ListViewAdapter< String>();
//给ListViewAdapter提供我们的数据
lva.setList(values);

{
//带有PageSizePager的TextCell的CellList
CellList< String> cl = new CellList< String>(new TextCell());
//将初始页面大小设置为2
cl.setPageSize(2);

//将CellLists添加到适配器
lva.addView(cl);

//创建一个PageSizePager,给它一个CellList的句柄
PageSizePager< String> psp = new PageSizePager< String>(cl,2);

//将CellList添加到页面
RootPanel.get()。add(cl);

//将PageSizePager添加到页面
RootPanel.get()。add(psp);
}

RootPanel.get()。add(new HTML(< hr />));

{
//带有SimplePager的TextCell的CellList
CellList< String> cl = new CellList< String>(new TextCell());
//将初始pageSize设置为2
cl.setPageSize(2);

//将CellLists添加到适配器
lva.addView(cl);

//创建一个寻呼机,给它一个CellList的句柄
SimplePager< String> pager = new SimplePager< String>(cl,
SimplePager.TextLocation.CENTER);

//将CellList添加到页面
RootPanel.get()。add(cl);

//将寻呼机添加到页面
RootPanel.get()。add(pager);
}

RootPanel.get()。add(new HTML(< hr />));

{
//带有SimplePager和PageSizePager的TextCell的CellList
CellList< String> cl = new CellList< String>(new TextCell());
//将初始pageSize设置为2
cl.setPageSize(2);

//将CellLists添加到适配器
lva.addView(cl);

//创建一个PageSizePager,给它一个CellList的句柄
PageSizePager< String> psp = new PageSizePager< String>(cl,1);

//创建一个寻呼机,给它一个CellList的句柄
SimplePager< String> pager = new SimplePager< String>(cl,
SimplePager.TextLocation.CENTER);

//将CellList添加到页面
RootPanel.get()。add(cl);

//将寻呼机添加到页面
RootPanel.get()。add(pager);

//将PageSizePager添加到页面
RootPanel.get()。add(psp);
}

RootPanel.get()。add(new HTML(< hr />));

{
// CellTable
CellTable< String> ct = new CellTable< String>();
ct.setPageSize(2);
lva.addView(ct);

//添加一个包含简单字符串头的列
ct.addColumn(new TextColumn< String>(){

@Override
public String getValue(String object){
return object;
}
},String Header);

//添加一个带有TextCell头部的列
ct.addColumn(new TextColumn< String>(){

@Override
public String getValue (String object){
return%+ object +%;
}
},new Header< String>(new TextCell()){

@Override
public String getValue(){
returnTextCell Header;
}
});

//创建一个寻呼机,给它一个CellTable的句柄
SimplePager< String> pager = new SimplePager< String>(ct,
SimplePager.TextLocation.CENTER);

//将CellList添加到页面
RootPanel.get()。add(ct);

//将寻呼机添加到页面
RootPanel.get()。add(pager);
}
}
}


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 no documentation has yet surfaced.

Is there a short tutorial or example for how to use them? I've seen a rumor that CellList and CellTable are the classes in question. The Javadoc for them is riddled with lots of TODOs, so quite a bit is still missing in terms of usage.

解决方案

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:

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

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<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);
        }
    }
}

这篇关于如何使用GWT 2.1数据演示组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆