com.vaadin.v7.client.connectors.ClickableRendererConnector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vaadin-compatibility-client Show documentation
Show all versions of vaadin-compatibility-client Show documentation
Vaadin 7 compatibility package for Vaadin 8
/*
* Copyright (C) 2000-2024 Vaadin Ltd
*
* This program is available under Vaadin Commercial License and Service Terms.
*
* See for the full
* license.
*/
package com.vaadin.v7.client.connectors;
import com.google.web.bindery.event.shared.HandlerRegistration;
import com.vaadin.client.MouseEventDetailsBuilder;
import com.vaadin.v7.client.renderers.ClickableRenderer;
import com.vaadin.v7.client.renderers.ClickableRenderer.RendererClickEvent;
import com.vaadin.v7.client.renderers.ClickableRenderer.RendererClickHandler;
import com.vaadin.v7.shared.ui.grid.renderers.RendererClickRpc;
import elemental.json.JsonObject;
/**
* An abstract base class for {@link ClickableRenderer} connectors.
*
* @param
* the presentation type of the renderer
*
* @since 7.4
* @author Vaadin Ltd
*/
public abstract class ClickableRendererConnector
extends AbstractGridRendererConnector {
HandlerRegistration clickRegistration;
@Override
protected void init() {
clickRegistration = addClickHandler(
new RendererClickHandler() {
@Override
public void onClick(RendererClickEvent event) {
if (((GridConnector) getParent()).isReadOnly()) {
// NO-OP
return;
}
getRpcProxy(RendererClickRpc.class).click(
getRowKey(event.getCell().getRow()),
getColumnId(event.getCell().getColumn()),
MouseEventDetailsBuilder.buildMouseEventDetails(
event.getNativeEvent()));
}
});
}
@Override
public void onUnregister() {
clickRegistration.removeHandler();
}
protected abstract HandlerRegistration addClickHandler(
RendererClickHandler handler);
}