public class XElement
extends com.google.gwt.user.client.Element
Element
class.
XElement's cannot be directly instantiated. New XElements can be created using the static
createElement(String)
method.Modifier and Type | Class and Description |
---|---|
static class |
XElement.VisMode
VisMode enumeration.
|
Modifier | Constructor and Description |
---|---|
protected |
XElement()
Not directly instantiable.
|
Modifier and Type | Method and Description |
---|---|
void |
addClassName(String... classNames)
Adds the style names to the element.
|
void |
addClassName(String className1,
String className2)
Adds the style names 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 offsetX,
int offsetY)
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 |
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 and all children.
|
void |
disableTextSelectionSingle(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 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.
|
int |
getBorders(Style.Side... sides)
Returns the total border size of the specified sides.
|
int |
getBorders(Style.Side side)
Returns the total border size of the specified sides.
|
int |
getBorders(Style.Side side1,
Style.Side side2)
Returns the total border size of the specified sides.
|
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.
|
protected Point |
getConstrainToXY(Element elem,
Point proposedXY) |
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 |
getFrameWidth(Style.Side side)
Returns the sum width of the padding and borders for the given side.
|
int |
getFrameWidth(Style.Side side1,
Style.Side side2)
Returns the sum width of the padding and borders for the given side.
|
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.
|
int |
getMargins(Style.Side side)
Returns the total margin size of the specified side.
|
int |
getMargins(Style.Side side1,
Style.Side side2)
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).
|
int |
getPadding(Style.Side side)
Returns the width of the padding(s) for the specified side.
|
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.
|
void |
hide()
Hides this element.
|
int |
indexOf(Element child)
Returns the index of the child.
|
void |
insertBefore(<any> elements)
Inserts the elements before this element.
|
void |
insertBefore(Element element)
Inserts this element before the passed 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 |
isScrollable()
Returns whether the element is scrollable (x or y).
|
boolean |
isScrollableX()
Returns whether the element is scrollable on the x-axis.
|
boolean |
isScrollableY()
Returns whether the element is scrollable on the y-axis.
|
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 |
removeClassName(String className1,
String className2)
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 offsetX,
int offsetY)
Scrolls the element into view.
|
void |
scrollTo(Style.ScrollDirection side,
int value)
Scrolls this element the specified scroll point.
|
<any> |
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.
|
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.
|
protected XElement()
public static String addUnits(String v, String defaultUnit)
v
- the valuepublic static XElement as(Node node)
Node
is an Element
and automatically typecast it.public static final XElement createElement(String tagName)
tagName
- the element tag namepublic static boolean isBorderBox(Element element)
element
- the element to testpublic final void addClassName(String... classNames)
classNames
- the new class names to addpublic final void addClassName(String className1, String className2)
className1
- the first new class name to addclassName2
- the second new class name to addpublic final void addEventsSunk(int event)
event
- the events to addpublic final Point adjustForConstraints(Point p)
p
- the target destinationpublic final void alignTo(Element elem, Style.AnchorAlignment alignment, int offsetX, int offsetY)
elem
- the element to align toalignment
- the position to align tooffsetX
- X offsetoffsetY
- Y offsetpublic 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 selectorpublic final Element childElement(String selector)
selector
- the css selectorpublic final void click()
public final XElement createChild(String html)
html
- the html fragmentpublic final void disable()
public final void disableTextSelection(boolean disable)
Component
source for an
example.disable
- true to disable, false to enablepublic final void disableTextSelectionSingle(boolean disable)
Component
source for an
example.disable
- true to disable, false to enablepublic final XElement down(String selector)
selector
- the CSS selectorpublic final void enable()
public final List<FastMap<Object>> ensureVisible()
restoreVisible(List)
public final XElement findParent(String selector, int maxDepth)
selector
- the simple selector to testpublic final Element findParentElement(String selector, int maxDepth)
selector
- the simple selector to testmaxDepth
- the max depthpublic final Point getAlignToXY(Element elem, Style.AnchorAlignment alignment, int ox, int oy)
elem
- the element to align toalignment
- the alignmentox
- x offsetoy
- y offsetpublic final Point getAnchorXY(Style.Anchor anchor, boolean local)
anchor
- the specified anchor position (defaults to CENTER
). See alignTo(Element, com.sencha.gxt.core.client.Style.AnchorAlignment, int, int)
for details on
supported anchor positions.local
- true
to get the local (element top/left-relative) anchor position instead of page coordinatespublic final int getBorders(Style.Side side)
side
- the sidepublic final int getBorders(Style.Side... sides)
sides
- the sidespublic final int getBorders(Style.Side side1, Style.Side side2)
side1
- the first sideside2
- the second sidepublic final Rectangle getBounds()
public final Rectangle getBounds(boolean local)
local
- if true the element's left and top are returned instead of page coordinatespublic 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 adjustedpublic final int getChildIndex(Element child)
public final int getComputedHeight()
public final FastMap<String> getComputedStyle(List<String> props)
props
- the list of CSS property namespublic 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 sidespublic final int getFrameWidth(Style.Side side)
side
- the sidepublic final int getFrameWidth(Style.Side side1, Style.Side side2)
side1
- the sideside2
- the sidepublic final int getHeight(boolean content)
content
- true to get the height minus borders and paddingpublic final String getId(boolean autoGenId)
autoGenId
- true to set an id if one does not existpublic final int getLeft()
public final int getLeft(boolean local)
local
- true to get the local css position instead of page coordinatepublic final int getMargins(Style.Side side)
side
- the side from which to calculate the margin.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 int getMargins(Style.Side side1, Style.Side side2)
side1
- the first side from which to calculate the margin.side2
- the second side from which to calculate the margin.public final Point getOffsetsTo(Element to)
to
- the to elementpublic final int getPadding(Style.Side side)
side
- the side from which to calculate the padding.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 coordinatespublic final Region getRegion()
public final int getRight(boolean local)
local
- true
to get the local css position instead of page coordinatepublic final Scroll getScroll()
public final Size getSize()
public final Size getSize(boolean content)
content
- true to get the size minus borders and paddingpublic final Size getStyleSize()
public final Size getStyleSize(boolean contentOnly)
contentOnly
- true to exclude padding and borderspublic final Element getSubChild(int depth)
depth
- the child node depthpublic final int getTextWidth()
public final int getTop()
public final int getTop(boolean local)
local
- true to get the local css position instead of page coordinatepublic final XElement.VisMode getVisMode()
public final int getWidth(boolean content)
content
- true to get the width minus borders and paddingpublic final int getX()
public final Point getXY()
public final int getY()
public final int getZIndex()
public final void hide()
public final int indexOf(Element child)
child
- the childpublic final void insertBefore(Element element)
element
- the element to insert beforepublic final void insertBefore(<any> elements)
elements
- the elements to insertpublic final void insertChild(Element child, int index)
child
- the child elementindex
- the insert locationpublic final XElement insertFirst(String html)
html
- the HTML fragmentpublic final XElement insertHtml(String where, String html)
where
- where to insert the html in relation to el - beforeBegin, afterBegin, beforeEnd, afterEnd.html
- the HTML fragmentpublic final boolean is(String selector)
selector
- selectorpublic final boolean isBorderBox()
public final boolean isConnected()
public final boolean isScrollable()
public final boolean isScrollableX()
public final boolean isScrollableY()
public final boolean isStyleAttribute(String attr, String value)
attr
- the style namevalue
- the test valuepublic final boolean isStyleProperty(Map<String,String> map, boolean matchAll)
map
- the map of style property names and valuesmatchAll
- true to match all propertiespublic final boolean isVisible()
public final boolean isVisible(boolean deep)
deep
- true to deep testpublic 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 removeClassName(String className1, String className2)
className1
- the first class name to removeclassName2
- the second class name to removepublic 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 listpublic 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 offsetX, int offsetY)
container
- the container elementhscroll
- false
to disable horizontal scrolling.offsetX
- X offsetoffsetY
- Y offsetpublic final void scrollTo(Style.ScrollDirection side, int value)
side
- the scroll directionvalue
- the new scroll valuepublic final <any> select(String selector)
selector
- the selector/xpath querypublic final XElement selectNode(String selector)
selector
- the CSS selectorpublic 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 statepublic final void setBounds(int x, int y, int width, int height)
x
- the x coordinatey
- the y coordinatewidth
- the new widthheight
- the new heightpublic 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 boundspublic final void setBounds(Rectangle bounds, boolean content)
bounds
- the new boundscontent
- true
to adjust for box model issuespublic 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 heightpublic 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 pixelspublic 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 paddingpublic final void setSize(int width, int height)
width
- the new widthheight
- the new heightpublic 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 widthpublic 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 coordinatepublic 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 Point translatePoints(Point p)
p
- the coordinatespublic 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 elementCopyright © 2018. All rights reserved.