package com.cnblogs.hooligen.client;

import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.ValueUpdater;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder; public class HyperTextCell extends AbstractCell<String[]> {   interface HyperTextTemplate extends SafeHtmlTemplates {
    @Template("<a style=\"{0}\">{1}</a>")
    SafeHtml hyperText(String styleClass, String value);
  }   private static HyperTextTemplate template;   public HyperTextCell() {
    this("click");
  }   public HyperTextCell(String... consumedEvents) {
    super(consumedEvents);     if(template == null) {
      template = GWT.create(HyperTextTemplate.class);
    }
  }   @Override
  public void onBrowserEvent(Context context, Element parent, String[] value,
    NativeEvent event, ValueUpdater<String[]> valueUpdater) {
    super.onBrowserEvent(context, parent, value, event, valueUpdater);
    if("click".equals(event.getType())) {
      if (valueUpdater != null) {
        valueUpdater.update(value);
      }
    }   }   @Override
  public void render(Context context, String[] value, SafeHtmlBuilder sb) {
    if (value != null && value.length == 2) {
      sb.append(template.hyperText(value[0], value[1]));
    }
  } }

最新文章

  1. Microsoft Build 2016 Day 1 记录
  2. HTML5教程之html 5 本地数据库(Web Sql Database)
  3. A library of generic data structures
  4. require.js工作原理(初始)
  5. 完美解决google无法访问
  6. zabbix常用术语
  7. linux 配置java 环境
  8. 夺命雷公狗—angularjs—5—ng-switch的用法实现下拉更换板块的实现
  9. POJ 1995
  10. 内存管理算法--Buddy伙伴算法
  11. WCF入门教程系列三
  12. web.config中&lt;customErrors&gt;节点
  13. [置顶] 一个demo学会css
  14. 为什么要写 tf.Graph().as_default()
  15. SQL学习指南之查询入门
  16. 商业版微信小程序开发流程
  17. js判断手机邮箱格式(正则)
  18. C#实现接口IHttpModule完成统一的权限验证
  19. BZOJ2793[Poi2012]Vouchers——枚举
  20. cube-ui修改按钮颜色

热门文章

  1. phpcms v9 模板标签说明整理
  2. How to Analyze Java Thread Dumps--reference
  3. C# 之 SqlConnection 类
  4. zTree 异步加载
  5. Android_SystemService
  6. 主流存储引擎详解:Innodb,Tokudb、Memory、MYISAM、Federated
  7. [转]为什么python标准库没有实现链表
  8. Spring 的@Controller 和@RestController的区别
  9. JavaScript 一个等号 两个等号 三个等号的区别
  10. 【C#4.0图解教程】笔记(第9章~第18章)