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

gwt 创建 超链接cell (HyperTextCell)的更多相关文章

  1. 如何在TextView类中创建超链接 Linkify

    Linkify是一个辅助类,通过RegEx样式匹配,自动地在TextView类(和继承的类)中创建超链接.符合特定的RegEx样式的文本会被转变成可点击的超链接,这些超链接隐式的调用startActi ...

  2. ios用storyboard快速创建静态cell

    在实际开发中经常会遇到下面这样的页面,通常我们用静态cell来做可以快速创建,提高效率 下面讲一下用storyboard创建方法,将一个tableViewController控制器拖入storyboa ...

  3. iOS UICollectionView(转一) XIB+纯代码创建:cell,头脚视图 cell间距

    之前用CollectionViewController只是皮毛,一些iOS从入门到精通的书上也是泛泛而谈.这几天好好的搞了搞苹果的开发文档上CollectionViewController的内容,亲身 ...

  4. 新浪微博客户端(22)-创建微博Cell

    DJStatusCell.h #import <UIKit/UIKit.h> @class DJStatusCellFrame; @interface DJStatusCell : UIT ...

  5. poi操作Word创建超链接

    项目引入poi: <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</ ...

  6. Winform中创建超链接,点击跳转网页

    代码如下: System.Diagnostics.Process ie = new System.Diagnostics.Process();ie.StartInfo.FileName = " ...

  7. a标签创建超链接,利用a标签创建锚点

    #Html今日学习内容 <!DOCTYPE html> <html> <head lang="en">     <meta charset ...

  8. swift 之 纯代码创建 cell

    初学swift 但是网上只有很多swift用xib创建的cell,就算是有也不是我想要的.今天自己弄了一个不用xib纯代码写的,来上代码 博客地址: https://github.com/liguol ...

  9. 使用xib创建cell时 bug

    UITableView (<UITableView: 0x15799a800; frame = (0 4797; 375 733); clipsToBounds = YES; tag = 305 ...

随机推荐

  1. 信号之system函数

    在http://www.cnblogs.com/nufangrensheng/p/3512291.html中已经有了一个system函数的实现,但是该版本并不执行任何信号处理.POSIX.1要求sys ...

  2. JForum 2.19源码部署到eclipse

    前两天在研究免费论坛,通过oschina和相关的文档查阅,最终选择了jforum,首先他是java写的,其次方便二次开发,而且有些论坛的源码都已经不在维护了,jforum最近几个月还是有更新的,但是从 ...

  3. Spring-boot使用Ehcache配置

    1.配置类 @Configuration @EnableCaching public class CacheConfiguration {// implements CachingConfigurer ...

  4. 简单的jquery选择器的实现

    function getByClass(oParent,oClass){    if(document.getElementsByClassName){         return document ...

  5. 关于SWT中的GridLayout布局方式

    GridLayout 布局的功能非常强大,也是笔者常用的一种布局方式.GridLayout是网格式布局,它把父组件分成一个表格,默认情况下每个子组件占据一个单元格的空间,每个子组件按添加到父组件的顺序 ...

  6. Microsoft Visual Studio 2013 Update 2 离线安装程序

    ☆ 微软官网地址:☆ http://www.microsoft.com/zh-cn/download/details.aspx?id=42665☆ 离线安装程序 直接下载链接:☆ Microsoft ...

  7. system.badimageformatexception 未能加载文件或程序集

    今天在调用dll文件的时候发现这样一个错误.      system.badimageformatexception 未能加载文件或程序集.   发现项目CPU默认Any CPU,我的系统是X64,将 ...

  8. MySQL与NoSQL——SQL与NoSQL的融合

    来源:http://www.cnblogs.com/sunli/archive/2011/05/11/mysql-nosql.html 写这一篇内容的原因是MySQL5.6.2突然推出了memcach ...

  9. WPF 中,如何使用自定义的resources

    第一步,先自己自定义一个Resources 1.新建一个xaml文件,在其中自定义好自己的Resources 这个Resource 的根节点是 <ResourceDictionary xmlns ...

  10. Java使用Flying Saucer实现HTML代码生成PDF文档

    1.需要的jar包:org.xhtmlrenderer.flying-saucer-pdf-itext5,Maven依赖如下: <dependency> <groupId>or ...