|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.maryanovsky.gwtutils.client.ui.UiUtils
public class UiUtils
A utility class for UI related functionality.
Field Summary | |
---|---|
static com.maryanovsky.gwtutils.client.ui.UiUtils.Delegate |
LTR
The delegate for left-to-right languages. |
static com.maryanovsky.gwtutils.client.ui.UiUtils.Delegate |
RTL
The delegate for right-to-left languages. |
Constructor Summary | |
---|---|
UiUtils()
|
Method Summary | ||
---|---|---|
static void |
addDependentStyleName(Widget widget,
String styleSuffix)
Adds a dependent style name to the specified widget. |
|
static void |
addDialogButtons(HorizontalPanel panel,
List<? extends Widget> buttons)
Adds the specified dialog buttons to the specified panel. |
|
static void |
addFullSize(Panel panel,
Widget widget)
Adds the specified widget to the specified absolute panel and makes it occupy the panel fully. |
|
static void |
addInCorner(Panel panel,
Widget widget,
Alignment corner,
SizeView offset)
Adds the specified widget to the specified corner of the specified panel with the specified offset from the borders. |
|
static Object |
addLoadListener(Element element,
Callback<Element> callback)
Registers a load listener for the specified element which will invoke the specified callback with the element. |
|
static HandlerRegistration |
addSizeChangeHandler(Widget widget,
ResizeHandler handler)
Attempts to track changes in the size of the specified widget and notify the specified change listener. |
|
static void |
addWidgets(HorizontalPanel panel,
List<? extends Widget> widgets)
Adds the specified widgets to the specified horizontal panel in reading order. |
|
static void |
applyPngHack(Image image,
String url,
Size size)
Applies the IE PNG hack to the specified image. |
|
static void |
cancelCurrentEvent()
Cancels processing of the current event by stopping its propagation and preventing the default action from occurring. |
|
static
|
cancelEvent(DomEvent<H> evt)
Cancels the processing of the specified DomEvent by stopping its
propagation and preventing the default action from occurring. |
|
static void |
cancelEvent(NativeEvent evt)
Cancels processing of the specified event by stopping its propagation and preventing the default action from occurring. |
|
static void |
disableContextMenu(Element element)
Disables the browser context menu for the specified element (and enables right-click detection). |
|
static void |
disableDragging(Object dragTracker)
Makes the specified widget un-draggable, after it was made draggable with makeDraggable(Widget, HasAllMouseHandlers, HandlesAllDragEvents). |
|
static void |
extraImageCellHeightWorkaround(Element tdElement)
Fixes a strange problem with an image being placed in a table cell. |
|
static void |
extraImageCellHeightWorkaround(Widget panel)
Fixes the problem described by extraImageCellHeightWorkaround(Element) for every TD element of the specified panel. |
|
static void |
fillRow(HTMLTable table,
int row,
int height)
Fills the specified row of a table with vertical struts of the specified size. |
|
static void |
findElementsByTagName(Element parent,
String tagName,
List<Element> list)
Finds the children of the specified element whose tag name is the specified one, and adds them to the specified list. |
|
static Rectangle |
getBoundsClient(Widget widget)
Returns the bounds of the specified widget, in the client coordinate system. |
|
static PointView |
getCurrentTargetCoordinates(Touch touch,
TouchEvent<?> evt)
Returns the location of the specified touch in the coordinate system of the specified event's current target element. |
|
static Widget |
getHorizontalStrut(int width)
Creates a horizontal spacer of the specified width. |
|
static HasHorizontalAlignment.HorizontalAlignmentConstant |
getLeadingAlignment()
Returns the alignment constant corresponding to the beginning of the line in reading order. |
|
static String |
getPngHackedImageHtml(String url,
Size size)
Returns the HTML for an image at the specified URL with the PNG hack applied to it. |
|
static String |
getPrimaryStyleName(String fullStyleName)
Returns the "primary" style name based on the specified full style name. |
|
static String |
getPrimaryStyleName(Widget widget)
Returns the "primary" style name of the specified widget. |
|
static Widget |
getRelatedHorizontalStrut()
Returns a horizontal spacer of with the size of the preferred distance between related elements. |
|
static Widget |
getRelatedVerticalStrut()
Returns a vertical spacer of with the size of the preferred distance between related elements. |
|
static PointView |
getRelativeCoordinates(Touch touch,
Element target)
Returns the location of the specified touch in the coordinate system of the specified element. |
|
static Widget |
getRigidArea(int width,
int height)
Creates a spacer of the specified dimensions. |
|
static String |
getTagName(Element element)
Returns the tag name of the specified element. |
|
static PointView |
getTargetCoordinates(Touch touch)
Returns the location of the specified touch in the coordinate system of the target element. |
|
static Point |
getTopLeft(Widget widget)
Returns the top-left location of an absolutely positioned widget from its "top" and "left" style attributes. |
|
static HasHorizontalAlignment.HorizontalAlignmentConstant |
getTrailingAlignment()
Returns the alignment constant corresponding to the end of the line in reading order. |
|
static Widget |
getUnrelatedHorizontalStrut()
Returns a horizontal spacer of with the size of the preferred distance between unrelated elements. |
|
static Widget |
getUnrelatedVerticalStrut()
Returns a vertical spacer of with the size of the preferred distance between unrelated elements. |
|
static Widget |
getVerticalStrut(int height)
Creates a vertical spacer of the specified height. |
|
static boolean |
getVisibility(Widget widget)
Returns whether the specified widget's "visibility" CSS property is not set to "hidden" or "collapsed" or "inherit" and the parent's visibility is false. |
|
static Size |
getWidgetSize(Widget widget)
Returns the size of the specified widget (offsetWidth, offsetHeight). |
|
static
|
handleAllMouseEvents(HasAllMouseHandlers source,
H receiver)
Adds the specified mouse event handler to the specified mouse event source and returns the proper registration. |
|
static boolean |
isAncestorOf(Widget ancestor,
Widget widget)
Returns whether ancestor is an ancestor of the specified
widget. |
|
static boolean |
isNativeMouseButton(int button)
Returns whether the specified value is one of NativeEvent.BUTTON_LEFT , NativeEvent.BUTTON_MIDDLE or
NativeEvent.BUTTON_RIGHT . |
|
static Object |
makeDraggable(Widget widget,
HasAllMouseHandlers dragHandle,
HandlesAllDragEvents handler)
Makes the specified widget draggable via the specified drag handle. |
|
static Label |
makeLabelFor(String text)
Creates a label to be a label for some other element. |
|
static void |
maybeInitializeEventSystem()
If the event system has not yet been initialized, initializes it. |
|
static HTMLTable |
prepareLayoutTable(HTMLTable table)
Prepares the specified table to be a layout table by clearing its cell padding, spacing and border. |
|
static void |
removeListener(Element element,
Object listenerId)
Unregisters a load listener from the specified element. |
|
static void |
setAbsoluteBounds(Widget widget,
int left,
int top,
int width,
int height)
Makes the specified widget positioned absolutely and sets its bounds. |
|
static void |
setAbsoluteBounds(Widget widget,
RectangleView bounds)
Makes the specified widget positioned absolutely and sets its bounds. |
|
static void |
setAbsoluteFullSize(Widget widget)
Sets the specified widget's position attribute to "absolute", its top and left attributes to "0px" and its width and height attributes to "100%". |
|
static void |
setBounds(Element element,
int left,
int top,
int width,
int height)
Sets the "left", "top", "width" and "height" style attributes of the widget to the specified values, in pixels. |
|
static void |
setBounds(Element element,
RectangleView bounds)
Sets the bounds ("left", "top", "width" and "height" style attributes) of the specified element. |
|
static void |
setBounds(Widget widget,
int left,
int top,
int width,
int height)
Sets the "left", "top", "width" and "height" style attributes of the widget to the specified values, in pixels. |
|
static void |
setBounds(Widget widget,
RectangleView bounds)
Sets the bounds ("left", "top", "width" and "height" style attributes) of the specified widget. |
|
static void |
setContainingSize(AbsolutePanel panel)
Sets the bounds of the specified panel so that all of its widgets are within them (obviously, except those placed at negative coordinates). |
|
static void |
setDataDirection(Widget widget)
Sets the direction of the specified widget to LTR. |
|
static void |
setDelegate(com.maryanovsky.gwtutils.client.ui.UiUtils.Delegate delegate)
Sets the current delegate. |
|
static void |
setElementId(Widget widget,
String id)
Sets the id attribute of the specified widget's DOM element to the specified value. |
|
static void |
setFullSize(Widget widget)
Sets the specified widget's top and left attributes to "0px" and its width and height attributes to "100%". |
|
static void |
setGrabbingCursor(Widget widget)
Sets the "grabbing" cursor on the specified widget, if supported. |
|
static void |
setGrabbingCursorUrl(String url)
Sets the grabbing cursor to the specified URL. |
|
static void |
setGrabCursor(Widget widget)
Sets the "grab" cursor on the specified widget, if supported. |
|
static void |
setGrabCursorUrl(String url)
Sets the grab cursor to the specified URL. |
|
static void |
setGridRow(Grid grid,
int row,
List<? extends Widget> widgets)
Puts the specified widgets into the specified row in the grid, in language order. |
|
static void |
setGridRow(Grid grid,
int row,
List<? extends Widget> widgets,
List<HasVerticalAlignment.VerticalAlignmentConstant> vAlignments,
List<HasHorizontalAlignment.HorizontalAlignmentConstant> hAlignments)
Puts the specified widgets into the specified row in the grid, in language order. |
|
static void |
setLeadingMargin(Widget widget,
int size)
Sets the margin leading the element, in the reading direction (left when in LTR, right when in RTL mode). |
|
static void |
setOpacity(Widget widget,
double opacity)
Sets the opacity of the specified widget to the specified value, where 0 stands for completely transparent and 1 for completely opaque. |
|
static void |
setPosition(Element element,
int left,
int top)
Sets the "left" and "top" style attributes of the widget to the specified values, in pixels. |
|
static void |
setPosition(Widget widget,
int left,
int top)
Sets the "left" and "top" style attributes of the widget to the specified values, in pixels. |
|
static void |
setPosition(Widget widget,
PointView position)
Sets the position of the widget to the specified one, in pixels. |
|
static void |
setSize(Element element,
int width,
int height)
Sets the "width" and "height" attributes of the element to the specified values, in pixels. |
|
static void |
setSize(Widget widget,
int width,
int height)
Sets the "width" and "height" style attributes of the widget to the specified values, in pixels. |
|
static void |
setSize(Widget widget,
SizeView size)
Sets the size of the widget to the specified one, in pixels. |
|
static void |
setTextDirection(Widget widget)
Sets the direction of the specified widget to the direction of the application's language. |
|
static void |
setTopLeft(Widget widget,
int x,
int y)
Sets the widget's position via the "top" and "left" style attributes. |
|
static void |
setTopLeft(Widget widget,
PointView point)
Sets the widget's position via the "top" and "left" style attributes. |
|
static void |
setTrailingMargin(Widget widget,
int size)
Sets the margin trailing the element, in the reading direction (right when in LTR, left when in RTL mode). |
|
static void |
setTransform(Element element,
String transform)
Applies the specified transform CSS property to the specified element. |
|
static void |
setTransformOrigin(Element element,
String origin)
Applies the specified transform-origin CSS property to the specified element. |
|
static void |
setVisibility(Widget widget,
boolean isVisible)
Sets the visibility of the specified widget. |
|
static void |
setVisualWidth(Widget widget,
GwtUiDefaults.WidgetElementType elementType,
int width)
Sets the width of the specified widget so that its visual width is as specified. |
|
static void |
setVisualWidth(Widget widget,
int width)
Sets the width of the specified widget so that its visual width is as specified. |
|
static void |
setZOrder(Widget... widgets)
Sets the z-indices of the specified widgets to their indices in the specified array, making widgets with greater indices appear on top of widgets with smaller indices. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final com.maryanovsky.gwtutils.client.ui.UiUtils.Delegate LTR
public static final com.maryanovsky.gwtutils.client.ui.UiUtils.Delegate RTL
Constructor Detail |
---|
public UiUtils()
Method Detail |
---|
public static void setDelegate(com.maryanovsky.gwtutils.client.ui.UiUtils.Delegate delegate)
LTR
and
RTL
.
public static Label makeLabelFor(String text)
public static void setLeadingMargin(Widget widget, int size)
public static void setTrailingMargin(Widget widget, int size)
public static void setGridRow(Grid grid, int row, List<? extends Widget> widgets)
public static void setGridRow(Grid grid, int row, List<? extends Widget> widgets, List<HasVerticalAlignment.VerticalAlignmentConstant> vAlignments, List<HasHorizontalAlignment.HorizontalAlignmentConstant> hAlignments)
null
).
public static void addWidgets(HorizontalPanel panel, List<? extends Widget> widgets)
public static void addDialogButtons(HorizontalPanel panel, List<? extends Widget> buttons)
public static HasHorizontalAlignment.HorizontalAlignmentConstant getLeadingAlignment()
public static HasHorizontalAlignment.HorizontalAlignmentConstant getTrailingAlignment()
public static void setTextDirection(Widget widget)
public static void setDataDirection(Widget widget)
public static void setVisualWidth(Widget widget, GwtUiDefaults.WidgetElementType elementType, int width)
public static void setVisualWidth(Widget widget, int width)
setVisualWidth(Widget, GwtUiDefaults.WidgetElementType, int)
in that it guesses the element type of the widget itself, but only works
for standard GWT widgets.
public static Widget getHorizontalStrut(int width)
public static Widget getVerticalStrut(int height)
public static Widget getRigidArea(int width, int height)
public static Widget getRelatedHorizontalStrut()
public static Widget getUnrelatedHorizontalStrut()
public static Widget getRelatedVerticalStrut()
public static Widget getUnrelatedVerticalStrut()
public static void setAbsoluteFullSize(Widget widget)
public static void setFullSize(Widget widget)
public static void addFullSize(Panel panel, Widget widget)
public static void setAbsoluteBounds(Widget widget, int left, int top, int width, int height)
public static void setAbsoluteBounds(Widget widget, RectangleView bounds)
public static void setBounds(Widget widget, int left, int top, int width, int height)
public static void setBounds(Widget widget, RectangleView bounds)
public static void setBounds(Element element, RectangleView bounds)
public static void setBounds(Element element, int left, int top, int width, int height)
public static void setSize(Widget widget, int width, int height)
public static void setSize(Element element, int width, int height)
public static void setSize(Widget widget, SizeView size)
public static void setPosition(Widget widget, int left, int top)
public static void setPosition(Element element, int left, int top)
public static void setPosition(Widget widget, PointView position)
public static void setContainingSize(AbsolutePanel panel)
public static void addInCorner(Panel panel, Widget widget, Alignment corner, SizeView offset)
panel
- The panel to add to.widget
- The widget to place in a corner.corner
- The corner to place the widget in. This must be one of the
alignment constants which define a corner (not anything in the middle).offset
- The offset, in pixels, from the borders.public static Point getTopLeft(Widget widget)
public static void setTopLeft(Widget widget, PointView point)
public static void setTopLeft(Widget widget, int x, int y)
public static Rectangle getBoundsClient(Widget widget)
public static Size getWidgetSize(Widget widget)
public static PointView getTargetCoordinates(Touch touch)
public static PointView getCurrentTargetCoordinates(Touch touch, TouchEvent<?> evt)
public static PointView getRelativeCoordinates(Touch touch, Element target)
public static void disableContextMenu(Element element)
public static void setElementId(Widget widget, String id)
public static String getTagName(Element element)
public static void findElementsByTagName(Element parent, String tagName, List<Element> list)
public static String getPrimaryStyleName(String fullStyleName)
public static String getPrimaryStyleName(Widget widget)
public static void addDependentStyleName(Widget widget, String styleSuffix)
styleSuffix
- The suffix of the dependent style (not including the
'-' separator).public static void setVisibility(Widget widget, boolean isVisible)
UIObject.setVisible(boolean)
in that it uses the "visibility" CSS
property, and not "display".
public static boolean getVisibility(Widget widget)
public static void setZOrder(Widget... widgets)
public static void setOpacity(Widget widget, double opacity)
public static void setGrabCursorUrl(String url)
setGrabCursor(Widget)
.
public static void setGrabbingCursorUrl(String url)
setGrabbingCursor(Widget)
.
public static void setGrabCursor(Widget widget)
setGrabCursorUrl(String)
or it will
currently only work under Mozilla browsers.
public static void setGrabbingCursor(Widget widget)
setGrabbingCursorUrl(String)
or it
will currently only work under Mozilla browsers.
public static void extraImageCellHeightWorkaround(Element tdElement)
public static void extraImageCellHeightWorkaround(Widget panel)
public static void fillRow(HTMLTable table, int row, int height)
public static HTMLTable prepareLayoutTable(HTMLTable table)
public static <H extends MouseDownHandler & MouseUpHandler & MouseOutHandler & MouseOverHandler & MouseMoveHandler & MouseWheelHandler> HandlerRegistration handleAllMouseEvents(HasAllMouseHandlers source, H receiver)
HandlesAllMouseEvents.handle(HasAllMouseHandlers, MouseDownHandler)
doesn't bother to return a proper HandlerRegistration
.
public static HandlerRegistration addSizeChangeHandler(Widget widget, ResizeHandler handler)
public static void cancelCurrentEvent()
public static void cancelEvent(NativeEvent evt)
public static <H extends EventHandler> void cancelEvent(DomEvent<H> evt)
DomEvent
by stopping its
propagation and preventing the default action from occurring.
public static Object makeDraggable(Widget widget, HasAllMouseHandlers dragHandle, HandlesAllDragEvents handler)
null
, with all parameters passed being relative to
the parent of the dragged widget. That is, the drag target widget will be
the parent and the pressed point and offset will be relative to the
parent.
You may make the widget un-draggable again by passing the return value to
disableDragging(Object).
public static void disableDragging(Object dragTracker)
dragTracker
- The object returned by makeDraggable
.public static void applyPngHack(Image image, String url, Size size)
Image.setUrl(String)
directly; always use this method
instead. Also, using Image.getUrl()
on a PNG-hacked image will
not return the expected URL. You don't have to, but are advised to
specify the image's size - the PNG hack is only 100% reliable if you do.
image
- The image to apply the PNG hack to.url
- The URL of the PNG image.size
- The size of the image; may be null
.public static String getPngHackedImageHtml(String url, Size size)
public static void maybeInitializeEventSystem()
public static boolean isNativeMouseButton(int button)
NativeEvent.BUTTON_LEFT
, NativeEvent.BUTTON_MIDDLE
or
NativeEvent.BUTTON_RIGHT
.
public static boolean isAncestorOf(Widget ancestor, Widget widget)
ancestor
is an ancestor of the specified
widget.
public static void setTransform(Element element, String transform)
public static void setTransformOrigin(Element element, String origin)
public static Object addLoadListener(Element element, Callback<Element> callback)
public static void removeListener(Element element, Object listenerId)
addLoadListener(com.google.gwt.dom.client.Element, Callback)
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |