com.itmill.toolkit.terminal.gwt.client
Class Util

java.lang.Object
  extended by com.itmill.toolkit.terminal.gwt.client.Util

public class Util
extends Object


Constructor Summary
Util()
           
 
Method Summary
static void addPngFix(com.google.gwt.user.client.Element el, String blankImageUrl)
          Adds transparent PNG fix to image element; only use for IE6.
static void alert(String string)
           
static void browserDebugger()
          Helper method for debugging purposes.
static com.google.gwt.user.client.Element cloneNode(com.google.gwt.user.client.Element element, boolean deep)
          Clones given element as in JavaScript.
static void componentSizeUpdated(Set<Paintable> widgets)
          Called when the size of one or more widgets have changed during rendering.
static boolean equals(Object a, Object b)
           
static String escapeHTML(String html)
          Converts html entities to text.
static Container getLayout(com.google.gwt.user.client.ui.Widget component)
          Returns closest parent Widget in hierarchy that implements Container interface
static int getNativeScrollbarSize()
           
static int getRequiredHeight(com.google.gwt.dom.client.Element element)
           
static int getRequiredHeight(com.google.gwt.user.client.ui.Widget widget)
           
static int getRequiredWidth(com.google.gwt.dom.client.Element element)
           
static int getRequiredWidth(com.google.gwt.user.client.ui.Widget widget)
           
static String getSimpleName(Object widget)
           
static boolean isCached(UIDL uidl)
           
static boolean isFF2()
          Deprecated. use BrowserInfo class instead
static boolean isIE()
          Deprecated. use BrowserInfo class instead
static boolean isIE6()
          Deprecated. use BrowserInfo class instead
static boolean isIE7()
          Deprecated. use BrowserInfo class instead
static boolean mayHaveScrollBars(com.google.gwt.dom.client.Element pe)
          Detects what is currently the overflow style attribute in given element.
static int measureHorizontalBorder(com.google.gwt.user.client.Element element)
           
static int measureHorizontalPaddingAndBorder(com.google.gwt.user.client.Element element, int paddingGuess)
           
static int measureMarginLeft(com.google.gwt.user.client.Element element)
           
static int measureVerticalBorder(com.google.gwt.user.client.Element element)
           
static int measureVerticalPaddingAndBorder(com.google.gwt.user.client.Element element, int paddingGuess)
           
static void notifyParentOfSizeChange(Paintable widget, boolean lazy)
          This helper method can be called if components size have been changed outside rendering phase.
static float parseRelativeSize(String size)
           
static RenderInformation.FloatSize parseRelativeSize(UIDL uidl)
          Parses the UIDL parameter and fetches the relative size of the component.
static void runWebkitOverflowAutoFix(com.google.gwt.user.client.Element elem)
          Run workaround for webkits overflow auto issue.
static void setFloat(com.google.gwt.user.client.Element element, String value)
           
static int setHeightExcludingPaddingAndBorder(com.google.gwt.user.client.Element element, int requestedHeight, int verticalPaddingBorderGuess, boolean requestedHeightIncludesPaddingBorder)
           
static int setHeightExcludingPaddingAndBorder(com.google.gwt.user.client.ui.Widget widget, String height, int paddingBorderGuess)
           
static int setWidthExcludingPaddingAndBorder(com.google.gwt.user.client.Element element, int requestedWidth, int horizontalPaddingBorderGuess, boolean requestedWidthIncludesPaddingBorder)
           
static int setWidthExcludingPaddingAndBorder(com.google.gwt.user.client.ui.Widget widget, String width, int paddingBorderGuess)
           
static void updateRelativeChildrenAndSendSizeUpdateEvent(ApplicationConnection client, com.google.gwt.user.client.ui.HasWidgets container)
           
static void updateRelativeChildrenAndSendSizeUpdateEvent(ApplicationConnection client, com.google.gwt.user.client.ui.HasWidgets container, Paintable 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

public static void browserDebugger()
Helper method for debugging purposes. Stops execution on firefox browsers on a breakpoint.


notifyParentOfSizeChange

public static void notifyParentOfSizeChange(Paintable widget,
                                            boolean lazy)
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

componentSizeUpdated

public static void componentSizeUpdated(Set<Paintable> widgets)
Called when the size of one or more widgets have changed during rendering. Finds parent container and notifies them of the size change.

Parameters:
widgets -

parseRelativeSize

public static float parseRelativeSize(String size)

getLayout

public static Container getLayout(com.google.gwt.user.client.ui.Widget component)
Returns closest parent Widget in hierarchy that implements Container interface

Parameters:
component -
Returns:
closest parent Container

isIE

@Deprecated
public static boolean isIE()
Deprecated. use BrowserInfo class instead

Detects if current browser is IE.

Returns:
true if IE

isIE6

@Deprecated
public static boolean isIE6()
Deprecated. use BrowserInfo class instead

Detects if current browser is IE6.

Returns:
true if IE6

isIE7

@Deprecated
public static boolean isIE7()
Deprecated. use BrowserInfo class instead

Returns:

isFF2

@Deprecated
public static boolean isFF2()
Deprecated. use BrowserInfo class instead

Returns:

escapeHTML

public static String escapeHTML(String html)
Converts html entities to text.

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

addPngFix

public static void addPngFix(com.google.gwt.user.client.Element el,
                             String blankImageUrl)
Adds transparent PNG fix to image element; only use for IE6.

Parameters:
el - IMG element
blankImageUrl - URL to transparent one-pixel gif

cloneNode

public static com.google.gwt.user.client.Element cloneNode(com.google.gwt.user.client.Element element,
                                                           boolean deep)
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

public static int measureHorizontalPaddingAndBorder(com.google.gwt.user.client.Element element,
                                                    int paddingGuess)

measureVerticalPaddingAndBorder

public static int measureVerticalPaddingAndBorder(com.google.gwt.user.client.Element element,
                                                  int paddingGuess)

measureHorizontalBorder

public static int measureHorizontalBorder(com.google.gwt.user.client.Element element)

measureVerticalBorder

public static int measureVerticalBorder(com.google.gwt.user.client.Element element)

measureMarginLeft

public static int measureMarginLeft(com.google.gwt.user.client.Element element)

setHeightExcludingPaddingAndBorder

public static int setHeightExcludingPaddingAndBorder(com.google.gwt.user.client.ui.Widget widget,
                                                     String height,
                                                     int paddingBorderGuess)

setWidthExcludingPaddingAndBorder

public static int setWidthExcludingPaddingAndBorder(com.google.gwt.user.client.ui.Widget widget,
                                                    String width,
                                                    int paddingBorderGuess)

setWidthExcludingPaddingAndBorder

public static int setWidthExcludingPaddingAndBorder(com.google.gwt.user.client.Element element,
                                                    int requestedWidth,
                                                    int horizontalPaddingBorderGuess,
                                                    boolean requestedWidthIncludesPaddingBorder)

setHeightExcludingPaddingAndBorder

public static int setHeightExcludingPaddingAndBorder(com.google.gwt.user.client.Element element,
                                                     int requestedHeight,
                                                     int verticalPaddingBorderGuess,
                                                     boolean requestedHeightIncludesPaddingBorder)

getSimpleName

public static String getSimpleName(Object widget)

setFloat

public static void setFloat(com.google.gwt.user.client.Element element,
                            String value)

getNativeScrollbarSize

public static int getNativeScrollbarSize()

runWebkitOverflowAutoFix

public static void runWebkitOverflowAutoFix(com.google.gwt.user.client.Element elem)
Run workaround for webkits overflow auto issue. See: our buh #2138 and https://bugs.webkit.org/show_bug.cgi?id=21462

Parameters:
elem - with overflow auto

parseRelativeSize

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

Parameters:
uidl -
Returns:

isCached

public static boolean isCached(UIDL uidl)

alert

public static void alert(String string)

equals

public static boolean equals(Object a,
                             Object b)

updateRelativeChildrenAndSendSizeUpdateEvent

public static void updateRelativeChildrenAndSendSizeUpdateEvent(ApplicationConnection client,
                                                                com.google.gwt.user.client.ui.HasWidgets container)

updateRelativeChildrenAndSendSizeUpdateEvent

public static void updateRelativeChildrenAndSendSizeUpdateEvent(ApplicationConnection client,
                                                                com.google.gwt.user.client.ui.HasWidgets container,
                                                                Paintable widget)

getRequiredWidth

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

getRequiredHeight

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

getRequiredWidth

public static int getRequiredWidth(com.google.gwt.user.client.ui.Widget widget)

getRequiredHeight

public static int getRequiredHeight(com.google.gwt.user.client.ui.Widget widget)

mayHaveScrollBars

public static boolean mayHaveScrollBars(com.google.gwt.dom.client.Element pe)
Detects what is currently the overflow style attribute in given element.

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


Copyright © 2000-2009 IT Mill Ltd. All Rights Reserved.