use of com.google.gwt.dom.client.NativeEvent in project opennms by OpenNMS.
the class SearchStateTest method createEvent.
protected NativeEvent createEvent(final String type, final int keyCode) throws Exception {
final NativeEvent event = PowerMock.createMock(NativeEvent.class);
expect(event.getType()).andReturn(type).anyTimes();
expect(event.getKeyCode()).andReturn(keyCode).anyTimes();
event.stopPropagation();
expectLastCall().andAnswer(new IAnswer<Void>() {
@Override
public Void answer() throws Throwable {
LOG.info("stopPropagation() called on event(" + type + ", " + keyCode + ")");
return null;
}
}).anyTimes();
PowerMock.replay(event);
return event;
}
use of com.google.gwt.dom.client.NativeEvent in project opennms by OpenNMS.
the class VTopologyComponent method vertexClickHandler.
private Handler<GWTVertex> vertexClickHandler() {
return new D3Events.Handler<GWTVertex>() {
@Override
public void call(GWTVertex vertex, int index) {
if (D3.eventDefaultPrevented()) {
return;
}
NativeEvent event = D3.getEvent();
SVGGElement vertexElement = event.getCurrentEventTarget().cast();
vertexElement.getParentElement().appendChild(vertexElement);
event.preventDefault();
event.stopPropagation();
final MouseEventDetails mouseDetails = MouseEventDetailsBuilder.buildMouseEventDetails(event, getElement());
m_serverRpc.vertexClicked(vertex.getId(), mouseDetails, Navigator.getPlatform());
}
};
}
use of com.google.gwt.dom.client.NativeEvent in project opennms by OpenNMS.
the class VTopologyComponent method vertexDragStartHandler.
private Handler<GWTVertex> vertexDragStartHandler() {
return new Handler<GWTVertex>() {
@Override
public void call(GWTVertex vertex, int index) {
NativeEvent event = D3.getEvent();
Element draggableElement = Element.as(event.getEventTarget()).getParentElement();
D3 selection = null;
boolean isSelected = draggableElement.getAttribute("class").equals("vertex selected");
if (isSelected) {
selection = D3.d3().selectAll(GWTVertex.SELECTED_VERTEX_CLASS_NAME);
} else {
selection = D3.d3().select(Element.as(event.getEventTarget()).getParentElement());
}
m_dragObject = new DragObject(VTopologyComponent.this.m_topologyView, draggableElement, m_topologyView.getSVGViewPort(), selection);
D3.getEvent().preventDefault();
D3.getEvent().stopPropagation();
}
};
}
use of com.google.gwt.dom.client.NativeEvent in project rstudio by rstudio.
the class WindowEx method fireFocusHandlers.
private static void fireFocusHandlers() {
NativeEvent nativeEvent = Document.get().createFocusEvent();
FocusEvent.fireNativeEvent(nativeEvent, new HasHandlers() {
public void fireEvent(GwtEvent<?> event) {
handlers_.fireEvent(event);
}
});
}
use of com.google.gwt.dom.client.NativeEvent in project rstudio by rstudio.
the class AceEditorBackgroundLinkHighlighter method onAceClick.
@Override
public void onAceClick(AceClickEvent clickEvent) {
NativeEvent event = clickEvent.getNativeEvent();
if (!isRequiredClickModifier(event))
return;
MarkerRegistration marker = getTargetedMarker(event);
if (marker == null)
return;
clickEvent.stopPropagation();
clickEvent.preventDefault();
// will be opened in the background
if (BrowseCap.isMacintosh() && !BrowseCap.isMacintoshDesktop()) {
endDetectClickTarget();
String url = editor_.getTextForRange(marker.getRange());
navigateToUrl(url);
}
}
Aggregations