Package org.eclipse.e4.ui.css.swt.dom

# Class WidgetElement

java.lang.Object
org.eclipse.e4.ui.css.core.dom.ElementAdapter
org.eclipse.e4.ui.css.swt.dom.WidgetElement

All Implemented Interfaces:
  `CSSStylableElement`, `Element`, `Node`, `NodeList`

Direct Known Subclasses:
  `ControlElement`, `ItemElement`, `SWTHTMLElement`

public class WidgetElement extends ElementAdapter implements NodeList
`CSSStylableElement` implementation which wrap SWT `Widget`.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected String`
`localName`
`protected String`
`namespaceURI`
`protected String`
`swtStyles`

### Fields inherited from class org.eclipse.e4.ui.css.core.dom.ElementAdapter

`engine`

### Fields inherited from interface org.w3c.dom.Node

`ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE`

## Constructor Summary

Constructors
Constructor
Description
`WidgetElement(Widget widget, CSSEngine engine)`

## Method Summary

Modifier and Type
Method
Description
`static void`
`applyStyles(Widget widget, boolean applyStylesToChildNodes)`
Convenience method for requesting the CSS engine to re-apply styles to a widget.
`protected String`
`computeAttributeSWTStyle()`
Compute attribute SWT style.
`protected String`
`computeLocalName()`
Compute local name.
`protected String`
`computeNamespaceURI()`
Compute namespaceURI.
`protected void`
`computeStaticPseudoInstances()`
Compute static pseudo instances.
`final String`
`getAttribute(String attr)`
`NodeList`
`getChildNodes()`
`String`
`getCSSClass()`
Return the class of the native widget.
`static String`
`getCSSClass(Widget widget)`
Convenience method for getting the CSS class of a widget.
`String`
`getCSSId()`
Return the id of the native widget.
`String`
`getCSSStyle()`
Return the inline style of the native widget.
`static CSSEngine`
`getEngine(Display display)`
Convenience method for getting the CSS engine responsible for a widget.
`static CSSEngine`
`getEngine(Widget widget)`
Convenience method for getting the CSS engine responsible for a widget.
`static String`
`getID(Widget widget)`
Convenience method for getting the CSS ID of a widget.
`int`
`getLength()`
`String`
`getLocalName()`
`String`
`getNamespaceURI()`
`Node`
`getParentNode()`
`protected Widget`
`getWidget()`
`final boolean`
`hasAttribute(String attr)`
`protected Supplier<String>`
`internalGetAttribute(String attr)`
The goal for `internalGetAttribute(String)` is to share the code of `hasAttribute(String)` and `getAttribute(String)` and to keep the performance footprint for `hasAttribute(String)` small.
`Node`
`item(int index)`
`void`
`reset()`
Called by the CSS engine upon a CSS theme switch.
`static void`
`setCSSClass(Widget widget, String className)`
Convenience method for setting the CSS class of a widget.
`static void`
`setEngine(Display display, CSSEngine engine)`
Convenience method for setting the CSS engine responsible for a display.
`static void`
`setID(Widget widget, String id)`
Convenience method for setting the CSS ID of a widget.
`String`
`toString()`

### Methods inherited from class org.eclipse.e4.ui.css.core.dom.ElementAdapter

`addStaticPseudoInstance, appendChild, cloneNode, compareDocumentPosition, copyDefaultStyleDeclarations, dispose, doApplyStyles, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getBaseURI, getDefaultStyleDeclaration, getElement, getElementsByTagName, getElementsByTagNameNS, getFeature, getFirstChild, getLastChild, getNativeWidget, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getPrefix, getPreviousSibling, getSchemaTypeInfo, getStaticPseudoInstances, getStyle, getTagName, getTextContent, getUserData, hasAttributeNS, hasAttributes, hasChildNodes, initialize, insertBefore, isDefaultNamespace, isEqualNode, isPseudoInstanceOf, isSameNode, isStaticPseudoInstance, isSupported, lookupNamespaceURI, lookupPrefix, normalize, onStylesApplied, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setDefaultStyleDeclaration, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setNodeValue, setPrefix, setTextContent, setUserData`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### localName

protected String localName

### namespaceURI

protected String namespaceURI

### swtStyles

protected String swtStyles

## Constructor Details

### WidgetElement

public WidgetElement(Widget widget, CSSEngine engine)

## Method Details

### getCSSClass

public static String getCSSClass(Widget widget)
Convenience method for getting the CSS class of a widget.

Parameters:
  `widget` - SWT widget with associated CSS class name
Returns:
  CSS class name

### getID

public static String getID(Widget widget)
Convenience method for getting the CSS ID of a widget.

Parameters:
  `widget` - SWT widget with associated CSS id
Returns:
  CSS ID

### setCSSClass

public static void setCSSClass(Widget widget, String className)
Convenience method for setting the CSS class of a widget.

Parameters:
  `widget` - SWT widget with associated CSS class name
  `className` - class name to set

### setID

public static void setID(Widget widget, String id)
Convenience method for setting the CSS ID of a widget.

Parameters:
  `widget` - SWT widget with associated CSS id
  `id` - CSS id to set

### getEngine

public static CSSEngine getEngine(Widget widget)
Convenience method for getting the CSS engine responsible for a widget.

Parameters:
  `widget` - SWT widget which is styled by an engine

### getEngine

public static CSSEngine getEngine(Display display)
Convenience method for getting the CSS engine responsible for a widget.

Parameters:
  `display` - SWT display which is styled by an engine

### applyStyles

public static void applyStyles(Widget widget, boolean applyStylesToChildNodes)
Convenience method for requesting the CSS engine to re-apply styles to a widget.

Parameters:
  `widget` - widget to be restyled
  `applyStylesToChildNodes` - if true, apply styles to the child nodes

### setEngine

public static void setEngine(Display display, CSSEngine engine)
Convenience method for setting the CSS engine responsible for a display.

Parameters:
  `display` - SWT display which is styled by an engine
  `engine` - Engine to be associated with the display

### computeLocalName

protected String computeLocalName()
Compute local name.

### computeNamespaceURI

protected String computeNamespaceURI()
Compute namespaceURI.

### computeStaticPseudoInstances

protected void computeStaticPseudoInstances()
Compute static pseudo instances.

### computeAttributeSWTStyle

protected String computeAttributeSWTStyle()
Compute attribute SWT style.

### getAttribute

public final String getAttribute(String attr)

Specified by:
  `getAttribute` in interface `Element`
Specified by:
  `getAttribute` in class `ElementAdapter`

### hasAttribute

public final boolean hasAttribute(String attr)

Specified by:
  `hasAttribute` in interface `Element`
Overrides:
  `hasAttribute` in class `ElementAdapter`

### internalGetAttribute

protected Supplier<String> internalGetAttribute(String attr)
The goal for `internalGetAttribute(String)` is to share the code of `hasAttribute(String)` and `getAttribute(String)` and to keep the performance footprint for `hasAttribute(String)` small. This shall be accomplished by:

- The method shall only be a lookup for a supplier, no actual computation shall be made.
- The result of the supplier must hold the requirements of the result of `getAttribute(String)`. Especially it must not return `null`.
- If the attribute isn't set on the widget, the method must return `null`.

Parameters:
  `attr` - the name of the attribute to look for.
Returns:
  a supplier which will return the actual attribute value or `null` if the attribute isn't set for the widget.

### getLocalName

public String getLocalName()

Specified by:
  `getLocalName` in interface `Node`
Specified by:
  `getLocalName` in class `ElementAdapter`

### getNamespaceURI

public String getNamespaceURI()

Specified by:
  `getNamespaceURI` in interface `Node`

### getParentNode

public Node getParentNode()

Specified by:
  `getParentNode` in interface `Node`

### getChildNodes

public NodeList getChildNodes()

Specified by:
  `getChildNodes` in interface `Node`

### getLength

public int getLength()

Specified by:
  `getLength` in interface `NodeList`

### item

public Node item(int index)

Specified by:
  `item` in interface `NodeList`

### getWidget

protected Widget getWidget()

### getCSSId

public String getCSSId()
Description copied from interface: `CSSStylableElement`
Return the id of the native widget. This method is used to manage CSS style like this input#MyId{....}.

Specified by:
  `getCSSId` in interface `CSSStylableElement`

### getCSSClass

public String getCSSClass()
Description copied from interface: `CSSStylableElement`
Return the class of the native widget. This method is used to manage CSS style like this .blueClass {...}.

Specified by:
  `getCSSClass` in interface `CSSStylableElement`

### getCSSStyle

public String getCSSStyle()
Description copied from interface: `CSSStylableElement`
Return the inline style of the native widget.

Specified by:
  `getCSSStyle` in interface `CSSStylableElement`

### reset

public void reset()
Called by the CSS engine upon a CSS theme switch. Implementations should restore the default value so that the new theme can be applied to the application without restart

### toString

public String toString()

Overrides:
  `toString` in class `Object`