Search in sources :

Example 21 with Event

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);
}
Also used : Event(com.google.gwt.user.client.Event) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 22 with Event

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);
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) DomEvent(com.google.gwt.event.dom.client.DomEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Event(com.google.gwt.user.client.Event) Test(org.junit.Test)

Example 23 with Event

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);
    }
}
Also used : Event(com.google.gwt.user.client.Event) EventListener(com.google.gwt.user.client.EventListener) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 24 with Event

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());
        }
    });
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) Event(com.google.gwt.user.client.Event) MenuItem(com.google.gwt.user.client.ui.MenuItem)

Example 25 with Event

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());
        }
    });
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback) Event(com.google.gwt.user.client.Event) MenuItem(com.google.gwt.user.client.ui.MenuItem)

Aggregations

Event (com.google.gwt.user.client.Event)31 EventListener (com.google.gwt.user.client.EventListener)12 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)10 ColumnSortEvent (com.google.gwt.user.cellview.client.ColumnSortEvent)7 SpanElement (com.google.gwt.dom.client.SpanElement)5 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)5 KeyboardEvent (elemental.events.KeyboardEvent)5 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)4 Test (org.junit.Test)4 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)3 KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)3 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)3 PositionCallback (com.google.gwt.user.client.ui.PopupPanel.PositionCallback)3 PatchMethod (com.googlecode.gwt.test.patchers.PatchMethod)3 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)3 ToolbarPopupMenu (org.rstudio.core.client.widget.ToolbarPopupMenu)3 OnEditEnabler (com.google.gerrit.client.ui.OnEditEnabler)2 Element (com.google.gwt.dom.client.Element)2