com.vaadin.client
Class Util

java.lang.Object
  extended by com.vaadin.client.Util

public class Util
extends java.lang.Object


Constructor Summary
Util()
           
 
Method Summary
static void alert(java.lang.String string)
          Deprecated. 
static void browserDebugger()
          Deprecated. 
static com.google.gwt.user.client.Element cloneNode(Element element, boolean deep)
          Deprecated. 
static boolean collectionsEquals(java.util.Collection<?> collection1, java.util.Collection<?> collection2)
          Performs a shallow comparison of the collections.
static void detachAttach(Element element)
          Deprecated. 
static boolean equals(java.lang.Object a, java.lang.Object b)
          Deprecated. As of 7.1 use Object.equals(Object) instead
static java.lang.String escapeAttribute(java.lang.String attribute)
          Deprecated. 
static java.lang.String escapeHTML(java.lang.String html)
          Deprecated. 
static ComponentConnector findConnectorFor(Widget widget)
           
static ComponentConnector findPaintable(ApplicationConnection client, Element element)
          Helper method to find the nearest parent paintable instance by traversing the DOM upwards from given element.
static
<T> T
findWidget(Element element, java.lang.Class<? extends Widget> class1)
          Deprecated. 
static void focus(Element el)
          Deprecated. 
static void forceIE8Redraw(Element e)
          Deprecated. 
static void forceIERedraw(Element e)
          Deprecated. 
static void forceWebkitRedraw(Element element)
          Deprecated. 
static java.lang.String getAbsoluteUrl(java.lang.String url)
          Deprecated. 
static int getChildElementIndex(Element childElement)
          Deprecated. 
static ComponentConnector getConnectorForElement(ApplicationConnection client, Widget parent, Element element)
          Locates the nested child component of parent which contains the element element.
static java.lang.String getConnectorString(ServerConnector p)
           
static com.google.gwt.user.client.Element getElementFromPoint(int clientX, int clientY)
          Deprecated. 
static com.google.gwt.user.client.Element getElementUnderMouse(NativeEvent event)
          Deprecated. 
static com.google.gwt.user.client.Element getFocusedElement()
          Deprecated. 
static com.google.gwt.user.client.Element getIEFocusedElement()
          Deprecated. Use #getFocusedElement instead
static int getKeyCode( event)
          Deprecated. 
static int getNativeScrollbarSize()
          Deprecated. 
static int getRequiredHeight(com.google.gwt.dom.client.Element element)
          Deprecated. 
static int getRequiredHeight(Widget widget)
          Deprecated. 
static int getRequiredHeightBoundingClientRect(com.google.gwt.dom.client.Element element)
          Deprecated. 
static int getRequiredHeightComputedStyle(com.google.gwt.dom.client.Element element)
          Deprecated. 
static int getRequiredWidth(com.google.gwt.dom.client.Element element)
          Deprecated. 
static int getRequiredWidth(Widget widget)
          Deprecated. 
 int getRequiredWidthBoundingClientRect(com.google.gwt.dom.client.Element element)
          Deprecated. 
static int getRequiredWidthComputedStyle(com.google.gwt.dom.client.Element element)
          Deprecated. 
static java.lang.String getSimpleName(java.lang.Object widget)
          Deprecated. 
static int getTouchOrMouseClientX(Event event)
          Deprecated. 
static int getTouchOrMouseClientX(NativeEvent event)
          Deprecated. 
static int getTouchOrMouseClientY(Event event)
          Deprecated. 
static int getTouchOrMouseClientY(NativeEvent currentGwtEvent)
          Deprecated. 
static boolean isAttachedAndDisplayed(Widget widget)
          Deprecated. 
static boolean isCached(UIDL uidl)
          Deprecated. 
static boolean isFocusedElementEditable()
          Deprecated. 
static boolean isTouchEvent(Event event)
          Deprecated. 
static boolean isTouchEvent(NativeEvent event)
          Deprecated. 
static boolean isTouchEventOrLeftMouseButton(Event event)
          Deprecated. 
static
<T extends elemental.json.JsonValue>
T
jso2json(JavaScriptObject jso)
          Converts a native JavaScriptObject into a JsonValue.
static JavaScriptObject json2jso(elemental.json.JsonValue jsonValue)
          Converts a JsonValue into a native JavaScriptObject.
static boolean mayHaveScrollBars(com.google.gwt.dom.client.Element pe)
          Deprecated. 
static int measureHorizontalBorder(Element element)
          Deprecated. 
static int measureHorizontalPaddingAndBorder(Element element, int paddingGuess)
          Deprecated. 
static int measureMarginLeft(Element element)
          Deprecated. 
static int measureVerticalBorder(Element element)
          Deprecated. 
static int measureVerticalPaddingAndBorder(Element element, int paddingGuess)
          Deprecated. 
static void notifyParentOfSizeChange(Widget widget, boolean lazy)
          Deprecated. As of 7.0, use LayoutManager.setNeedsMeasure(ComponentConnector) instead
static
<T extends JavaScriptObject>
T
parse(java.lang.String jsonAsString)
          Parse a string containing JSON into a JavaScriptObject.
static RenderInformation.FloatSize parseRelativeSize(com.vaadin.shared.AbstractComponentState state)
          Parses shared state and fetches the relative size of the component.
static float parseRelativeSize(java.lang.String size)
          Deprecated. 
static void runWebkitOverflowAutoFix(Element elem)
          Deprecated. 
static void runWebkitOverflowAutoFixDeferred(Element elem)
          Deprecated. 
static void scrollIntoViewVertically(Element elem)
          Deprecated. 
static void setFloat(Element element, java.lang.String value)
          Deprecated. 
static int setHeightExcludingPaddingAndBorder(Element element, int requestedHeight, int verticalPaddingBorderGuess, boolean requestedHeightIncludesPaddingBorder)
          Deprecated. 
static int setHeightExcludingPaddingAndBorder(Widget widget, java.lang.String height, int paddingBorderGuess)
          Deprecated. 
static void setSelectionRange(Element elem, int pos, int length, java.lang.String direction)
          Deprecated. 
static void setStyleTemporarily(Element element, java.lang.String styleProperty, java.lang.String tempValue)
          Deprecated. 
static int setWidthExcludingPaddingAndBorder(Element element, int requestedWidth, int horizontalPaddingBorderGuess, boolean requestedWidthIncludesPaddingBorder)
          Deprecated. 
static int setWidthExcludingPaddingAndBorder(Widget widget, java.lang.String width, int paddingBorderGuess)
          Deprecated. 
static void simulateClickFromTouchEvent(Event touchevent, Widget widget)
          Deprecated. 
static void sinkOnloadForImages(Element element)
          Deprecated. 
static void updateRelativeChildrenAndSendSizeUpdateEvent(ApplicationConnection client, HasWidgets container, Widget widget)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

browserDebugger

@Deprecated
public static void browserDebugger()
Deprecated. 

Helper method for debugging purposes. Stops execution on firefox browsers on a breakpoint.


getKeyCode

@Deprecated
public static int getKeyCode( event)
Deprecated. 

Helper method for a bug fix #14041. For mozilla getKeyCode return 0 for space bar (because space is considered as char). If return 0 use getCharCode.

Parameters:
event -
Returns:
return key code
Since:
7.2.4

getElementFromPoint

@Deprecated
public static com.google.gwt.user.client.Element getElementFromPoint(int clientX,
                                                                                int clientY)
Deprecated. 

Returns the topmost element of from given coordinates. TODO fix crossplat issues clientX vs pageX. See quircksmode. Not critical for vaadin as we scroll div istead of page.

Parameters:
x -
y -
Returns:
the element at given coordinates

notifyParentOfSizeChange

@Deprecated
public static void notifyParentOfSizeChange(Widget widget,
                                                       boolean lazy)
Deprecated. As of 7.0, use LayoutManager.setNeedsMeasure(ComponentConnector) instead

This helper method can be called if components size have been changed outside rendering phase. It notifies components parent about the size change so it can react. When using this method, developer should consider if size changes could be notified lazily. If lazy flag is true, method will save widget and wait for a moment until it notifies parents in chunks. This may vastly optimize layout in various situation. Example: if component have a lot of images their onload events may fire "layout phase" many times in a short period.

Parameters:
widget -
lazy - run componentSizeUpdated lazyly

findConnectorFor

public static ComponentConnector findConnectorFor(Widget widget)

parseRelativeSize

@Deprecated
public static float parseRelativeSize(java.lang.String size)
Deprecated. 


escapeHTML

@Deprecated
public static java.lang.String escapeHTML(java.lang.String html)
Deprecated. 

Converts html entities to text.

Parameters:
html -
Returns:
escaped string presentation of given html

escapeAttribute

@Deprecated
public static java.lang.String escapeAttribute(java.lang.String attribute)
Deprecated. 

Escapes the string so it is safe to write inside an HTML attribute.

Parameters:
attribute - The string to escape
Returns:
An escaped version of attribute.

cloneNode

@Deprecated
public static com.google.gwt.user.client.Element cloneNode(Element element,
                                                                      boolean deep)
Deprecated. 

Clones given element as in JavaScript. Deprecate this if there appears similar method into GWT someday.

Parameters:
element -
deep - clone child tree also
Returns:

measureHorizontalPaddingAndBorder

@Deprecated
public static int measureHorizontalPaddingAndBorder(Element element,
                                                               int paddingGuess)
Deprecated. 


measureVerticalPaddingAndBorder

@Deprecated
public static int measureVerticalPaddingAndBorder(Element element,
                                                             int paddingGuess)
Deprecated. 


measureHorizontalBorder

@Deprecated
public static int measureHorizontalBorder(Element element)
Deprecated. 


measureVerticalBorder

@Deprecated
public static int measureVerticalBorder(Element element)
Deprecated. 


measureMarginLeft

@Deprecated
public static int measureMarginLeft(Element element)
Deprecated. 


setHeightExcludingPaddingAndBorder

@Deprecated
public static int setHeightExcludingPaddingAndBorder(Widget widget,
                                                                java.lang.String height,
                                                                int paddingBorderGuess)
Deprecated. 


setWidthExcludingPaddingAndBorder

@Deprecated
public static int setWidthExcludingPaddingAndBorder(Widget widget,
                                                               java.lang.String width,
                                                               int paddingBorderGuess)
Deprecated. 


setWidthExcludingPaddingAndBorder

@Deprecated
public static int setWidthExcludingPaddingAndBorder(Element element,
                                                               int requestedWidth,
                                                               int horizontalPaddingBorderGuess,
                                                               boolean requestedWidthIncludesPaddingBorder)
Deprecated. 


setHeightExcludingPaddingAndBorder

@Deprecated
public static int setHeightExcludingPaddingAndBorder(Element element,
                                                                int requestedHeight,
                                                                int verticalPaddingBorderGuess,
                                                                boolean requestedHeightIncludesPaddingBorder)
Deprecated. 


getSimpleName

@Deprecated
public static java.lang.String getSimpleName(java.lang.Object widget)
Deprecated. 


setFloat

@Deprecated
public static void setFloat(Element element,
                                       java.lang.String value)
Deprecated. 


getNativeScrollbarSize

@Deprecated
public static int getNativeScrollbarSize()
Deprecated. 


runWebkitOverflowAutoFixDeferred

@Deprecated
public static void runWebkitOverflowAutoFixDeferred(Element elem)
Deprecated. 

Defers the execution of runWebkitOverflowAutoFix(Element)

Parameters:
elem - with overflow auto
Since:
7.2.6

runWebkitOverflowAutoFix

@Deprecated
public static void runWebkitOverflowAutoFix(Element elem)
Deprecated. 

Run workaround for webkits overflow auto issue. See: our bug #2138 and https://bugs.webkit.org/show_bug.cgi?id=21462

Parameters:
elem - with overflow auto

parseRelativeSize

public static RenderInformation.FloatSize parseRelativeSize(com.vaadin.shared.AbstractComponentState state)
Parses shared state and fetches the relative size of the component. If a dimension is not specified as relative it will return -1. If the shared state does not contain width or height specifications this will return null.

Parameters:
state -
Returns:

isCached

@Deprecated
public static boolean isCached(UIDL uidl)
Deprecated. 


alert

@Deprecated
public static void alert(java.lang.String string)
Deprecated. 


equals

@Deprecated
public static boolean equals(java.lang.Object a,
                                        java.lang.Object b)
Deprecated. As of 7.1 use Object.equals(Object) instead

Checks if a and b are equals using Object.equals(Object). Handles null values as well. Does not ensure that objects are of the same type. Assumes that the first object's equals method handle equals properly.

Parameters:
a - The first value to compare
b - The second value to compare
Returns:

updateRelativeChildrenAndSendSizeUpdateEvent

public static void updateRelativeChildrenAndSendSizeUpdateEvent(ApplicationConnection client,
                                                                HasWidgets container,
                                                                Widget widget)

getRequiredWidth

@Deprecated
public static int getRequiredWidth(com.google.gwt.dom.client.Element element)
Deprecated. 

Gets the border-box width for the given element, i.e. element width + border + padding. Always rounds up to nearest integer.

Parameters:
element - The element to check
Returns:
The border-box width for the element

getRequiredHeight

@Deprecated
public static int getRequiredHeight(com.google.gwt.dom.client.Element element)
Deprecated. 

Gets the border-box height for the given element, i.e. element height + border + padding. Always rounds up to nearest integer.

Parameters:
element - The element to check
Returns:
The border-box height for the element

getRequiredWidthBoundingClientRect

@Deprecated
public int getRequiredWidthBoundingClientRect(com.google.gwt.dom.client.Element element)
Deprecated. 


getRequiredHeightComputedStyle

@Deprecated
public static int getRequiredHeightComputedStyle(com.google.gwt.dom.client.Element element)
Deprecated. 


getRequiredWidthComputedStyle

@Deprecated
public static int getRequiredWidthComputedStyle(com.google.gwt.dom.client.Element element)
Deprecated. 


getRequiredHeightBoundingClientRect

@Deprecated
public static int getRequiredHeightBoundingClientRect(com.google.gwt.dom.client.Element element)
Deprecated. 


getRequiredWidth

@Deprecated
public static int getRequiredWidth(Widget widget)
Deprecated. 


getRequiredHeight

@Deprecated
public static int getRequiredHeight(Widget widget)
Deprecated. 


mayHaveScrollBars

@Deprecated
public static boolean mayHaveScrollBars(com.google.gwt.dom.client.Element pe)
Deprecated. 

Detects what is currently the overflow style attribute in given element.

Parameters:
pe - the element to detect
Returns:
true if auto or scroll

getConnectorForElement

public static ComponentConnector getConnectorForElement(ApplicationConnection client,
                                                        Widget parent,
                                                        Element element)
Locates the nested child component of parent which contains the element element. The child component is also returned if "element" is part of its caption. If element is not part of any child component, null is returned. This method returns the deepest nested VPaintableWidget.

Parameters:
client - A reference to ApplicationConnection
parent - The widget that contains element.
element - An element that is a sub element of the parent
Returns:
The VPaintableWidget which the element is a part of. Null if the element does not belong to a child.

focus

@Deprecated
public static void focus(Element el)
Deprecated. 

Will (attempt) to focus the given DOM Element.

Parameters:
el - the element to focus

findPaintable

public static ComponentConnector findPaintable(ApplicationConnection client,
                                               Element element)
Helper method to find the nearest parent paintable instance by traversing the DOM upwards from given element.

Parameters:
element - the element to start from

findWidget

@Deprecated
public static <T> T findWidget(Element element,
                                          java.lang.Class<? extends Widget> class1)
Deprecated. 

Helper method to find first instance of given Widget type found by traversing DOM upwards from given element.

Parameters:
element - the element where to start seeking of Widget
class1 - the Widget type to seek for

forceWebkitRedraw

@Deprecated
public static void forceWebkitRedraw(Element element)
Deprecated. 

Force webkit to redraw an element

Parameters:
element - The element that should be redrawn

forceIE8Redraw

@Deprecated
public static final void forceIE8Redraw(Element e)
Deprecated. 

Performs a hack to trigger a re-layout in the IE8. This is usually necessary in cases where IE8 "forgets" to update child elements when they resize.

Parameters:
e - The element to perform the hack on

forceIERedraw

@Deprecated
public static void forceIERedraw(Element e)
Deprecated. 

Performs a hack to trigger a re-layout in the IE browser. This is usually necessary in cases where IE "forgets" to update child elements when they resize.

Parameters:
e - The element to perform the hack on
Since:
7.3

detachAttach

@Deprecated
public static void detachAttach(Element element)
Deprecated. 

Detaches and re-attaches the element from its parent. The element is reattached at the same position in the DOM as it was before. Does nothing if the element is not attached to the DOM.

Parameters:
element - The element to detach and re-attach

sinkOnloadForImages

@Deprecated
public static void sinkOnloadForImages(Element element)
Deprecated. 


getChildElementIndex

@Deprecated
public static int getChildElementIndex(Element childElement)
Deprecated. 

Returns the index of the childElement within its parent.

Parameters:
subElement -
Returns:

setStyleTemporarily

@Deprecated
public static void setStyleTemporarily(Element element,
                                                  java.lang.String styleProperty,
                                                  java.lang.String tempValue)
Deprecated. 

Temporarily sets the styleProperty to tempValue and then resets it to its current value. Used mainly to work around rendering issues in IE (and possibly in other browsers)

Parameters:
element - The target element
styleProperty - The name of the property to set
tempValue - The temporary value

getTouchOrMouseClientX

@Deprecated
public static int getTouchOrMouseClientX(Event event)
Deprecated. 

A helper method to return the client position from an event. Returns position from either first changed touch (if touch event) or from the event itself.

Parameters:
event -
Returns:

getElementUnderMouse

@Deprecated
public static com.google.gwt.user.client.Element getElementUnderMouse(NativeEvent event)
Deprecated. 

Find the element corresponding to the coordinates in the passed mouse event. Please note that this is not always the same as the target of the event e.g. if event capture is used.

Parameters:
event - the mouse event to get coordinates from
Returns:
the element at the coordinates of the event

getTouchOrMouseClientY

@Deprecated
public static int getTouchOrMouseClientY(Event event)
Deprecated. 

A helper method to return the client position from an event. Returns position from either first changed touch (if touch event) or from the event itself.

Parameters:
event -
Returns:

getTouchOrMouseClientY

@Deprecated
public static int getTouchOrMouseClientY(NativeEvent currentGwtEvent)
Deprecated. 

Parameters:
currentGwtEvent -
Returns:
See Also:
getTouchOrMouseClientY(Event)

getTouchOrMouseClientX

@Deprecated
public static int getTouchOrMouseClientX(NativeEvent event)
Deprecated. 

Parameters:
event -
Returns:
See Also:
getTouchOrMouseClientX(Event)

isTouchEvent

@Deprecated
public static boolean isTouchEvent(Event event)
Deprecated. 


isTouchEvent

@Deprecated
public static boolean isTouchEvent(NativeEvent event)
Deprecated. 


simulateClickFromTouchEvent

@Deprecated
public static void simulateClickFromTouchEvent(Event touchevent,
                                                          Widget widget)
Deprecated. 


getFocusedElement

@Deprecated
public static com.google.gwt.user.client.Element getFocusedElement()
Deprecated. 

Gets the currently focused element.

Returns:
The active element or null if no active element could be found.

getIEFocusedElement

@Deprecated
public static com.google.gwt.user.client.Element getIEFocusedElement()
Deprecated. Use #getFocusedElement instead

Gets the currently focused element for Internet Explorer.

Returns:
The currently focused element

isFocusedElementEditable

@Deprecated
public static boolean isFocusedElementEditable()
Deprecated. 

Gets currently focused element and checks if it's editable

Returns:
true if focused element is editable
Since:
7.4

isAttachedAndDisplayed

@Deprecated
public static boolean isAttachedAndDisplayed(Widget widget)
Deprecated. 

Kind of stronger version of isAttached(). In addition to std isAttached, this method checks that this widget nor any of its parents is hidden. Can be e.g used to check whether component should react to some events or not.

Parameters:
widget -
Returns:
true if attached and displayed

scrollIntoViewVertically

@Deprecated
public static void scrollIntoViewVertically(Element elem)
Deprecated. 

Scrolls an element into view vertically only. Modified version of Element.scrollIntoView.

Parameters:
elem - The element to scroll into view

isTouchEventOrLeftMouseButton

@Deprecated
public static boolean isTouchEventOrLeftMouseButton(Event event)
Deprecated. 

Checks if the given event is either a touch event or caused by the left mouse button

Parameters:
event -
Returns:
true if the event is a touch event or caused by the left mouse button, false otherwise

collectionsEquals

public static boolean collectionsEquals(java.util.Collection<?> collection1,
                                        java.util.Collection<?> collection2)
Performs a shallow comparison of the collections.

Parameters:
collection1 - The first collection
collection2 - The second collection
Returns:
true if the collections contain the same elements in the same order, false otherwise

getConnectorString

public static java.lang.String getConnectorString(ServerConnector p)

getAbsoluteUrl

@Deprecated
public static java.lang.String getAbsoluteUrl(java.lang.String url)
Deprecated. 

Resolve a relative URL to an absolute URL based on the current document's location.

Parameters:
url - a string with the relative URL to resolve
Returns:
the corresponding absolute URL as a string

setSelectionRange

@Deprecated
public static void setSelectionRange(Element elem,
                                                int pos,
                                                int length,
                                                java.lang.String direction)
Deprecated. 

Sets the selection range of an input element. We need this JSNI function to set selection range so that we can use the optional direction attribute to set the anchor to the end and the focus to the start. This makes Firefox work the same way as other browsers (#13477)

Parameters:
elem - the html input element.
pos - the index of the first selected character.
length - the selection length.
direction - a string indicating the direction in which the selection was performed. This may be "forward" or "backward", or "none" if the direction is unknown or irrelevant.
Since:
7.3

jso2json

public static <T extends elemental.json.JsonValue> T jso2json(JavaScriptObject jso)
Converts a native JavaScriptObject into a JsonValue. This is a no-op in GWT code compiled to javascript, but needs some special handling to work when run in JVM.

Parameters:
jso - the java script object to represent as json
Returns:
the json representation

json2jso

public static JavaScriptObject json2jso(elemental.json.JsonValue jsonValue)
Converts a JsonValue into a native JavaScriptObject. This is a no-op in GWT code compiled to javascript, but needs some special handling to work when run in JVM.

Parameters:
jsonValue - the json value
Returns:
a native javascript object representation of the json value

parse

public static <T extends JavaScriptObject> T parse(java.lang.String jsonAsString)
Parse a string containing JSON into a JavaScriptObject.

Type Parameters:
T - the overlay type to expect from the parse
Parameters:
jsonAsString -
Returns:
a JavaScript object constructed from the parse


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.