use of com.google.gwt.user.client.Event in project gwt-test-utils by gwt-test-utils.
the class ImageStatePatcher method fireSyntheticLoadEvent.
@PatchMethod
static void fireSyntheticLoadEvent(Object state, Image image) {
Event loadEvent = EventBuilder.create(Event.ONLOAD).build();
Browser.dispatchEvent(image, loadEvent);
}
use of com.google.gwt.user.client.Event in project gwt-test-utils by gwt-test-utils.
the class CompositeTest method fireNativeEvent_Wrapper.
@Test
public void fireNativeEvent_Wrapper() {
// Given
label.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
labelCount++;
assertThat(event.getSource()).isEqualTo(label);
assertThat(event.getRelativeElement()).isEqualTo(label.getElement());
}
});
composite.addDomHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
compositeCount++;
assertThat(event.getSource()).isEqualTo(composite);
assertThat(event.getRelativeElement()).isEqualTo(label.getElement());
}
}, ClickEvent.getType());
Event clickEvent = EventBuilder.create(Event.ONCLICK).build();
// When
DomEvent.fireNativeEvent(clickEvent, composite, composite.getElement());
// Then
assertThat(labelCount).isEqualTo(0);
assertThat(compositeCount).isEqualTo(1);
}
use of com.google.gwt.user.client.Event in project gwt-test-utils by gwt-test-utils.
the class DOMImplPatcher method dispatchEvent.
@PatchMethod
static void dispatchEvent(Object domImpl, Element target, NativeEvent evt) {
EventListener listener = DOM.getEventListener(target);
if (listener != null && evt instanceof Event) {
listener.onBrowserEvent((Event) evt);
}
// dispatch to parent if needed
boolean propagationStopped = JavaScriptObjects.getBoolean(evt, JsoProperties.EVENT_IS_STOPPED);
if (target.getParentElement() != null && propagationStopped) {
target.getParentElement().dispatchEvent(evt);
}
}
use of com.google.gwt.user.client.Event in project rstudio by rstudio.
the class FilesPane method showDataImportFileChoice.
@Override
public void showDataImportFileChoice(FileSystemItem file, Command onView, Command onImport) {
final ToolbarPopupMenu menu = new ToolbarPopupMenu();
String editLabel = AppCommand.formatMenuLabel(commands_.renameFile().getImageResource(), "View File", null);
String importLabel = AppCommand.formatMenuLabel(new ImageResource2x(StandardIcons.INSTANCE.import_dataset2x()), "Import Dataset...", null);
menu.addItem(new MenuItem(editLabel, true, onView));
menu.addItem(new MenuItem(importLabel, true, onImport));
menu.setPopupPositionAndShow(new PositionCallback() {
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
Event event = Event.getCurrentEvent();
PopupPositioner.setPopupPosition(menu, event.getClientX(), event.getClientY());
}
});
}
use of com.google.gwt.user.client.Event in project rstudio by rstudio.
the class FilesPane method showHtmlFileChoice.
@Override
public void showHtmlFileChoice(FileSystemItem file, Command onEdit, Command onBrowse) {
final ToolbarPopupMenu menu = new ToolbarPopupMenu();
String editLabel = AppCommand.formatMenuLabel(commands_.renameFile().getImageResource(), "Open in Editor", null);
String openLabel = AppCommand.formatMenuLabel(commands_.openHtmlExternal().getImageResource(), "View in Web Browser", null);
menu.addItem(new MenuItem(editLabel, true, onEdit));
menu.addItem(new MenuItem(openLabel, true, onBrowse));
menu.setPopupPositionAndShow(new PositionCallback() {
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
Event event = Event.getCurrentEvent();
PopupPositioner.setPopupPosition(menu, event.getClientX(), event.getClientY());
}
});
}
Aggregations