use of com.google.gwt.dom.client.NativeEvent in project cuba by cuba-platform.
the class MultiSelectionBodyClickHandler method handleCtrlClick.
protected void handleCtrlClick(SelectionModel.Multi<JsonObject> model, CellReference<JsonObject> cell, GridClickEvent event) {
NativeEvent e = event.getNativeEvent();
JsonObject row = cell.getRow();
if (!e.getCtrlKey() && !e.getMetaKey()) {
model.deselectAll();
}
if (model.isSelected(row)) {
model.deselect(row);
} else {
model.select(row);
}
}
use of com.google.gwt.dom.client.NativeEvent in project cuba by cuba-platform.
the class CubaFileUploadProgressWindow method constructDOM.
protected void constructDOM() {
setStyleName(CLASSNAME);
topTabStop = DOM.createDiv();
topTabStop.setTabIndex(0);
header = DOM.createDiv();
header.setClassName(CLASSNAME + "-outerheader");
headerText = DOM.createDiv();
headerText.setClassName(CLASSNAME + "-header");
contents = DOM.createDiv();
contents.setClassName(CLASSNAME + "-contents");
footer = DOM.createDiv();
footer.setClassName(CLASSNAME + "-footer");
resizeBox = DOM.createDiv();
resizeBox.setClassName(CLASSNAME + "-resizebox");
closeBox = DOM.createDiv();
closeBox.setClassName(CLASSNAME + "-closebox");
closeBox.setTabIndex(0);
DOM.appendChild(footer, resizeBox);
bottomTabStop = DOM.createDiv();
bottomTabStop.setTabIndex(0);
wrapper = DOM.createDiv();
wrapper.setClassName(CLASSNAME + "-wrap");
DOM.appendChild(wrapper, topTabStop);
DOM.appendChild(wrapper, header);
DOM.appendChild(header, closeBox);
DOM.appendChild(header, headerText);
DOM.appendChild(wrapper, contents);
DOM.appendChild(wrapper, footer);
DOM.appendChild(wrapper, bottomTabStop);
DOM.appendChild(super.getContainerElement(), wrapper);
sinkEvents(Event.ONDBLCLICK | Event.MOUSEEVENTS | Event.TOUCHEVENTS | Event.ONCLICK | Event.ONLOSECAPTURE);
currentFileLabel = new VLabel();
currentFileLabel.addStyleName("upload-file-label");
currentFileLabel.setWidth("100%");
progressBar = new VProgressBar();
progressBar.addStyleName("upload-progressbar");
progressBar.setIndeterminate(false);
progressBar.setState(0);
progressBar.setWidth("100%");
cancelButton = new VButton();
cancelButton.addStyleName("upload-cancel-button");
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
closeWindow();
}
});
contentPanel = new SimpleFocusablePanel();
contentPanel.setStyleName("content-pane");
contentPanel.addKeyDownHandler(this);
contentPanel.addKeyUpHandler(this);
setWidget(contentPanel);
final FlowPanel verticalPanel = new FlowPanel();
verticalPanel.setStyleName("vertical-panel");
verticalPanel.addStyleName("v-widget");
verticalPanel.addStyleName("v-has-width");
verticalPanel.addStyleName("v-has-height");
verticalPanel.add(currentFileLabel);
verticalPanel.add(progressBar);
verticalPanel.add(cancelButton);
contentPanel.setWidget(verticalPanel);
// do some calculations for window layout
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
Style contentStyle = contents.getStyle();
ComputedStyle headerCs = new ComputedStyle(header);
String headerHeight = headerCs.getProperty("height");
contentStyle.setProperty("paddingTop", headerHeight);
contentStyle.setProperty("marginTop", "-" + headerHeight);
ComputedStyle footerCs = new ComputedStyle(footer);
String footerHeight = footerCs.getProperty("height");
contentStyle.setProperty("paddingBottom", footerHeight);
contentStyle.setProperty("marginBottom", "-" + footerHeight);
}
});
// Make the closebox accessible for assistive devices
Roles.getButtonRole().set(closeBox);
Roles.getButtonRole().setAriaLabelProperty(closeBox, "close button");
// Provide the title to assistive devices
AriaHelper.ensureHasId(headerText);
Roles.getDialogRole().setAriaLabelledbyProperty(getElement(), Id.of(headerText));
// Handlers to Prevent tab to leave the window
// and backspace to cause browser navigation
topEventBlocker = new Event.NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
NativeEvent nativeEvent = event.getNativeEvent();
if (nativeEvent.getEventTarget().cast() == topTabStop && nativeEvent.getKeyCode() == KeyCodes.KEY_TAB && nativeEvent.getShiftKey()) {
nativeEvent.preventDefault();
}
if (nativeEvent.getEventTarget().cast() == topTabStop && nativeEvent.getKeyCode() == KeyCodes.KEY_BACKSPACE) {
nativeEvent.preventDefault();
}
}
};
bottomEventBlocker = new Event.NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
NativeEvent nativeEvent = event.getNativeEvent();
if (nativeEvent.getEventTarget().cast() == bottomTabStop && nativeEvent.getKeyCode() == KeyCodes.KEY_TAB && !nativeEvent.getShiftKey()) {
nativeEvent.preventDefault();
}
if (nativeEvent.getEventTarget().cast() == bottomTabStop && nativeEvent.getKeyCode() == KeyCodes.KEY_BACKSPACE) {
nativeEvent.preventDefault();
}
}
};
}
use of com.google.gwt.dom.client.NativeEvent in project cuba by cuba-platform.
the class CubaPopupButtonConnector method onPreviewNativeEvent.
@Override
public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
NativeEvent nativeEvent = event.getNativeEvent();
if (getWidget().getPopup().isVisible()) {
Element target = Element.as(nativeEvent.getEventTarget());
if (getWidget().popupHasChild(target)) {
if (event.getTypeInt() == Event.ONKEYDOWN && (nativeEvent.getKeyCode() == KeyCodes.KEY_ESCAPE || nativeEvent.getKeyCode() == KeyCodes.KEY_TAB && isLastChild(target)) && !nativeEvent.getAltKey() && !nativeEvent.getCtrlKey() && !nativeEvent.getShiftKey() && !nativeEvent.getMetaKey()) {
event.cancel();
event.getNativeEvent().stopPropagation();
event.getNativeEvent().preventDefault();
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
getWidget().hidePopup();
rpc.setPopupVisible(false);
getWidget().setFocus(true);
}
});
return;
}
}
}
super.onPreviewNativeEvent(event);
if (isEnabled()) {
Element target = Element.as(nativeEvent.getEventTarget());
switch(event.getTypeInt()) {
case Event.ONCLICK:
if (getState().autoClose && getWidget().popupHasChild(target)) {
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
getWidget().hidePopup();
// update state on server
rpc.setPopupVisible(false);
}
});
}
break;
case Event.ONKEYDOWN:
if (!getState().customLayout && getWidget().popupHasChild(target)) {
Widget widget = WidgetUtil.findWidget(target, null);
if (widget instanceof VButton || widget instanceof VUpload || widget instanceof CubaFileUploadWidget) {
Widget widgetParent = widget.getParent();
if (widgetParent.getParent() instanceof VUpload) {
VUpload upload = (VUpload) widgetParent.getParent();
// upload parent is Slot
widgetParent = upload.getParent();
} else if (widgetParent.getParent() instanceof CubaFileUploadWidget) {
CubaFileUploadWidget upload = (CubaFileUploadWidget) widgetParent.getParent();
// upload parent is Slot
widgetParent = upload.getParent();
}
VAbstractOrderedLayout layout = (VAbstractOrderedLayout) widgetParent.getParent();
Widget focusWidget = null;
int widgetIndex = layout.getWidgetIndex(widgetParent);
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_DOWN) {
focusWidget = Tools.findNextWidget(layout, widgetIndex);
} else if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_UP) {
focusWidget = Tools.findPrevWidget(layout, widgetIndex);
}
if (focusWidget instanceof VButton || focusWidget instanceof CubaFileUploadWidget || focusWidget instanceof VUpload) {
VButton button;
if (focusWidget instanceof VButton) {
button = (VButton) focusWidget;
} else if (focusWidget instanceof CubaFileUploadWidget) {
button = ((CubaFileUploadWidget) focusWidget).getSubmitButton();
} else {
button = ((VUpload) focusWidget).submitButton;
}
getWidget().childWidgetFocused(button);
button.setFocus(true);
}
}
}
break;
case Event.ONMOUSEOVER:
if (!getState().customLayout && getWidget().popupHasChild(target)) {
Widget widget = WidgetUtil.findWidget(target, null);
if ((widget instanceof VButton || widget instanceof VUpload || widget instanceof CubaFileUploadWidget)) {
VButton button;
if (widget instanceof VButton) {
button = (VButton) widget;
} else if (widget instanceof CubaFileUploadWidget) {
button = ((CubaFileUploadWidget) widget).getSubmitButton();
} else {
button = ((VUpload) widget).submitButton;
}
if (!button.getStyleName().contains(SELECTED_ITEM_STYLE)) {
getWidget().childWidgetFocused(button);
button.setFocus(true);
}
}
}
break;
}
}
}
use of com.google.gwt.dom.client.NativeEvent in project kie-wb-common by kiegroup.
the class DMNGridPanelContextMenuHandler method getRelativeX.
private int getRelativeX(final ContextMenuEvent event) {
final NativeEvent e = event.getNativeEvent();
final Element target = event.getRelativeElement();
return e.getClientX() - target.getAbsoluteLeft() + target.getScrollLeft() + target.getOwnerDocument().getScrollLeft();
}
use of com.google.gwt.dom.client.NativeEvent in project kie-wb-common by kiegroup.
the class DMNGridPanelContextMenuHandler method getRelativeY.
private int getRelativeY(final ContextMenuEvent event) {
final NativeEvent e = event.getNativeEvent();
final Element target = event.getRelativeElement();
return e.getClientY() - target.getAbsoluteTop() + target.getScrollTop() + target.getOwnerDocument().getScrollTop();
}
Aggregations