use of com.google.gwt.user.client.Event in project gwt-test-utils by gwt-test-utils.
the class Browser method prepareEvents.
private static void prepareEvents(IsWidget target, Event... events) {
for (Event event : events) {
Element effectiveTarget = JavaScriptObjects.getObject(event, JsoProperties.EVENT_TARGET);
if (effectiveTarget == null) {
effectiveTarget = target.asWidget().getElement();
JavaScriptObjects.setProperty(event, JsoProperties.EVENT_TARGET, effectiveTarget);
}
}
}
use of com.google.gwt.user.client.Event in project gwt-test-utils by gwt-test-utils.
the class BrowserTest method click_firesNativePreviewHandler.
@Test
public void click_firesNativePreviewHandler() {
// Given
Button b = new Button();
FocusPanel focusPanel = new FocusPanel();
focusPanel.add(b);
RootPanel.get().add(focusPanel);
final StringBuilder sb = new StringBuilder();
Event.addNativePreviewHandler(new NativePreviewHandler() {
public void onPreviewNativeEvent(NativePreviewEvent event) {
Event nativeEvent = Event.as(event.getNativeEvent());
int eventType = DOM.eventGetType(nativeEvent);
if (eventType == Event.ONCLICK) {
sb.append("click!");
}
}
});
// When
Browser.click(b);
// Then
assertThat(sb.toString()).isEqualTo("click!");
}
use of com.google.gwt.user.client.Event in project gwt-test-utils by gwt-test-utils.
the class CompositeTest method fireNativeEvent_Wrapped.
@Test
public void fireNativeEvent_Wrapped() {
// 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, label, label.getElement());
// Then
assertThat(labelCount).isEqualTo(1);
assertThat(compositeCount).isEqualTo(0);
}
use of com.google.gwt.user.client.Event in project gerrit by GerritCodeReview.
the class CreateGroupScreen method addCreateGroupPanel.
private void addCreateGroupPanel() {
VerticalPanel addPanel = new VerticalPanel();
addPanel.setStyleName(Gerrit.RESOURCES.css().addSshKeyPanel());
addPanel.add(new SmallHeading(AdminConstants.I.headingCreateGroup()));
addTxt = new NpTextBox() {
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (event.getTypeInt() == Event.ONPASTE) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
if (addTxt.getValue().trim().length() != 0) {
addNew.setEnabled(true);
}
}
});
}
}
};
addTxt.sinkEvents(Event.ONPASTE);
addTxt.setVisibleLength(60);
addTxt.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
doCreateGroup();
}
}
});
addPanel.add(addTxt);
addNew = new Button(AdminConstants.I.buttonCreateGroup());
addNew.setEnabled(false);
addNew.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
doCreateGroup();
}
});
addPanel.add(addNew);
add(addPanel);
new OnEditEnabler(addNew, addTxt);
}
use of com.google.gwt.user.client.Event in project gerrit by GerritCodeReview.
the class CreateProjectScreen method initCreateTxt.
private void initCreateTxt() {
project = new NpTextBox() {
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (event.getTypeInt() == Event.ONPASTE) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
if (project.getValue().trim().length() != 0) {
create.setEnabled(true);
}
}
});
}
}
};
project.sinkEvents(Event.ONPASTE);
project.setVisibleLength(50);
project.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
doCreateProject();
}
}
});
new OnEditEnabler(create, project);
}
Aggregations