|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.gwt.core.client.JavaScriptObject
com.google.gwt.dom.client.Node
com.google.gwt.dom.client.Element
com.google.gwt.user.client.Element
com.sencha.gxt.core.client.dom.XElement
public class XElement
Adds additional features and functionality to the GWT Element
class.
createElement(String) method.
| Nested Class Summary | |
|---|---|
static class |
XElement.VisMode
VisMode enumeration. |
| Field Summary |
|---|
| Fields inherited from class com.google.gwt.dom.client.Element |
|---|
DRAGGABLE_AUTO, DRAGGABLE_FALSE, DRAGGABLE_TRUE |
| Fields inherited from class com.google.gwt.dom.client.Node |
|---|
DOCUMENT_NODE, ELEMENT_NODE, TEXT_NODE |
| Method Summary | |
|---|---|
void |
addClassName(String... classNames)
Adds the style name to the element. |
void |
addEventsSunk(int event)
Adds the event type to the element's sunk events. |
static String |
addUnits(String v,
String defaultUnit)
Tests to see if the value has units, otherwise appends the default (px). |
Point |
adjustForConstraints(Point p)
Ensures the element is within the browser viewport. |
void |
alignTo(Element elem,
Style.AnchorAlignment alignment,
int[] offsets)
Aligns the element with another element relative to the specified anchor points. |
void |
applyStyles(String styles)
Sets multiple style properties. |
static XElement |
as(Node node)
Assert that the given Node is an Element and automatically
typecast it. |
void |
center()
Centers the element in the viewport. |
void |
center(boolean constrainViewport)
Centers the element. |
void |
center(Element container)
Centers an element. |
XElement |
child(String selector)
Selects a single child at any depth below this element based on the passed CSS selector. |
Element |
childElement(String selector)
Selects a single child at any depth below this element based on the passed CSS selector. |
void |
clearOpacity()
Clears the set opacity correctly. |
void |
click()
Generators a native dom click on the element. |
XElement |
createChild(String html)
Creates and adds a child using the HTML fragment. |
static XElement |
createElement(String tagName)
Creates a new element based on the specified HTML tag name. |
void |
disable()
Disables the element. |
void |
disableTextSelection(boolean disable)
Enables or disables text selection for the element. |
XElement |
down(String selector)
Selects a single *direct* child based on the passed CSS selector (the selector should not contain an id). |
void |
enable()
Enables the element. |
List<FastMap<Object>> |
ensureVisible()
Walks up the DOM and ensures all elements are visible. |
XElement |
findParent(String selector,
int maxDepth)
Looks at this node and then at parent nodes for a match of the passed simple selector (e.g. |
Element |
findParentElement(String selector,
int maxDepth)
Looks at this node and then at parent nodes for a match of the passed simple selector (e.g. |
Point |
getAlignToXY(Element elem,
Style.AnchorAlignment alignment,
int[] offsets)
Gets the x,y coordinates to align this element with another element. |
Point |
getAlignToXY(Element elem,
Style.AnchorAlignment alignment,
int ox,
int oy)
Gets the x,y coordinates to align this element with another element. |
Point |
getAnchorXY(Style.Anchor anchor,
boolean local)
Returns the x,y coordinates specified by the anchor position on the element. |
Rectangle |
getBounds()
Returns the elements bounds in page coordinates. |
Rectangle |
getBounds(boolean local)
Returns the elements bounds in page coordinates. |
Rectangle |
getBounds(boolean local,
boolean adjust)
Returns the element's bounds in page coordinates. |
int |
getChildIndex(Element child)
Returns the index of the child element. |
int |
getComputedHeight()
Returns either the offsetHeight or the height of this element based on it's CSS height. |
FastMap<String> |
getComputedStyle(List<String> props)
Returns a map of style values mapped by property name. |
String |
getComputedStyle(String prop)
Normalizes currentStyle and computedStyle. |
int |
getComputedWidth()
Returns either the offsetWidth or the width of this element based on it's CSS width. |
Size |
getFrameSize()
Returns the sum width of the padding and borders for all "sides". |
int |
getFrameWidth(Style.Side... side)
Returns the sum width of the padding and borders for the passed "sides". |
int |
getHeight(boolean content)
Returns the element's height. |
String |
getId(boolean autoGenId)
Returns the element's id. |
int |
getLeft()
Returns the top Y coordinate. |
int |
getLeft(boolean local)
Gets the left X coordinate. |
int |
getMargins(Style.Side... sides)
Returns the total margin size of the specified sides. |
Point |
getOffsetsTo(Element to)
Returns the offsets between two elements. |
int |
getPadding(Style.Side... sides)
Returns the width of the padding(s) for the specified side(s). |
Point |
getPosition(boolean local)
Returns the widget's current position. |
Region |
getRegion()
Returns the region of the given element. |
int |
getRight(boolean local)
Returns the right X coordinate of the element (element X position + element width). |
Scroll |
getScroll()
Returns the body elements current scroll position. |
Size |
getSize()
Returns the size of the element. |
Size |
getSize(boolean content)
Returns the element's size. |
Size |
getStyleSize()
Returns the element's size (excluding padding and borders), using style attribute before offsets. |
Size |
getStyleSize(boolean contentOnly)
Returns the element's size, using style attribute before offsets. |
Element |
getSubChild(int depth)
Returns the element's sub child. |
int |
getTextWidth()
Returns the measured width of the element's text. |
int |
getTop()
Returns the top Y coordinate. |
int |
getTop(boolean local)
Gets the top Y coordinate. |
XElement.VisMode |
getVisMode()
Returns the vis mode. |
int |
getWidth(boolean content)
Returns the element's width. |
int |
getX()
Gets the current X position of the element based on page coordinates. |
Point |
getXY()
Gets the current position of the element based on page coordinates. |
int |
getY()
Gets the current Y position of the element based on page coordinates. |
int |
getZIndex()
Returns the element's z-index. |
boolean |
hasClassName(String test)
Checks if the specified class name exists on this element. |
void |
hide()
Hides this element. |
int |
indexOf(Element child)
Returns the index of the child. |
void |
insertBefore(Element element)
Inserts this element before the passed element. |
void |
insertBefore(NodeList<Element> elements)
Inserts the elements before this element. |
void |
insertChild(Element child,
int index)
Inserts an element at the specified index. |
XElement |
insertFirst(String html)
Creates and inserts a child element. |
XElement |
insertHtml(String where,
String html)
Inserts an html fragment into this element |
boolean |
is(String selector)
Returns true if this element matches the passed simple selector (e.g. |
boolean |
isBorderBox()
Returns true if the element is a border box. |
static boolean |
isBorderBox(Element element)
Returns true if the passed element has a border box. |
boolean |
isConnected()
Returns true if the element is part of the browser's DOM. |
boolean |
isStyleAttribute(String attr,
String value)
Tests the style for the given value. |
boolean |
isStyleProperty(Map<String,String> map,
boolean matchAll)
Tests style property values for matches. |
boolean |
isVisible()
Returns whether the element is currently visible. |
boolean |
isVisible(boolean deep)
Returns whether the element is currently visible. |
Request |
load(RequestBuilder builder)
Retrieves the data using the request builder and updates the element's contents. |
void |
makePositionable()
Makes an element positionable. |
void |
makePositionable(boolean absolute)
Makes an element positionable. |
void |
mask(String message)
Puts a mask over this element to disable user interaction. |
void |
removeChildren()
Removes all the elements children. |
void |
removeClassName(String... classNames)
Removes the style names(s) from the element. |
void |
repaint()
Forces the Browser to repaint this element. |
void |
replaceClassName(String oldClassName,
String newClassName,
boolean deep)
Replace one class name with another. |
void |
restoreVisible(List<FastMap<Object>> list)
Restores any elements made visible with ensureVisible(). |
void |
scrollIntoView(Element container,
boolean hscroll)
Scrolls the element into view. |
void |
scrollIntoView(Element container,
boolean hscroll,
int[] offsets)
Scrolls the element into view. |
void |
scrollTo(Style.ScrollDirection side,
int value)
Scrolls this element the specified scroll point. |
NodeList<Element> |
select(String selector)
Selects child nodes based on the passed CSS selector (the selector should not contain an id). |
XElement |
selectNode(String selector)
Selects a single element. |
void |
setAttributeNS(String nameSpace,
String name,
String value)
Sets the attribute, determined by it names, using the given name space and value. |
void |
setBorders(boolean show)
Adds or removes a border. |
void |
setBounds(int x,
int y,
int width,
int height)
Sets the element's bounds. |
void |
setBounds(int x,
int y,
int width,
int height,
boolean adjust)
Sets the element's bounds. |
void |
setBounds(Rectangle bounds)
Sets the element's bounds. |
void |
setBounds(Rectangle bounds,
boolean content)
Sets the element's bounds. |
void |
setClassName(String cls,
boolean add)
Adds or removes the class name. |
void |
setDisplayed(boolean display)
Sets the CSS display property. |
void |
setHeight(int height)
Sets the elements height. |
void |
setHeight(int height,
boolean adjust)
Sets the elements height. |
void |
setHeight(String height)
Sets the elements height. |
void |
setLeft(int left)
Sets the element's left position directly using CSS style (instead of setX(int)). |
void |
setLeftTop(int left,
int top)
Quick set left and top adding default units. |
void |
setMargins(int margin)
Sets the elements's margin. |
void |
setMargins(Margins margin)
Sets the elements's margin. |
void |
setOpacity(double opacity)
Cross-browser support for setting opacity. |
void |
setPadding(Padding padding)
Sets the elements's padding. |
void |
setSize(int width,
int height)
Sets the element's size. |
void |
setSize(int width,
int height,
boolean adjust)
Set the size of the element. |
void |
setSize(Size size)
Sets the element's size. |
void |
setTop(int top)
Sets the element's top position directly using CSS style (instead of setY(int)). |
void |
setVisibility(boolean visible)
Sets the elements CSS visibility property. |
void |
setVisible(boolean visible)
Sets the visibility of the element using the getVisMode(). |
void |
setVisMode(XElement.VisMode visMode)
Sets the vis mode (defaults to XElement.VisMode.DISPLAY. |
void |
setWidth(int width)
Sets the element's width. |
void |
setWidth(int width,
boolean adjust)
Sets the elements's width. |
void |
setWidth(String width)
Sets the elements width. |
void |
setX(int x)
Sets the X position of the element based on page coordinates. |
void |
setXY(int x,
int y)
Sets the elements position in page coordinates. |
void |
setXY(Point p)
Sets the element's position in page coordinates. |
void |
setY(int y)
Sets the Y position of the element based on page coordinates. |
void |
setZIndex(int zIndex)
Sets the element's z-index. |
void |
show()
Shows this element. |
void |
swapClassName(String oldClassName,
String newClassName)
Replace one class name with another. |
void |
toggleClassName(String className)
Toggles the given class name, adding if not already present, removing if present. |
Point |
translatePoints(Point p)
Translates the passed page coordinates into left/top css values for this element. |
void |
unmask()
Removes a previously applied mask. |
void |
unwrap(XElement child,
Rectangle bounds)
Unwraps the child element. |
void |
updateZIndex(int adj)
Sets the element's z-index using XDOM.getTopZIndex() to ensure it
has the highest values. |
Rectangle |
wrap(Element wrapper)
Wraps the element with the specified wrapper. |
| Methods inherited from class com.google.gwt.dom.client.Node |
|---|
appendChild, cloneNode, getChild, getChildCount, getChildNodes, getFirstChild, getLastChild, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPreviousSibling, hasChildNodes, hasParentElement, insertAfter, insertBefore, insertFirst, isOrHasChild, removeChild, removeFromParent, replaceChild, setNodeValue |
| Methods inherited from class com.google.gwt.core.client.JavaScriptObject |
|---|
cast, createArray, createFunction, createObject, equals, hashCode, toSource, toString |
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public static String addUnits(String v,
String defaultUnit)
v - the value
public static XElement as(Node node)
Node is an Element and automatically
typecast it.
public static final XElement createElement(String tagName)
tagName - the element tag name
public static boolean isBorderBox(Element element)
element - the element to test
public final void addClassName(String... classNames)
classNames - the new class namespublic final void addEventsSunk(int event)
event - the events to addpublic final Point adjustForConstraints(Point p)
p - the target destination
public final void alignTo(Element elem,
Style.AnchorAlignment alignment,
int[] offsets)
elem - the element to align toalignment - the position to align tooffsets - the offsets or nullpublic final void applyStyles(String styles)
styles - a style specification stringpublic final void center()
public final void center(boolean constrainViewport)
constrainViewport - true to constrain the element position to the
viewport.public final void center(Element container)
container - the container elementpublic final XElement child(String selector)
selector - the css selector
public final Element childElement(String selector)
selector - the css selector
public final void clearOpacity()
public final void click()
public final XElement createChild(String html)
html - the html fragment
public final void disable()
public final void disableTextSelection(boolean disable)
Component source for an
example.
disable - true to disable, false to enablepublic final XElement down(String selector)
selector - the CSS selector
public final void enable()
public final List<FastMap<Object>> ensureVisible()
restoreVisible(List)
public final XElement findParent(String selector,
int maxDepth)
selector - the simple selector to test
public final Element findParentElement(String selector,
int maxDepth)
selector - the simple selector to testmaxDepth - the max depth
public final Point getAlignToXY(Element elem,
Style.AnchorAlignment alignment,
int ox,
int oy)
elem - the element to align toalignment - the alignmentox - x offsetoy - y offset
public final Point getAlignToXY(Element elem,
Style.AnchorAlignment alignment,
int[] offsets)
elem - the element to align toalignment - the alignmentoffsets - an array of x and y offsets (may be be null for 0, 0)
public final Point getAnchorXY(Style.Anchor anchor,
boolean local)
anchor - the specified anchor position (defaults to "c"). See
alignTo(com.google.gwt.dom.client.Element, com.sencha.gxt.core.client.Style.AnchorAlignment, int[]) for details on supported anchor positions.local - true to get the local (element top/left-relative)
anchor position instead of page coordinates
public final Rectangle getBounds()
public final Rectangle getBounds(boolean local)
local - if true the element's left and top are returned instead of
page coordinates
public final Rectangle getBounds(boolean local,
boolean adjust)
local - if true the element's left and top are returned instead of
page coordinatesadjust - if true sizes get adjusted
public final int getChildIndex(Element child)
public final int getComputedHeight()
public final FastMap<String> getComputedStyle(List<String> props)
props - the list of CSS property names
public final String getComputedStyle(String prop)
prop - the style attribute whose value is returned.
public final int getComputedWidth()
public final Size getFrameSize()
public final int getFrameWidth(Style.Side... side)
side - the sides
public final int getHeight(boolean content)
content - true to get the height minus borders and padding
public final String getId(boolean autoGenId)
autoGenId - true to set an id if one does not exist
public final int getLeft()
public final int getLeft(boolean local)
local - true to get the local css position instead of page coordinate
public final int getMargins(Style.Side... sides)
sides - the sides from which to calculate the margin. Passing more
than one side will yield the sum of the margins of those sides of
the element.
public final Point getOffsetsTo(Element to)
to - the to element
public final int getPadding(Style.Side... sides)
sides - the sides from which to calculate the padding. Passing more
than one side will yield the sum of the padding of those sides of
the element.
public final Point getPosition(boolean local)
local - true to return the element's left and top rather than page
coordinates
public final Region getRegion()
public final int getRight(boolean local)
local - true to get the local css position instead of
page coordinate
public final Scroll getScroll()
public final Size getSize()
public final Size getSize(boolean content)
content - true to get the size minus borders and padding
public final Size getStyleSize()
public final Size getStyleSize(boolean contentOnly)
contentOnly - true to exclude padding and borders
public final Element getSubChild(int depth)
depth - the child node depth
public final int getTextWidth()
public final int getTop()
public final int getTop(boolean local)
local - true to get the local css position instead of page coordinate
public final XElement.VisMode getVisMode()
public final int getWidth(boolean content)
content - true to get the width minus borders and padding
public final int getX()
public final Point getXY()
public final int getY()
public final int getZIndex()
public final boolean hasClassName(String test)
test - the test class name
public final void hide()
public final int indexOf(Element child)
child - the child
public final void insertBefore(Element element)
element - the element to insert beforepublic final void insertBefore(NodeList<Element> elements)
elements - the elements to insert
public final void insertChild(Element child,
int index)
child - the child elementindex - the insert locationpublic final XElement insertFirst(String html)
html - the HTML fragment
public final XElement insertHtml(String where,
String html)
where - where to insert the html in relation to el - beforeBegin,
afterBegin, beforeEnd, afterEnd.html - the HTML fragment
public final boolean is(String selector)
selector - selector
public final boolean isBorderBox()
public final boolean isConnected()
public final boolean isStyleAttribute(String attr,
String value)
attr - the style namevalue - the test value
public final boolean isStyleProperty(Map<String,String> map,
boolean matchAll)
map - the map of style property names and valuesmatchAll - true to match all properties
public final boolean isVisible()
public final boolean isVisible(boolean deep)
deep - true to deep test
public final Request load(RequestBuilder builder)
This method is subject to change.
builder - the request builderpublic final void makePositionable()
public final void makePositionable(boolean absolute)
absolute - true to position absolutelypublic final void mask(String message)
message - a message to display in the maskpublic final void removeChildren()
public final void removeClassName(String... classNames)
classNames - the style namespublic final void repaint()
public final void replaceClassName(String oldClassName,
String newClassName,
boolean deep)
oldClassName - the class name to be replacednewClassName - the class name to replace itdeep - true to class names on child elementspublic final void restoreVisible(List<FastMap<Object>> list)
ensureVisible().
list - the meta data list
public final void scrollIntoView(Element container,
boolean hscroll)
container - the container elementhscroll - false to disable horizontal scrolling.
public final void scrollIntoView(Element container,
boolean hscroll,
int[] offsets)
container - the container elementhscroll - false to disable horizontal scrolling.offsets - the offsets
public final void scrollTo(Style.ScrollDirection side,
int value)
side - the scroll directionvalue - the new scroll valuepublic final NodeList<Element> select(String selector)
selector - the selector/xpath query
public final XElement selectNode(String selector)
selector - the CSS selector
public final void setAttributeNS(String nameSpace,
String name,
String value)
nameSpace - the name space of the attributename - the attribute namevalue - the value of the attributepublic final void setBorders(boolean show)
show - the show state
public final void setBounds(int x,
int y,
int width,
int height)
x - the x coordinatey - the y coordinatewidth - the new widthheight - the new height
public final void setBounds(int x,
int y,
int width,
int height,
boolean adjust)
x - the x coordinatey - the y coordinatewidth - the new widthheight - the new heightadjust - true to adjust for box model issuespublic final void setBounds(Rectangle bounds)
bounds - the new bounds
public final void setBounds(Rectangle bounds,
boolean content)
bounds - the new boundscontent - true to adjust for box model issues
public final void setClassName(String cls,
boolean add)
cls - the style nameadd - true to add, false to removepublic final void setDisplayed(boolean display)
display - true to display the element using its default displaypublic final void setHeight(int height)
height - the height
public final void setHeight(int height,
boolean adjust)
height - the heightadjust - true to adjust for box model issuespublic final void setHeight(String height)
height - the heightpublic final void setLeft(int left)
setX(int)).
left - the left value in pixels
public final void setLeftTop(int left,
int top)
left - the left valuetop - the top valuepublic final void setMargins(int margin)
margin - the marginpublic final void setMargins(Margins margin)
margin - the marginpublic final void setOpacity(double opacity)
opacity - the opacitypublic final void setPadding(Padding padding)
padding - the padding
public final void setSize(int width,
int height)
width - the new widthheight - the new height
public final void setSize(int width,
int height,
boolean adjust)
width - the new widthheight - the new heightadjust - true to adjust for box model issuespublic final void setSize(Size size)
size - the sizepublic final void setTop(int top)
setY(int)).
top - the top value in pixelspublic final void setVisibility(boolean visible)
visible - true for visiblepublic final void setVisible(boolean visible)
getVisMode().
visible - whether the element is visiblepublic final void setVisMode(XElement.VisMode visMode)
XElement.VisMode.DISPLAY.
visMode - the vis modepublic final void setWidth(int width)
width - the new width
public final void setWidth(int width,
boolean adjust)
width - the new widthadjust - true to adjust for box model issuespublic final void setWidth(String width)
width - the widthpublic final void setX(int x)
x - the x coordinate
public final void setXY(int x,
int y)
x - the x coordinatey - the y coordinatepublic final void setXY(Point p)
p - the positionpublic final void setY(int y)
y - the y coordinatepublic final void setZIndex(int zIndex)
zIndex - the z-index valuepublic final void show()
public final void swapClassName(String oldClassName,
String newClassName)
oldClassName - the class name to be replaced, empty strings allowednewClassName - the class name to replace it, empty strings allowedpublic final void toggleClassName(String className)
className - the class name to togglepublic final Point translatePoints(Point p)
p - the coordinates
public final void unmask()
public final void unwrap(XElement child,
Rectangle bounds)
bounds - the original boundspublic final void updateZIndex(int adj)
XDOM.getTopZIndex() to ensure it
has the highest values.
adj - the adjustment to be applied to the z-index valuepublic final Rectangle wrap(Element wrapper)
wrapper - the wrapper element
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||