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. STL——空间的配置和释放std::alloc(第一级配置器和第二级配置器)

    1 空间的配置和释放,std::alloc 对象构造前的空间配置和对象析构后的空间释放,由<stl_alloc.h>负责,SGI对此的设计哲学如下: 向system heap要求空间 考虑 ...

  2. Android 导入导出CSV,xls文件 .

    1 . http://www.bangchui.org/read.php?tid=62 2 .http://blog.csdn.net/xinzheng_wang/article/details/77 ...

  3. iOS 开发中使用 NSURLProtocol 拦截 HTTP 请求

    这篇文章会提供一种在 Cocoa 层拦截所有 HTTP 请求的方法,其实标题已经说明了拦截 HTTP 请求需要的了解的就是 NSURLProtocol. 由于文章的内容较长,会分成两部分,这篇文章介绍 ...

  4. Java基础知识强化100:JVM 内存模型

    一. JVM内存模型总体架构图:  方法区和堆由所有线程共享,其他区域都是线程私有的 二. JVM内存模型的结构分析: 1. 类装载器(classLoader) 类装载器,它是在java虚拟机中用途是 ...

  5. h5拖放-上传图片预览功能

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  6. jsp The requested resource (/demo10/loginBean) is not available.

    The requested resource (/demo10/loginBean) is not available. <?xml version="1.0" encodi ...

  7. iOS之用xib给控件设置圆角、边框效果

    xib中为各种控件设置圆角 通过代码的方式设置 @interface ViewController () @property (weak, nonatomic) IBOutlet UIView *my ...

  8. 如何解决linux(ubuntu/CENTOS)中gedit中文乱码的问题

    http://jingyan.baidu.com/article/1709ad80a443c54634c4f09c.html 同时按键盘的Alt 和 F2,就可以打开“运行程序”对话框,这个功能类似于 ...

  9. Apache Mesos总体架构

    http://developer.51cto.com/art/201401/426507.htm 1. 前言 同其他大部分分布式系统一样,Apache Mesos为了简化设计,也是采用了master/ ...

  10. JNI的一些使用

    1.简介 Java Native Interface(JNI) 有时候我们必须要调用本地代码c/c++来克服java中的内存管理和性能限制.java支持通过Java Native Interface( ...