com.vaadin.client.BrowserInfo Java Examples
The following examples show how to use
com.vaadin.client.BrowserInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 6 votes |
@Override public void onFocus(FocusEvent event) { debug("VComboBoxMultiselect: onFocus()"); /* * When we disable a blur event in ie we need to refocus the textfield. * This will cause a focus event we do not want to process, so in that * case we just ignore it. */ if (BrowserInfo.get() .isIE() && this.iePreventNextFocus) { this.iePreventNextFocus = false; return; } this.focused = true; updatePlaceholder(); addStyleDependentName("focus"); this.connector.sendFocusEvent(); this.connector.getConnection() .getVTooltip() .showAssistive(this.connector.getTooltipInfo(getElement())); }
Example #2
Source File: CubaSideMenuWidget.java From cuba with Apache License 2.0 | 6 votes |
public CubaSideMenuWidget() { setStylePrimaryName(CLASS_NAME); sinkEvents(Event.ONMOUSEOVER | Event.ONMOUSEOUT); // Navigation is only handled by the root bar addFocusHandler(this); addBlurHandler(this); /* * Firefox auto-repeat works correctly only if we use a key press * handler, other browsers handle it correctly when using a key down handler */ if (BrowserInfo.get().isGecko() && BrowserInfo.get().getGeckoVersion() < 65.0) { addKeyPressHandler(this); } else { addKeyDownHandler(this); } }
Example #3
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 6 votes |
@Override public void onFocus(FocusEvent event) { debug("VComboBoxMultiselect: onFocus()"); /* * When we disable a blur event in ie we need to refocus the textfield. * This will cause a focus event we do not want to process, so in that * case we just ignore it. */ if (BrowserInfo.get() .isIE() && this.iePreventNextFocus) { this.iePreventNextFocus = false; return; } this.focused = true; updatePlaceholder(); addStyleDependentName("focus"); this.connector.sendFocusEvent(); this.connector.getConnection() .getVTooltip() .showAssistive(this.connector.getTooltipInfo(getElement())); }
Example #4
Source File: TableAggregationRow.java From cuba with Apache License 2.0 | 6 votes |
public void setCellWidth(int cellIx, int width) { // CAUTION: copied from VScrollTableRow with small changes final Element cell = DOM.getChild(tr, cellIx); Style wrapperStyle = cell.getFirstChildElement().getStyle(); int wrapperWidth = width; if (BrowserInfo.get().isWebkit() || BrowserInfo.get().isOpera10()) { /* * Some versions of Webkit and Opera ignore the width * definition of zero width table cells. Instead, use 1px * and compensate with a negative margin. */ if (width == 0) { wrapperWidth = 1; wrapperStyle.setMarginRight(-1, Style.Unit.PX); } else { wrapperStyle.clearMarginRight(); } } wrapperStyle.setPropertyPx("width", wrapperWidth); cell.getStyle().setPropertyPx("width", width); }
Example #5
Source File: CubaCheckBoxGroupWidget.java From cuba with Apache License 2.0 | 6 votes |
@Override public void onClick(ClickEvent event) { if (!isEnabled() || isReadonly()) { event.preventDefault(); if (isReadonly() && (BrowserInfo.get().isIE() || BrowserInfo.get().isEdge())) { // IE and Edge do not focus read-only checkbox on click Object checkBox = event.getSource(); if (checkBox instanceof VCheckBox) { ((VCheckBox) checkBox).setFocus(true); } } return; } super.onClick(event); }
Example #6
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 6 votes |
/** * Handles special behavior of the mouse down event. * * @param event */ private void handleMouseDownEvent(Event event) { /* * Prevent the keyboard focus from leaving the textfield by preventing * the default behaviour of the browser. Fixes #4285. */ if (event.getTypeInt() == Event.ONMOUSEDOWN) { debug("VComboBoxMultiselect: blocking mouseDown event to avoid blur"); event.preventDefault(); event.stopPropagation(); /* * In IE the above wont work, the blur event will still trigger. So, * we set a flag here to prevent the next blur event from happening. * This is not needed if do not already have focus, in that case * there will not be any blur event and we should not cancel the * next blur. */ if (BrowserInfo.get() .isIE() && this.focused) { this.preventNextBlurEventInIE = true; debug("VComboBoxMultiselect: Going to prevent next blur event on IE"); } } }
Example #7
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 6 votes |
@Override public void onMouseDown(MouseDownEvent event) { debug("VComboBoxMultiselect.onMouseDown(): blocking mouseDown event to avoid blur"); event.preventDefault(); event.stopPropagation(); /* * In IE the above wont work, the blur event will still trigger. So, we * set a flag here to prevent the next blur event from happening. This * is not needed if do not already have focus, in that case there will * not be any blur event and we should not cancel the next blur. */ if (BrowserInfo.get() .isIE() && this.focused) { this.preventNextBlurEventInIE = true; debug("VComboBoxMultiselect: Going to prevent next blur event on IE"); } }
Example #8
Source File: XhrConnection.java From flow with Apache License 2.0 | 6 votes |
/** * Sends an asynchronous UIDL request to the server using the given URI. * * @param payload * The URI to use for the request. May includes GET parameters */ public void send(JsonObject payload) { XhrResponseHandler responseHandler = createResponseHandler(); responseHandler.setPayload(payload); responseHandler.setRequestStartTime(Profiler.getRelativeTimeMillis()); String payloadJson = WidgetUtil.stringify(payload); XMLHttpRequest xhr = Xhr.post(getUri(), payloadJson, JsonConstants.JSON_CONTENT_TYPE, responseHandler); Console.log("Sending xhr message to server: " + payloadJson); if (webkitMaybeIgnoringRequests && BrowserInfo.get().isWebkit()) { final int retryTimeout = 250; new Timer() { @Override public void run() { // Use native js to access private field in Request if (resendRequest(xhr) && webkitMaybeIgnoringRequests) { // Schedule retry if still needed schedule(retryTimeout); } } }.schedule(retryTimeout); } }
Example #9
Source File: CubaFileUploadProgressWindow.java From cuba with Apache License 2.0 | 6 votes |
@Override public void hide() { /* * If the window has a RichTextArea and the RTA is focused at the time * of hiding in IE8 only the window will have some problems returning * the focus to the correct place. Curiously the focus will be returned * correctly if clicking on the "close" button in the window header but * closing the window from a button for example in the window will fail. * Symptom described in #10776 * * The problematic part is that for the focus to be returned correctly * an input element needs to be focused in the root panel. Focusing some * other element apparently won't work. */ if (BrowserInfo.get().isIE8()) { fixIE8FocusCaptureIssue(); } if (vaadinModality) { hideModalityCurtain(); } super.hide(); }
Example #10
Source File: CubaFileUploadProgressWindow.java From cuba with Apache License 2.0 | 6 votes |
@Override public void setVisible(boolean visible) { /* * Visibility with VWindow works differently than with other Paintables * in Vaadin. Invisible VWindows are not attached to DOM at all. Flag is * used to avoid visibility call from * ApplicationConnection.updateComponent(); */ if (!visibilityChangesDisabled) { super.setVisible(visible); } if (visible && BrowserInfo.get().requiresPositionAbsoluteOverflowAutoFix()) { /* * Shake up the DOM a bit to make the window shed unnecessary * scrollbars and resize correctly afterwards. The version fixing * ticket #11994 which was changing the size to 110% was replaced * with this due to ticket #12943 */ WidgetUtil .runWebkitOverflowAutoFix(contents.getFirstChildElement()); } }
Example #11
Source File: CubaFileUploadProgressWindow.java From cuba with Apache License 2.0 | 6 votes |
@Override protected void onAttach() { super.onAttach(); /* * When this window gets reattached, set the tabstop to the previous * state. */ setTabStopEnabled(doTabStop); // Fix for #14413. Any pseudo elements inside these elements are not // visible on initial render unless we shake the DOM. if (BrowserInfo.get().isIE8()) { closeBox.getStyle().setDisplay(Style.Display.NONE); Scheduler.get().scheduleFinally(new Command() { @Override public void execute() { closeBox.getStyle().clearDisplay(); } }); } }
Example #12
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 6 votes |
@Override public void onMouseDown(MouseDownEvent event) { debug("VComboBoxMultiselect.onMouseDown(): blocking mouseDown event to avoid blur"); event.preventDefault(); event.stopPropagation(); /* * In IE the above wont work, the blur event will still trigger. So, we * set a flag here to prevent the next blur event from happening. This * is not needed if do not already have focus, in that case there will * not be any blur event and we should not cancel the next blur. */ if (BrowserInfo.get() .isIE() && this.focused) { this.preventNextBlurEventInIE = true; debug("VComboBoxMultiselect: Going to prevent next blur event on IE"); } }
Example #13
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 6 votes |
/** * Handles special behavior of the mouse down event. * * @param event */ private void handleMouseDownEvent(Event event) { /* * Prevent the keyboard focus from leaving the textfield by preventing * the default behaviour of the browser. Fixes #4285. */ if (event.getTypeInt() == Event.ONMOUSEDOWN) { debug("VComboBoxMultiselect: blocking mouseDown event to avoid blur"); event.preventDefault(); event.stopPropagation(); /* * In IE the above wont work, the blur event will still trigger. So, * we set a flag here to prevent the next blur event from happening. * This is not needed if do not already have focus, in that case * there will not be any blur event and we should not cancel the * next blur. */ if (BrowserInfo.get() .isIE() && this.focused) { this.preventNextBlurEventInIE = true; debug("VComboBoxMultiselect: Going to prevent next blur event on IE"); } } }
Example #14
Source File: CubaSuggestionFieldWidget.java From cuba with Apache License 2.0 | 5 votes |
protected void disableAutocompletion() { if (BrowserInfo.get().isChrome()) { // Chrome supports "off" and random number does not work with Chrome textField.getElement().setAttribute("autocomplete", "off"); } else { textField.getElement().setAttribute("autocomplete", Math.random() + ""); } }
Example #15
Source File: CubaImageWidget.java From cuba with Apache License 2.0 | 5 votes |
public void applyScaling(String scaleMode) { removeStyleName(OBJECT_FIT + this.scaleMode); this.scaleMode = scaleMode; addStyleName(OBJECT_FIT + scaleMode); if (BrowserInfo.get().isIE() || BrowserInfo.get().isEdge()) { applyScaling(Integer.valueOf(getElement().getAttribute(OBJECT_FIT_ATTRIBUTE))); } }
Example #16
Source File: HTML5Support.java From cuba with Apache License 2.0 | 5 votes |
@Override public void onDrop(DropEvent event) { NativeEvent nativeEvent = event.getNativeEvent(); if (validate(nativeEvent) && vaadinDragEvent != null) { nativeEvent.preventDefault(); nativeEvent.stopPropagation(); // event stopped, just notify global handler // Haulmont API if (globalDropHandler != null) { globalDropHandler.onDrop(event); } vaadinDragEvent.setCurrentGwtEvent(nativeEvent); VDragAndDropManager.get().setCurrentDropHandler(dropHandler); // FIXME only text currently supported String data; if (BrowserInfo.get().isIE()) { // IE does not support MIME types // http://www.developerfusion.com/article/144828/the-html5-drag-and-drop-api/ data = event.getData("text"); } else { data = event.getData("text/plain"); } vaadinDragEvent.getTransferable().setData("html5Data", data); VDragAndDropManager.get().endDrag(); vaadinDragEvent = null; } }
Example #17
Source File: CubaTextFieldWidget.java From cuba with Apache License 2.0 | 5 votes |
protected void disableAutocompletion() { if (BrowserInfo.get().isChrome()) { // Chrome supports "off" and random number does not work with Chrome getElement().setAttribute("autocomplete", "off"); } else { getElement().setAttribute("autocomplete", Math.random() + ""); } }
Example #18
Source File: CubaTreeTableWidget.java From cuba with Apache License 2.0 | 5 votes |
@Override public void updateBody(UIDL uidl, int firstRow, int reqRows) { super.updateBody(uidl, firstRow, reqRows); // Have to scroll after row is expanded when table has vertical scroll if (BrowserInfo.get().isFirefox()) { enableLazyScroller(); } handleUpdateBodyRows(); }
Example #19
Source File: CubaButtonWidget.java From cuba with Apache License 2.0 | 5 votes |
@Override public void onClick(ClickEvent event) { if (BrowserInfo.get().isIE() && BrowserInfo.get().getIEVersion() >= 11) { // fix focusing of button-wrap in IE11 setFocus(true); } super.onClick(event); }
Example #20
Source File: GanttConnector.java From gantt with Apache License 2.0 | 5 votes |
@Override protected void init() { super.init(); BrowserInfo info = BrowserInfo.get(); getWidget().setBrowserInfo(info.isIE(), info.isChrome(), info.isSafari(), info.isWebkit(), info.getBrowserMajorVersion()); getWidget().setAlwaysCalculatePixelWidths(info.isSafari() || info.isOpera()); getWidget().setTouchSupported(info.isTouchDevice()); getWidget().initWidget(ganttRpc, localeDataProvider); getLayoutManager().addElementResizeListener(getWidget().getElement(), widgetResizeListener); }
Example #21
Source File: HistoryGwtApi.java From cuba with Apache License 2.0 | 5 votes |
protected void handleHistoryStep() { if (!isEnabled()) { disable(); return; } if (!BrowserInfo.get().isIE()) { goForward(); } else { goForwardDelayed(); } }
Example #22
Source File: CubaSuggestionFieldWidget.java From cuba with Apache License 2.0 | 5 votes |
protected void handleOnBlur(BlurEvent event) { removeStyleName(MODIFIED_STYLENAME); if (BrowserInfo.get().isIE()) { if (iePreventBlur) { textField.setFocus(true); iePreventBlur = false; } else { resetComponentState(); } } else { if (!suggestionsPopup.isShowing()) { resetComponentState(); return; } EventTarget eventTarget = event.getNativeEvent().getRelatedEventTarget(); if (eventTarget == null) { resetComponentState(); return; } if (Element.is(eventTarget)) { Widget widget = WidgetUtil.findWidget(Element.as(eventTarget), null); if (widget != suggestionsContainer) { resetComponentState(); } } } }
Example #23
Source File: CubaOptionGroupWidget.java From cuba with Apache License 2.0 | 5 votes |
@Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (isReadonly() && (BrowserInfo.get().isIE() || BrowserInfo.get().isEdge())) { // IE and Edge reset radioButton checked when clicking on another radioButton updateItemsSelection(); } }
Example #24
Source File: CubaPasswordFieldWidget.java From cuba with Apache License 2.0 | 5 votes |
public void setAutocomplete(boolean autocomplete) { if (autocomplete) { getElement().removeAttribute("autocomplete"); } else { BrowserInfo browser = BrowserInfo.get(); if (browser.isIE() || (browser.isGecko() && browser.getGeckoVersion() < 47) || (browser.isChrome() && browser.getBrowserMajorVersion() < 49)) { getElement().setAttribute("autocomplete", "off"); } else { getElement().setAttribute("autocomplete", "new-password"); } } }
Example #25
Source File: CubaCheckBoxWidget.java From cuba with Apache License 2.0 | 5 votes |
@Override public void onClick(ClickEvent event) { if (!isEnabled() || isReadOnly()) { event.preventDefault(); if (isReadOnly() && (BrowserInfo.get().isIE() || BrowserInfo.get().isEdge())) { // IE and Edge do not focus read-only checkbox on click setFocus(true); } } }
Example #26
Source File: CubaCheckBoxWidget.java From cuba with Apache License 2.0 | 5 votes |
@Override public void setFocus(boolean focused) { super.setFocus(focused); if (BrowserInfo.get().isWebkit()) { clearWebkitTextSelection(); } }
Example #27
Source File: CubaRadioButtonGroupWidget.java From cuba with Apache License 2.0 | 5 votes |
@Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (isReadonly() && (BrowserInfo.get().isIE() || BrowserInfo.get().isEdge())) { // IE and Edge reset radioButton checked when clicking on another radioButton updateItemsSelection(); } }
Example #28
Source File: CubaTextAreaWidget.java From cuba with Apache License 2.0 | 5 votes |
protected void disableAutocompletion() { if (BrowserInfo.get().isChrome()) { // Chrome supports "off" and random number does not work with Chrome getElement().setAttribute("autocomplete", "off"); } else { getElement().setAttribute("autocomplete", Math.random() + ""); } }
Example #29
Source File: CubaFileUploadProgressWindow.java From cuba with Apache License 2.0 | 5 votes |
private void hideModalityCurtain() { Document.get().getBody().removeClassName(MODAL_WINDOW_OPEN_CLASSNAME); modalityCurtain.removeFromParent(); if (BrowserInfo.get().isIE()) { // IE leaks memory in certain cases unless we release the reference // (#9197) modalityCurtain = null; } }
Example #30
Source File: SuggestionsContainer.java From cuba with Apache License 2.0 | 4 votes |
@Override public void onBrowserEvent(Event event) { if (getElement() == DOM.eventGetTarget(event)) { return; } SuggestionItem item = findItem(DOM.eventGetTarget(event)); switch (DOM.eventGetType(event)) { case Event.ONMOUSEDOWN: { if (BrowserInfo.get().isIE()) { suggestionFieldWidget.iePreventBlur = true; } break; } case Event.ONCLICK: { if (event.getButton() == NativeEvent.BUTTON_LEFT) { performItemCommand(item); } break; } case Event.ONMOUSEOVER: { if (item != null) { selectItem(item); } break; } case Event.ONKEYDOWN: { int keyCode = KeyCodes.maybeSwapArrowKeysForRtl( event.getKeyCode(), LocaleInfo.getCurrentLocale().isRTL() ); switch (keyCode) { case KeyCodes.KEY_UP: selectPrevItem(); preventEvent(event); break; case KeyCodes.KEY_DOWN: selectNextItem(); preventEvent(event); break; case KeyCodes.KEY_ESCAPE: selectItem(null); preventEvent(event); break; case KeyCodes.KEY_TAB: selectItem(null); break; case KeyCodes.KEY_ENTER: performItemCommand(item); preventEvent(event); break; } break; } } super.onBrowserEvent(event); }