com.allen_sauer.gwt.dnd.client.util
Class DOMUtil

java.lang.Object
  extended by com.allen_sauer.gwt.dnd.client.util.DOMUtil

public class DOMUtil
extends java.lang.Object

Provides DOM utility methods.


Field Summary
static boolean DEBUG
          Whether or not debugging is enabled.
 
Constructor Summary
DOMUtil()
           
 
Method Summary
static java.lang.String adjustTitleForBrowser(java.lang.String title)
          Adjust line breaks within in the provided title for optimal readability and display length for the current user agent.
static void cancelAllDocumentSelections()
          Cancel all currently selected region(s) on the current page.
static void debugWidgetWithColor(com.google.gwt.user.client.ui.Widget widget, java.lang.String color)
          Set a widget's border style for debugging purposes.
static void fastSetElementPosition(com.google.gwt.dom.client.Element elem, int left, int top)
          Set an element's location as fast as possible, avoiding some of the overhead in AbsolutePanel.setWidgetPosition(Widget, int, int) .
static int findIntersect(com.google.gwt.user.client.ui.IndexedPanel parent, Location location, LocationWidgetComparator comparator)
          Find child widget intersection at the provided location using the provided comparator strategy.
static int getBorderLeft(com.google.gwt.dom.client.Element elem)
          Gets an element's CSS based 'border-left-width' in pixels or 0 (zero) when the element is hidden.
static int getBorderTop(com.google.gwt.dom.client.Element elem)
          Gets an element's CSS based 'border-top-widget' in pixels or 0 (zero) when the element is hidden.
static int getClientHeight(com.google.gwt.dom.client.Element elem)
          Gets an element's client height in pixels or 0 (zero) when the element is hidden.
static int getClientWidth(com.google.gwt.dom.client.Element elem)
          Gets an element's client widget in pixels or 0 (zero) when the element is hidden.
static java.lang.String getEffectiveStyle(com.google.gwt.dom.client.Element elem, java.lang.String styleName)
           
static int getHorizontalBorders(com.google.gwt.user.client.ui.Widget widget)
          Gets the sum of an element's left and right CSS borders in pixels.
static java.lang.String getNodeName(com.google.gwt.dom.client.Element elem)
          Determine an element's node name via the nodeName property.
static int getVerticalBorders(com.google.gwt.user.client.ui.Widget widget)
          Gets the sum of an element's top and bottom CSS borders in pixels.
static void reportFatalAndThrowRuntimeException(java.lang.String msg)
          Report a fatal exception via Window.alert() than throw a RuntimeException.
static void setStatus(java.lang.String text)
          Set the browser's status bar text, if supported and enabled in the client browser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
Whether or not debugging is enabled.

See Also:
Constant Field Values
Constructor Detail

DOMUtil

public DOMUtil()
Method Detail

adjustTitleForBrowser

public static java.lang.String adjustTitleForBrowser(java.lang.String title)
Adjust line breaks within in the provided title for optimal readability and display length for the current user agent.

Parameters:
title - the desired raw text
Returns:
formatted and escaped text

cancelAllDocumentSelections

public static void cancelAllDocumentSelections()
Cancel all currently selected region(s) on the current page.


debugWidgetWithColor

public static void debugWidgetWithColor(com.google.gwt.user.client.ui.Widget widget,
                                        java.lang.String color)
Set a widget's border style for debugging purposes.

Parameters:
widget - the widget to color
color - the desired border color

fastSetElementPosition

public static void fastSetElementPosition(com.google.gwt.dom.client.Element elem,
                                          int left,
                                          int top)
Set an element's location as fast as possible, avoiding some of the overhead in AbsolutePanel.setWidgetPosition(Widget, int, int) .

Parameters:
elem - the element's whose position is to be modified
left - the left pixel offset
top - the top pixel offset

findIntersect

public static int findIntersect(com.google.gwt.user.client.ui.IndexedPanel parent,
                                Location location,
                                LocationWidgetComparator comparator)
Find child widget intersection at the provided location using the provided comparator strategy. TODO Handle LTR case for Bidi TODO Change IndexedPanel -> InsertPanel

Parameters:
parent - the parent widget which contains the children to be compared
location - the location of the intersection
comparator - the comparator strategy
Returns:
the index of the matching child

getBorderLeft

public static int getBorderLeft(com.google.gwt.dom.client.Element elem)
Gets an element's CSS based 'border-left-width' in pixels or 0 (zero) when the element is hidden.

Parameters:
elem - the element to be measured
Returns:
the width of the left CSS border in pixels

getBorderTop

public static int getBorderTop(com.google.gwt.dom.client.Element elem)
Gets an element's CSS based 'border-top-widget' in pixels or 0 (zero) when the element is hidden.

Parameters:
elem - the element to be measured
Returns:
the width of the top CSS border in pixels

getClientHeight

public static int getClientHeight(com.google.gwt.dom.client.Element elem)
Gets an element's client height in pixels or 0 (zero) when the element is hidden. This is equal to offset height minus the top and bottom CSS borders.

Parameters:
elem - the element to be measured
Returns:
the element's client height in pixels

getClientWidth

public static int getClientWidth(com.google.gwt.dom.client.Element elem)
Gets an element's client widget in pixels or 0 (zero) when the element is hidden. This is equal to offset width minus the left and right CSS borders.

Parameters:
elem - the element to be measured
Returns:
the element's client width in pixels

getEffectiveStyle

public static java.lang.String getEffectiveStyle(com.google.gwt.dom.client.Element elem,
                                                 java.lang.String styleName)

getHorizontalBorders

public static int getHorizontalBorders(com.google.gwt.user.client.ui.Widget widget)
Gets the sum of an element's left and right CSS borders in pixels.

Parameters:
widget - the widget to be measured
Returns:
the total border width in pixels

getNodeName

public static java.lang.String getNodeName(com.google.gwt.dom.client.Element elem)
Determine an element's node name via the nodeName property.

Parameters:
elem - the element whose node name is to be determined
Returns:
the element's node name

getVerticalBorders

public static int getVerticalBorders(com.google.gwt.user.client.ui.Widget widget)
Gets the sum of an element's top and bottom CSS borders in pixels.

Parameters:
widget - the widget to be measured
Returns:
the total border height in pixels

reportFatalAndThrowRuntimeException

public static void reportFatalAndThrowRuntimeException(java.lang.String msg)
                                                throws java.lang.RuntimeException
Report a fatal exception via Window.alert() than throw a RuntimeException.

Parameters:
msg - the message to report
Throws:
java.lang.RuntimeException - a new exception based on the provided message

setStatus

public static void setStatus(java.lang.String text)
Set the browser's status bar text, if supported and enabled in the client browser.

Parameters:
text - the message to use as the window status


Copyright © 2011 Sage Software, Inc. All rights reserved.