List of usage examples for com.google.gwt.user.client.ui Image fireEvent
void fireEvent(GwtEvent<?> event);
From source file:org.rstudio.studio.client.shiny.ui.ShinyGadgetDialog.java
License:Open Source License
private void addCaptionWithCloseButton(String caption) { final Image closeIcon = new Image(new ImageResource2x(ThemeResources.INSTANCE.closeDialog2x())); Style closeIconStyle = closeIcon.getElement().getStyle(); closeIconStyle.setCursor(Style.Cursor.POINTER); closeIconStyle.setMarginTop(2, Unit.PX); FlexTable captionLayoutTable = new FlexTable(); captionLayoutTable.setWidth("100%"); captionLayoutTable.setText(0, 0, caption); captionLayoutTable.setWidget(0, 1, closeIcon); captionLayoutTable.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.HorizontalAlignmentConstant.endOf(Direction.LTR)); HTML captionWidget = (HTML) getCaption(); captionWidget.getElement().appendChild(captionLayoutTable.getElement()); captionWidget.addClickHandler(new ClickHandler() { @Override/*from www .java 2s. c om*/ public void onClick(ClickEvent event) { EventTarget target = event.getNativeEvent().getEventTarget(); Element targetElement = (Element) target.cast(); if (targetElement == closeIcon.getElement()) { closeIcon.fireEvent(event); } } }); closeIcon.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { performClose(); } }); }