import org.gwtbootstrap3.client.ui.Tooltip; //导入方法依赖的package包/类
@Override
public ImageListEditorView add(final SafeUri uri, final String width, final String height,
final SafeHtml heading, final SafeHtml text,
final boolean selected, final Command clickCommand) {
final VerticalPanel panel = new VerticalPanel();
panel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE);
panel.setHeight("100%");
final Image image = new Image(uri);
image.setWidth(width);
image.setHeight(height);
image.addStyleName(style.image());
final double alpha = selected ? 1 : 0.2;
image.getElement().setAttribute("style", "filter: alpha(opacity=5);opacity: " + alpha);
final Tooltip tooltip = new Tooltip();
tooltip.setTitle( text.asString() );
tooltip.setWidget(image);
tooltip.setContainer("body");
tooltip.setPlacement(Placement.BOTTOM);
tooltip.setIsAnimated(false);
tooltip.setShowDelayMs(100);
final HTML label = new HTML(heading.asString());
final HorizontalPanel labelPanel = new HorizontalPanel();
labelPanel.setWidth("100%");
labelPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
labelPanel.add(label);
panel.add(tooltip);
panel.add(labelPanel);
mainPanel.add(panel);
image.addClickHandler(e -> {
tooltip.hide();
tooltip.destroy();
clickCommand.execute();
});
return this;
}