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 Details

    • localName

      protected String localName
    • namespaceURI

      protected String namespaceURI
    • swtStyles

      protected String swtStyles
  • Constructor Details

  • 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