List of usage examples for com.vaadin.client BrowserInfo get
public static BrowserInfo get()
From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadProgressWindow.java
License:Apache License
@Override public void setVisible(boolean visible) { /*/*from w ww . j a v a 2 s .co m*/ * 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()); } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadProgressWindow.java
License:Apache License
@Override public void hide() { /*/*www. ja va 2 s. c o m*/ * 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(); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadProgressWindow.java
License:Apache License
private void hideModalityCurtain() { Document.get().getBody().removeClassName(MODAL_WINDOW_OPEN_CLASSNAME); modalityCurtain.removeFromParent();//w w w . ja v a2 s.co m if (BrowserInfo.get().isIE()) { // IE leaks memory in certain cases unless we release the reference // (#9197) modalityCurtain = null; } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadProgressWindow.java
License:Apache License
private void onResizeEvent(Event event) { if (resizable && WidgetUtil.isTouchEventOrLeftMouseButton(event)) { switch (event.getTypeInt()) { case Event.ONMOUSEDOWN: case Event.ONTOUCHSTART: showResizingCurtain();/*from ww w . ja va 2s . co m*/ if (BrowserInfo.get().isIE()) { resizeBox.getStyle().setVisibility(Style.Visibility.HIDDEN); } resizing = true; startX = WidgetUtil.getTouchOrMouseClientX(event); startY = WidgetUtil.getTouchOrMouseClientY(event); origW = getElement().getOffsetWidth(); origH = getElement().getOffsetHeight(); DOM.setCapture(getElement()); event.preventDefault(); break; case Event.ONMOUSEUP: case Event.ONTOUCHEND: setSize(event); case Event.ONTOUCHCANCEL: DOM.releaseCapture(getElement()); case Event.ONLOSECAPTURE: hideResizingCurtain(); if (BrowserInfo.get().isIE()) { resizeBox.getStyle().clearVisibility(); } resizing = false; break; case Event.ONMOUSEMOVE: case Event.ONTOUCHMOVE: if (resizing) { setSize(event); event.preventDefault(); } break; default: event.preventDefault(); break; } } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.JQueryFileUploadOverlay.java
License:Apache License
protected boolean isIframeTransportNecessary() { return BrowserInfo.get().isIE10(); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.orderedactionslayout.CubaOrderedLayoutSlot.java
License:Apache License
public void setCaption(String captionText, boolean contextHelpIconEnabled, Icon icon, List<String> styles, String error, boolean showError, boolean required, boolean enabled, boolean captionAsHtml) { // CAUTION copied from super // Caption wrappers Widget widget = getWidget();/*from w w w . ja v a2 s.c om*/ final Element focusedElement = WidgetUtil.getFocusedElement(); // By default focus will not be lost boolean focusLost = false; if (captionText != null || icon != null || error != null || required || contextHelpIconEnabled) { if (caption == null) { caption = DOM.createDiv(); captionWrap = DOM.createDiv(); captionWrap.addClassName(StyleConstants.UI_WIDGET); captionWrap.addClassName("v-has-caption"); getElement().appendChild(captionWrap); orphan(widget); captionWrap.appendChild(widget.getElement()); adopt(widget); // Made changes to DOM. Focus can be lost if it was in the // widget. focusLost = (focusedElement == null ? false : widget.getElement().isOrHasChild(focusedElement)); } } else if (caption != null) { orphan(widget); getElement().appendChild(widget.getElement()); adopt(widget); captionWrap.removeFromParent(); caption = null; captionWrap = null; // Made changes to DOM. Focus can be lost if it was in the widget. focusLost = (focusedElement == null ? false : widget.getElement().isOrHasChild(focusedElement)); } // Caption text if (captionText != null) { if (this.captionText == null) { this.captionText = DOM.createSpan(); this.captionText.addClassName("v-captiontext"); if (caption != null) { caption.appendChild(this.captionText); } } if (captionText.trim().equals("")) { this.captionText.setInnerHTML(" "); } else { if (captionAsHtml) { this.captionText.setInnerHTML(captionText); } else { this.captionText.setInnerText(captionText); } } } else if (this.captionText != null) { this.captionText.removeFromParent(); this.captionText = null; } // Icon if (this.icon != null) { this.icon.getElement().removeFromParent(); } if (icon != null) { if (caption != null) { caption.insertFirst(icon.getElement()); } } this.icon = icon; // Required if (required) { if (requiredIcon == null) { requiredIcon = DOM.createSpan(); // TODO decide something better (e.g. use CSS to insert the // character) requiredIcon.setInnerHTML("*"); requiredIcon.setClassName("v-required-field-indicator"); // The star should not be read by the screen reader, as it is // purely visual. Required state is set at the element level for // the screen reader. Roles.getTextboxRole().setAriaHiddenState(requiredIcon, true); } if (caption != null) { caption.appendChild(requiredIcon); } } else if (requiredIcon != null) { requiredIcon.removeFromParent(); requiredIcon = null; } // Context Help // Haulmont API if (contextHelpIconEnabled) { if (contextHelpIcon == null) { contextHelpIcon = DOM.createSpan(); // TODO decide something better (e.g. use CSS to insert the character) contextHelpIcon.setInnerHTML("?"); contextHelpIcon.setClassName(CONTEXT_HELP_CLASSNAME); // The question mark should not be read by the screen reader, as it is // purely visual. Required state is set at the element level for // the screen reader. Roles.getTextboxRole().setAriaHiddenState(contextHelpIcon, true); } if (caption != null) { caption.appendChild(contextHelpIcon); if (clickHandlerRegistration == null) { clickHandlerRegistration = addDomHandler(this, ClickEvent.getType()); } } } else { if (this.contextHelpIcon != null) { this.contextHelpIcon.removeFromParent(); this.contextHelpIcon = null; } if (clickHandlerRegistration != null) { clickHandlerRegistration.removeHandler(); clickHandlerRegistration = null; } } // Error if (error != null && showError) { if (errorIcon == null) { errorIcon = DOM.createSpan(); errorIcon.setClassName("v-errorindicator"); } if (caption != null) { caption.appendChild(errorIcon); } } else if (errorIcon != null) { errorIcon.removeFromParent(); errorIcon = null; } if (caption != null) { // Styles caption.setClassName("v-caption"); if (styles != null) { for (String style : styles) { caption.addClassName("v-caption-" + style); } } if (enabled) { caption.removeClassName("v-disabled"); } else { caption.addClassName("v-disabled"); } // Caption position if (captionText != null || icon != null) { setCaptionPosition(CaptionPosition.TOP); } else { setCaptionPosition(CaptionPosition.RIGHT); } } if (focusLost) { // Find out what element is currently focused. Element currentFocus = WidgetUtil.getFocusedElement(); if (currentFocus != null && currentFocus.equals(Document.get().getBody())) { // Focus has moved to BodyElement and should be moved back to // original location. This happened because of adding or // removing the captionWrap focusedElement.focus(); } else if (currentFocus != focusedElement) { // Focus is either moved somewhere else on purpose or IE has // lost it. Investigate further. Timer focusTimer = new Timer() { @Override public void run() { if (WidgetUtil.getFocusedElement() == null) { // This should never become an infinite loop and // even if it does it will be stopped once something // is done with the browser. schedule(25); } else if (WidgetUtil.getFocusedElement().equals(Document.get().getBody())) { // Focus found it's way to BodyElement. Now it can // be restored focusedElement.focus(); } } }; if (BrowserInfo.get().isIE8()) { // IE8 can't fix the focus immediately. It will fail. focusTimer.schedule(25); } else { // Newer IE versions can handle things immediately. focusTimer.run(); } } } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.passwordfield.CubaPasswordFieldWidget.java
License:Apache License
public void setAutocomplete(boolean autocomplete) { if (autocomplete) { getElement().removeAttribute("autocomplete"); } else {/*from w w w. ja v a 2 s . c o m*/ 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"); } } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.suggestionfield.CubaSuggestionFieldWidget.java
License:Apache License
protected void handleOnBlur(BlurEvent event) { removeStyleName(MODIFIED_STYLENAME); if (BrowserInfo.get().isIE()) { if (iePreventBlur) { textField.setFocus(true);//from www .j av a2 s. c o m 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(); } } } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.suggestionfield.menu.SuggestionsContainer.java
License:Apache License
@Override public void onBrowserEvent(Event event) { if (getElement() == DOM.eventGetTarget(event)) { return;/*from www. j a v a 2s. com*/ } 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); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.table.CubaScrollTableWidget.java
License:Apache License
@Override protected boolean isAllowSingleSelectToggle() { return BrowserInfo.get().isTouchDevice() && Tools.isUseSimpleMultiselectForTouchDevice(); }