|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.maryanovsky.gwtutils.client.UiUtils
public class UiUtils
A utility class for UI related functionality.
| Field Summary | |
|---|---|
static com.maryanovsky.gwtutils.client.UiUtils.Delegate |
LTR
The delegate for left-to-right languages. |
static com.maryanovsky.gwtutils.client.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,
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 void |
addWidgets(HorizontalPanel panel,
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 cancalling bubble and preventing the default action on event 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, SourcesMouseEvents, DragAction). |
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 list)
Finds the children of the specified element whose tag name is the specified one, and adds them to the specified list. |
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 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 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 Object |
makeDraggable(Widget widget,
SourcesMouseEvents dragHandle,
DragAction dragAction)
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 HTMLTable |
prepareLayoutTable(HTMLTable table)
Prepares the specified table to be a layout table by clearing its cell padding, spacing and border. |
static void |
setAbsoluteBounds(Widget widget,
int left,
int top,
int width,
int height)
Sets the bounds of the specified widget and its "position" style attribute to "absolute". |
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(Widget widget,
int left,
int top,
int width,
int height)
Sets the "left", "top", "width" and "height" attributes of the widget to the specified values, in pixels. |
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.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,
Widget[] widgets)
Puts the specified widgets into the specified row in the grid, in language order. |
static void |
setGridRow(Grid grid,
int row,
Widget[] widgets,
HasVerticalAlignment.VerticalAlignmentConstant[] vAlignments,
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 |
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 |
setVisible(Widget widget,
boolean isVisible)
Sets the visibility of the specified widget. |
static void |
setVisualWidth(Widget widget,
int width)
Sets the width of the specified widget so that its visual width is as specified. |
static void |
setVisualWidth(Widget widget,
Object elementType,
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. |
static void |
stopTrackingResizes(Object resizeTracker)
Stops tracking size changes for some widget. |
static Object |
trackResizes(Widget widget,
ChangeListener listener)
Attempts to track changes in the size of the specified widget and notify the specified change listener. |
| 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.UiUtils.Delegate LTR
public static final com.maryanovsky.gwtutils.client.UiUtils.Delegate RTL
| Constructor Detail |
|---|
public UiUtils()
| Method Detail |
|---|
public static void setDelegate(com.maryanovsky.gwtutils.client.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,
Widget[] widgets)
public static void setGridRow(Grid grid,
int row,
Widget[] widgets,
HasVerticalAlignment.VerticalAlignmentConstant[] vAlignments,
HasHorizontalAlignment.HorizontalAlignmentConstant[] hAlignments)
null).
public static void addWidgets(HorizontalPanel panel,
Widget[] widgets)
public static void addDialogButtons(HorizontalPanel panel,
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,
Object elementType,
int width)
elementType if one of the UI element
constants in GWTUiDefaults.
public static void setVisualWidth(Widget widget,
int width)
setVisualWidth(Widget, Object, 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 setBounds(Widget widget,
int left,
int top,
int width,
int height)
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 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 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 setVisible(Widget widget,
boolean isVisible)
UIObject.setVisible(boolean) in that it uses the "visibility" CSS
property, and not "display".
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).
public static void setGrabbingCursor(Widget widget)
setGrabbingCursorUrl(String).
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 Object trackResizes(Widget widget,
ChangeListener listener)
public static void stopTrackingResizes(Object resizeTracker)
public static void cancelCurrentEvent()
public static Object makeDraggable(Widget widget,
SourcesMouseEvents dragHandle,
DragAction dragAction)
DragAction,
if not 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)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||