- 浏览: 510068 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (156)
- xml (4)
- web前端 (24)
- jQuery (18)
- java (38)
- SQL (9)
- perl (2)
- OTRS (1)
- GWT (4)
- Linux (32)
- Maven (2)
- Spring (2)
- Oracle Win7 (1)
- css (8)
- eclipse (3)
- mysql (11)
- tomcat (5)
- git (4)
- javascript (22)
- font (1)
- android (1)
- log4j (1)
- email (1)
- sublime plugin (1)
- html (2)
- matches (1)
- php (3)
- apache (3)
- gd (1)
- docker (5)
- rails (1)
- RabbitMQ (1)
- Ubuntu (3)
- L2TP VPN (1)
- nodejs (1)
- oraclejet (1)
- ubutun (1)
- ntp (1)
- ngix (1)
- ssl (1)
- https (1)
- Linux,Debian (2)
- dpkg (1)
- pac (1)
- vi (1)
- vim (1)
- java,http (0)
- httpClient (0)
- shutter (1)
- shell (1)
- redmine (1)
最新评论
-
纵观全局:
配置之后,连接显示不是私密连接
keytool生成证书与Tomcat SSL配置 -
zhuchao_ko:
可以 伪造
java获得ip地址 -
longhua2003:
代码太乱了
java下载文件 -
tomhat:
ccx410 写道 安装gwt报错,unable to ret ...
GWT CellTable -
ccx410:
安装gwt报错,unable to retrieve osgi ...
GWT CellTable
package com.cn.client;
import java.util.ArrayList;
import java.util.List;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.Cell;
import com.google.gwt.cell.client.CheckboxCell;
import com.google.gwt.cell.client.CompositeCell;
import com.google.gwt.cell.client.FieldUpdater;
import com.google.gwt.cell.client.HasCell;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.cellview.client.CellList;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.view.client.DefaultSelectionEventManager;
import com.google.gwt.view.client.MultiSelectionModel;
import com.google.gwt.view.client.ProvidesKey;
import com.google.gwt.view.client.SelectionChangeEvent;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class CellTest implements EntryPoint {
private Cell<Department> contactCell;
private Label selectedLabel = new Label();
public void onModuleLoad() {
List<Department> depts = new ArrayList<Department>();
Department c = new Department("项目部");
c.setId(1);
Department c1 = new Department("财务部");
c1.setId(2);
Department c2 = new Department("开发部");
c2.setId(3);
Department c3 = new Department("测试部");
c3.setId(149);
depts.add(c);
depts.add(c1);
depts.add(c2);
depts.add(c3);
final DefaultSelectionEventManager<Department> selectionManager = DefaultSelectionEventManager.createCheckboxManager();
final MultiSelectionModel<Department> selectionModel = new MultiSelectionModel<Department>(DepartmentCell.KEY_PROVIDER);
selectionModel.addSelectionChangeHandler(
new SelectionChangeEvent.Handler() {
public void onSelectionChange(SelectionChangeEvent event) {
StringBuilder sb = new StringBuilder();
boolean first = true;
List<Department> selected = new ArrayList<Department>(
selectionModel.getSelectedSet());
for (Department value : selected) {
if (first) {
first = false;
} else {
sb.append(",");
}
sb.append(value.getName());
}
selectedLabel.setText("选择:"+sb.toString());
}
});
List<HasCell<Department, ?>> hasCells = new ArrayList<HasCell<Department, ?>>();
hasCells.add(new HasCell<Department, Boolean>() {
private CheckboxCell cell = new CheckboxCell(true, false);
public Cell<Boolean> getCell() {
return cell;
}
public FieldUpdater<Department, Boolean> getFieldUpdater() {
return null;
}
public Boolean getValue(Department object) {
return selectionModel.isSelected(object);
}
});
hasCells.add(new HasCell<Department, Department>() {
private DepartmentCell cell = new DepartmentCell();
public Cell<Department> getCell() {
return cell;
}
public FieldUpdater<Department, Department> getFieldUpdater() {
return null;
}
public Department getValue(Department object) {
return object;
}
});
contactCell = new CompositeCell<Department>(hasCells) {
@Override
public void render(Context context, Department value, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<table><tbody><tr>");
super.render(context, value, sb);
sb.appendHtmlConstant("</tr></tbody></table>");
}
@Override
protected Element getContainerElement(Element parent) {
return parent.getFirstChildElement().getFirstChildElement().getFirstChildElement();
}
@Override
protected <X> void render(Context context, Department value,
SafeHtmlBuilder sb, HasCell<Department, X> hasCell) {
Cell<X> cell = hasCell.getCell();
sb.appendHtmlConstant("<td>");
cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</td>");
}
};
final CellList<Department> cellList = new CellList<Department>(contactCell);
cellList.setRowData(depts);
cellList.setSelectionModel(selectionModel,selectionManager);
HorizontalPanel hpanel = new HorizontalPanel();
VerticalPanel vpanel = new VerticalPanel();
vpanel.add(cellList);
vpanel.add(selectedLabel);
Button submitButton = new Button("提交");
submitButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if(selectedLabel.getText() == null && selectedLabel.getText().equals("")){
Window.alert("没有选择!");
}else{
Window.alert(selectedLabel.getText());
}
}
});
hpanel.add(vpanel);
hpanel.add(submitButton);
RootPanel.get("root").add(hpanel);
}
private static class DepartmentCell extends AbstractCell<Department> {
@Override
public void render(Context context,Department value, SafeHtmlBuilder sb) {
if (value == null) {
return;
}
sb.appendHtmlConstant("<table>");
sb.appendHtmlConstant("<td style='font-size:95%;'>");
sb.appendEscaped(value.getName());
sb.appendHtmlConstant("</td></tr></table>");
}
public static final ProvidesKey<Department> KEY_PROVIDER = new ProvidesKey<Department>() {
@Override
public Object getKey(Department item) {
return item == null ? null : item.getId();
}
};
}
private class Department implements Comparable<Department> {
private int id;
private String name;
public Department(String name) {
super();
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public int compareTo(Department o) {
return (o == null || o.name == null) ? -1 : -o.name.compareTo(name);
}
@Override
public boolean equals(Object o) {
if (o instanceof Department) {
return id == ((Department) o).id;
}
return false;
}
}
}
要实现单选则:cellList.setSelectionModel(selectionModel);
要实现多选则:cellList.setSelectionModel(selectionModel,selectionManager);
import java.util.ArrayList;
import java.util.List;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.Cell;
import com.google.gwt.cell.client.CheckboxCell;
import com.google.gwt.cell.client.CompositeCell;
import com.google.gwt.cell.client.FieldUpdater;
import com.google.gwt.cell.client.HasCell;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.cellview.client.CellList;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.view.client.DefaultSelectionEventManager;
import com.google.gwt.view.client.MultiSelectionModel;
import com.google.gwt.view.client.ProvidesKey;
import com.google.gwt.view.client.SelectionChangeEvent;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class CellTest implements EntryPoint {
private Cell<Department> contactCell;
private Label selectedLabel = new Label();
public void onModuleLoad() {
List<Department> depts = new ArrayList<Department>();
Department c = new Department("项目部");
c.setId(1);
Department c1 = new Department("财务部");
c1.setId(2);
Department c2 = new Department("开发部");
c2.setId(3);
Department c3 = new Department("测试部");
c3.setId(149);
depts.add(c);
depts.add(c1);
depts.add(c2);
depts.add(c3);
final DefaultSelectionEventManager<Department> selectionManager = DefaultSelectionEventManager.createCheckboxManager();
final MultiSelectionModel<Department> selectionModel = new MultiSelectionModel<Department>(DepartmentCell.KEY_PROVIDER);
selectionModel.addSelectionChangeHandler(
new SelectionChangeEvent.Handler() {
public void onSelectionChange(SelectionChangeEvent event) {
StringBuilder sb = new StringBuilder();
boolean first = true;
List<Department> selected = new ArrayList<Department>(
selectionModel.getSelectedSet());
for (Department value : selected) {
if (first) {
first = false;
} else {
sb.append(",");
}
sb.append(value.getName());
}
selectedLabel.setText("选择:"+sb.toString());
}
});
List<HasCell<Department, ?>> hasCells = new ArrayList<HasCell<Department, ?>>();
hasCells.add(new HasCell<Department, Boolean>() {
private CheckboxCell cell = new CheckboxCell(true, false);
public Cell<Boolean> getCell() {
return cell;
}
public FieldUpdater<Department, Boolean> getFieldUpdater() {
return null;
}
public Boolean getValue(Department object) {
return selectionModel.isSelected(object);
}
});
hasCells.add(new HasCell<Department, Department>() {
private DepartmentCell cell = new DepartmentCell();
public Cell<Department> getCell() {
return cell;
}
public FieldUpdater<Department, Department> getFieldUpdater() {
return null;
}
public Department getValue(Department object) {
return object;
}
});
contactCell = new CompositeCell<Department>(hasCells) {
@Override
public void render(Context context, Department value, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<table><tbody><tr>");
super.render(context, value, sb);
sb.appendHtmlConstant("</tr></tbody></table>");
}
@Override
protected Element getContainerElement(Element parent) {
return parent.getFirstChildElement().getFirstChildElement().getFirstChildElement();
}
@Override
protected <X> void render(Context context, Department value,
SafeHtmlBuilder sb, HasCell<Department, X> hasCell) {
Cell<X> cell = hasCell.getCell();
sb.appendHtmlConstant("<td>");
cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</td>");
}
};
final CellList<Department> cellList = new CellList<Department>(contactCell);
cellList.setRowData(depts);
cellList.setSelectionModel(selectionModel,selectionManager);
HorizontalPanel hpanel = new HorizontalPanel();
VerticalPanel vpanel = new VerticalPanel();
vpanel.add(cellList);
vpanel.add(selectedLabel);
Button submitButton = new Button("提交");
submitButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if(selectedLabel.getText() == null && selectedLabel.getText().equals("")){
Window.alert("没有选择!");
}else{
Window.alert(selectedLabel.getText());
}
}
});
hpanel.add(vpanel);
hpanel.add(submitButton);
RootPanel.get("root").add(hpanel);
}
private static class DepartmentCell extends AbstractCell<Department> {
@Override
public void render(Context context,Department value, SafeHtmlBuilder sb) {
if (value == null) {
return;
}
sb.appendHtmlConstant("<table>");
sb.appendHtmlConstant("<td style='font-size:95%;'>");
sb.appendEscaped(value.getName());
sb.appendHtmlConstant("</td></tr></table>");
}
public static final ProvidesKey<Department> KEY_PROVIDER = new ProvidesKey<Department>() {
@Override
public Object getKey(Department item) {
return item == null ? null : item.getId();
}
};
}
private class Department implements Comparable<Department> {
private int id;
private String name;
public Department(String name) {
super();
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public int compareTo(Department o) {
return (o == null || o.name == null) ? -1 : -o.name.compareTo(name);
}
@Override
public boolean equals(Object o) {
if (o instanceof Department) {
return id == ((Department) o).id;
}
return false;
}
}
}
要实现单选则:cellList.setSelectionModel(selectionModel);
要实现多选则:cellList.setSelectionModel(selectionModel,selectionManager);
发表评论
-
Apache HTTPClient 忽略证书
2019-01-25 15:03 1612/** * httpclient4.5.2版 * ... -
HTTP 返回码
2019-01-24 15:28 427HTTP1.1新增了五种请求方法:OPTIONS、PUT、PA ... -
Java SizeToHuman 大小转换为mb kb tb等
2017-08-21 15:12 1653public class TestSizeToHuman ... -
javascript 监听键盘事件
2017-04-14 10:38 2812var ie; var firefox; ... -
JavaScript从数组中删除指定值元素的方法
2016-10-11 13:13 754下面的代码使用了两种方式删除数组的元素,第一种定义一个单独的函 ... -
CSS几种特效整理
2016-04-19 09:55 539css用伪类before和after制作三角形箭头网上有一堆教 ... -
java常规格式化说明
2016-01-20 17:27 1384转 换 符说 明 ... -
java验证是否包含特殊字符/\:*?"<>
2016-01-05 15:25 8767public class MatchTest { ... -
js 一些知识,js获取contxtPath
2015-11-12 13:49 1210var num = 1; var str = '1'; ... -
IE指定文档模式
2015-10-15 15:21 1027对于 Web 开发人员来说,文本兼容性是一个要考虑的重要问题。 ... -
JSP和JSTL获取服务器参数
2015-09-11 13:57 1200<%@ page language="java ... -
java计算时间差比较时间大小
2015-05-20 10:53 1121今天需要比较时间在网上找到然后写下: 比如:现在是:200 ... -
java发邮件
2014-11-19 15:37 1237一、 import java.util.Date; im ... -
java log4j.properties
2014-11-18 09:30 922log4j.properties配置文件如下: log4j ... -
java获得ip地址
2014-11-17 18:18 1330public String getIpAddr(Htt ... -
java下载文件
2014-11-07 10:57 1100// 文件名称中文乱码new String(filename. ... -
Android中RelativeLayout各个属性的含义
2014-10-11 15:06 877android:layout_above="@id ... -
Http发送请求
2014-09-17 15:01 902package wzh.Http; import j ... -
如何在一个页面上让多个jQuery版本共存
2014-09-10 10:22 919如何在一个页面上让多个jQuery共存呢?比如jquery-1 ... -
导出数据到excel
2014-09-03 16:20 1224/** * */ package com.chin ...
相关推荐
GWT,全称为Google Web Toolkit,是Google推出的一款开源JavaScript开发框架,允许Java开发者使用Java语言来编写Web应用。GWT通过编译器将Java代码转换为高效的JavaScript,从而在客户端浏览器上运行。这个“GWT入门...
GWT,全称为Google Web Toolkit,是一个开源的Java框架,用于构建高性能、可维护的富互联网应用程序(RIA)。GWT允许开发者使用Java语言编写客户端代码,然后通过编译器将其转换为优化过的JavaScript,以便在各种...
### GWT快速开发知识点详解 #### 一、GWT简介 **Google Web Toolkit (GWT)** 是由Google推出的一款开源的Java开发框架,主要用于构建高度交互式的Web应用程序,特别是那些类似Google Maps和Gmail这样的AJAX应用。...
GWT的Cell Widgets和CellTable允许你创建高度可定制的列表或表格,它们以数据驱动,可以高效渲染大量数据。 **5. Deferred Binding** GWT的Deferred Binding可以根据不同的浏览器或配置生成不同的代码,实现更好的...
GWT开发基础知识点 在本资源中,我们将讨论Google Web Toolkit(GWT)的基础知识点,包括GWT的安装、配置、编码基础和客户端代码编写等方面的内容。 GWT安装和配置 在Eclipse中添加GWT插件是使用GWT开发的第一步...
Gwt中文手册,GWt入门Gwt中文手册,GWt入门Gwt中文手册,GWt入门
标题 "GWT" 指的是 Google Web Toolkit,这是一个开源的Java开发框架,主要用于构建高性能、跨浏览器的富互联网应用程序(Rich Internet Applications,简称RIA)。GWT通过将Java代码编译为JavaScript,使得开发者...
SmartGWT是基于Google Web Toolkit (GWT) 的一个开源框架,它为开发富互联网应用程序(RIA)提供了丰富的组件库和高级功能。SmartGWT的最新版本进一步提升了用户体验,简化了开发过程,提供了更多现代Web设计的需求...
**GWT 概述** GWT(Google Web Toolkit)是由Google开发的一款开源的JavaScript开发框架,主要用于构建高性能、跨浏览器的Web应用程序。GWT通过Java语言进行开发,并将Java代码编译成高效的JavaScript,使得开发者...
**GWT(Google Web Toolkit)开发环境JAVA** Google Web Toolkit(GWT)是一个开放源代码的Java框架,它允许开发者使用Java语言来编写富互联网应用程序(Rich Internet Applications,RIA),并将其编译成优化的...
GWT提供了`DataGrid`或`CellTable`组件,它们可以绑定数据源并显示数据。这些组件支持分页、排序和过滤等功能,使得数据浏览更加灵活。同时,`AsyncCallback`可以用于异步加载数据,确保用户体验流畅。 3. **更新...
3. **用户界面改进**:GWT 2.5.0引入了新的UI组件和API,包括**Cell Widgets**,它们提供了一种更加灵活的方式来构建数据驱动的用户界面。同时,对于表单控件和布局管理也有显著优化。 4. **国际化支持**:增强了**...
Google Web Toolkit(GWT)是Google推出的一款开源的、基于Java的Web开发框架,它允许开发者使用Java语言来编写前端应用程序。GWT-2.8.2是该SDK的一个版本,提供了最新的特性和改进,旨在简化Web应用的开发流程,...
**GWT(Google Web Toolkit)简介** GWT,全称为Google Web Toolkit,是Google推出的一款开源的Java开发框架,主要用于构建高性能、跨浏览器的富互联网应用程序(Rich Internet Applications,简称RIA)。GWT允许...
GWT,全称为Google Web Toolkit,是一个开源的Java框架,用于构建高性能、跨浏览器的Web应用程序。这本书《GWT 揭秘》显然深入探讨了GWT的内部机制和使用技巧,通过源代码来帮助读者更好地理解和应用这个强大的工具...
此外,GWT社区还提供了许多第三方库,如GWT-Bootstrap和GWT-Platform,这些可以帮助开发者更轻松地构建现代、响应式的Web应用。 总之,Google插件SDK是开发GWT应用的关键组成部分,它与Eclipse IDE结合,为Java...
在IT行业中,有时候我们需要接手一些老项目,这些项目可能使用了过时的技术或框架,比如本文提到的Google Web Toolkit (GWT)。GWT是一种用于构建富互联网应用程序(RIA)的开源Java SDK,允许开发者使用Java语言编写...