Package com.wot.client

Source Code of com.wot.client.CLickableImageResourceCell

package com.wot.client;

import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.ValueUpdater;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.ImageResourceRenderer;

public class CLickableImageResourceCell extends AbstractCell<ImageResource> {

  private static ImageResourceRenderer renderer;

    public CLickableImageResourceCell () {
        super("click");
        if (renderer == null) {
            renderer = new ImageResourceRenderer();
        }
    }

    @Override
    public void onBrowserEvent(Context context, final Element parent, ImageResource value, NativeEvent event,
            ValueUpdater<ImageResource> valueUpdater) {
        super.onBrowserEvent(context, parent, value, event, valueUpdater);
        if (event.getType().equals("click")) {
            if(valueUpdater != null) {
                valueUpdater.update(value);
            }
        }
    }

    @Override
    public void render(com.google.gwt.cell.client.Cell.Context context,
            ImageResource value, final SafeHtmlBuilder sb) {
          sb.append(renderer.render(value));
    }

}
TOP

Related Classes of com.wot.client.CLickableImageResourceCell

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.