Skip to content

Instantly share code, notes, and snippets.

@christiangoudreau
Last active August 29, 2015 14:04
Show Gist options
  • Save christiangoudreau/1c02d86cfcb756cb2bf6 to your computer and use it in GitHub Desktop.
Save christiangoudreau/1c02d86cfcb756cb2bf6 to your computer and use it in GitHub Desktop.
table.addCellPreviewHandler(new CellPreviewEvent.Handler<Document>() {
@Override
public void onCellPreview(CellPreviewEvent<Document> event) {
if (BrowserEvents.MOUSEOVER.equals(event.getNativeEvent().getType())) {
overDocument = event.getValue();
}
}
});
table.addAttachHandler(new Handler() {
@Override
public void onAttachOrDetach(AttachEvent event) {
if (event.isAttached()) {
initTooltip(table);
}
}
});
}
private void initTooltip(CellTable<Document> documents) {
TooltipOptions options = new TooltipOptions();
options.withContent(new TooltipContentProvider() {
@Override
public String getContent(Element element) {
return documentTemplates.documentThumbnailTooltip(overDocument.getThumbnailUrl()).asString();
}
});
options.withPlacement(TooltipPlacement.LEFT);
options.withSelector(fontsResources.icons().icon_preview());
options.withContainer("element");
$(documents).as(Tooltip.class).tooltip(options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment