Class AbstractCSSEngine
java.lang.Object
org.eclipse.e4.ui.css.core.impl.engine.AbstractCSSEngine
- All Implemented Interfaces:
CSSEngine
- Direct Known Subclasses:
CSSEngineImpl
Abstract CSS Engine manage style sheet parsing and store the
CSSStyleSheet
into DocumentCSS
.
To apply styles, call the applyStyles(Object, boolean, boolean)
method. This method check if ICSSPropertyHandler
is registered for
apply the CSS property.- Version:
- 1.0.0
- Author:
- Angelo ZERR
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected List<ICSSPropertyHandlerProvider>
An ordered list of ICSSPropertyHandlerProvider -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapplyCSSProperty
(Object element, String property, CSSValue value, String pseudo) Delegates the handle method.void
applyDefaultStyleDeclaration
(Object element, boolean applyStylesToChildNodes) Apply initial style of the object node.void
applyDefaultStyleDeclaration
(Object element, boolean applyStylesToChildNodes, CSSStyleDeclaration newStyle, String pseudoE) void
applyInlineStyle
(Object node, boolean applyStylesToChildNodes) Apply inline style of the object node.void
applyStyleDeclaration
(Object element, CSSStyleDeclaration style, String pseudo) Apply style declaration to the object node.void
applyStyles
(Object element, boolean applyStylesToChildNodes) Apply styles to the Object node (SWT Text,...).void
applyStyles
(Object element, boolean applyStylesToChildNodes, boolean computeDefaultStyle) Apply styles to the Object node (SWT Text,...).Convert Object type oftoType
into CSSValue String.Convert CSSValue into Object type oftoType
.void
dispose()
Call reset and dispose all resourcesString[]
getCSSCompositePropertiesNames
(String property) Return array of CSS property name of the CSSproperty
.getCSSElementContext
(Object element) Get theCSSElementContext
context of the objectnode
.getCSSProperties
(Object element) Return the set of property names and handlers for the provided node.protected Collection<ICSSPropertyHandler>
getCSSPropertyHandlers
(String property) getCSSValueConverter
(Object toType) Get CSSValue converterICSSValueConverter
which is enable to converttoType
Object.getDefaultStyleDeclaration
(Object element, String pseudoE) getDefaultStyleDeclaration
(Object widget, CSSStyleDeclaration newStyle, String pseudoE) Return theDocumentCSS
used to storeCSSStyleSheet
.getElement
(Object element) Return the w3c Element linked to the Object element.GetIElementProvider
registered used to retrieve w3cElement
which wrap native widget.protected Map<Object,
CSSElementContext> ReturnCSSErrorHandler
used to handles exception error.getNativeWidget
(Object element) Get theIResourcesLocatorManager
to use manage resources.Get theIResourcesRegistry
registered used to cache/dispose resources.protected String[]
getStaticPseudoInstances
(Element element) Return theViewCSS
used to computeCSSStyleDeclaration
.void
Handle exceptions thrown while parsing, applying styles.void
handleWidgetDisposed
(Object widget) Called when a widget is disposed.protected void
hookNativeWidget
(Object widget) Called when an element context is created for a native widget and registered with this engine.protected boolean
Allow the CSS engine to skip particular elements if they are not visible.abstract CSSParser
Return instance of CSS Parser.boolean
Check if theselector
matches the objectnode
.protected void
onStylesAppliedToChildNodes
(Element element, NodeList nodes) Callback method called when styles applied ofnodes
children of theelement
.parseAndApplyStyleDeclaration
(Object node, InputStream stream) Parse and apply style declaration from InputStream stream.parseAndApplyStyleDeclaration
(Object node, Reader reader) Parse and apply style declaration from Reader reader.parseAndApplyStyleDeclaration
(Object node, String style) Parse and apply style declaration from String style.parseAndApplyStyleDeclaration
(Object node, org.w3c.css.sac.InputSource source) Parse and apply style declaration from InputSource source.parsePropertyValue
(InputStream stream) Parse CSSValue from InputStream stream.parsePropertyValue
(Reader reader) Parse CSSValue from Reader reader.parsePropertyValue
(String value) Parse CSSValue from String value.parsePropertyValue
(org.w3c.css.sac.InputSource source) Parse CSSValue from InputSource source.org.w3c.css.sac.SelectorList
parseSelectors
(InputStream stream) Parse Selectors from InputStream.org.w3c.css.sac.SelectorList
parseSelectors
(Reader reader) Parse Selectors from String value.org.w3c.css.sac.SelectorList
parseSelectors
(String selector) Parse Selectors from String value.org.w3c.css.sac.SelectorList
parseSelectors
(org.w3c.css.sac.InputSource source) Parse Selectors from InputSource value.parseStyleDeclaration
(InputStream stream) Parse style declaration from InputStream stream.parseStyleDeclaration
(Reader reader) Parse style declaration from Reader reader.parseStyleDeclaration
(String style) Parse style declaration from String style.parseStyleDeclaration
(org.w3c.css.sac.InputSource source) Parse style declaration from InputSource source.parseStyleSheet
(InputStream stream) Parse style sheet from InputStream stream.parseStyleSheet
(Reader reader) Parse style sheet from Reader reader.parseStyleSheet
(org.w3c.css.sac.InputSource source) Parse style sheet from InputSource source.void
registerCSSPropertyHandlerProvider
(ICSSPropertyHandlerProvider handlerProvider) void
registerCSSValueConverter
(ICSSValueConverter converter) Register CSSValue converterICSSValueConverter
.void
reset()
Reset all style sheet registered into CSS Engine.retrieveCSSProperty
(Object element, String property, String pseudo) void
setElementProvider
(IElementProvider elementProvider) SetIElementProvider
registered used to retrieve w3cElement
which wrap native widget.void
setErrorHandler
(CSSErrorHandler errorHandler) Set the CSS Error Handler to manage exception.protected void
void
setResourcesLocatorManager
(IResourcesLocatorManager resourcesLocatorManager) Set theIResourcesLocatorManager
to use manage resources.void
setResourcesRegistry
(IResourcesRegistry resourcesRegistry) RegisterIResourcesRegistry
used to cache/dispose resources.void
unregisterCSSPropertyHandlerProvider
(ICSSPropertyHandlerProvider handlerProvider) void
unregisterCSSValueConverter
(ICSSValueConverter converter) Unregister CSSValue converterICSSValueConverter
.
-
Field Details
-
computeDefaultStyle
protected boolean computeDefaultStyle -
propertyHandlerProviders
An ordered list of ICSSPropertyHandlerProvider
-
-
Constructor Details
-
AbstractCSSEngine
public AbstractCSSEngine() -
AbstractCSSEngine
-
-
Method Details
-
parseStyleSheet
Description copied from interface:CSSEngine
Parse style sheet from Reader reader.- Specified by:
parseStyleSheet
in interfaceCSSEngine
- Throws:
IOException
-
parseStyleSheet
Description copied from interface:CSSEngine
Parse style sheet from InputStream stream.- Specified by:
parseStyleSheet
in interfaceCSSEngine
- Throws:
IOException
-
parseStyleSheet
Description copied from interface:CSSEngine
Parse style sheet from InputSource source.- Specified by:
parseStyleSheet
in interfaceCSSEngine
- Throws:
IOException
-
parseStyleDeclaration
Description copied from interface:CSSEngine
Parse style declaration from String style.- Specified by:
parseStyleDeclaration
in interfaceCSSEngine
- Throws:
IOException
-
parseStyleDeclaration
Description copied from interface:CSSEngine
Parse style declaration from Reader reader.- Specified by:
parseStyleDeclaration
in interfaceCSSEngine
- Throws:
IOException
-
parseStyleDeclaration
Description copied from interface:CSSEngine
Parse style declaration from InputStream stream.- Specified by:
parseStyleDeclaration
in interfaceCSSEngine
- Throws:
IOException
-
parseStyleDeclaration
public CSSStyleDeclaration parseStyleDeclaration(org.w3c.css.sac.InputSource source) throws IOException Description copied from interface:CSSEngine
Parse style declaration from InputSource source.- Specified by:
parseStyleDeclaration
in interfaceCSSEngine
- Throws:
IOException
-
parseSelectors
Description copied from interface:CSSEngine
Parse Selectors from String value.- Specified by:
parseSelectors
in interfaceCSSEngine
- Throws:
IOException
-
parseSelectors
Description copied from interface:CSSEngine
Parse Selectors from String value.- Specified by:
parseSelectors
in interfaceCSSEngine
- Throws:
IOException
-
parseSelectors
Description copied from interface:CSSEngine
Parse Selectors from InputStream.- Specified by:
parseSelectors
in interfaceCSSEngine
- Throws:
IOException
-
parseSelectors
public org.w3c.css.sac.SelectorList parseSelectors(org.w3c.css.sac.InputSource source) throws IOException Description copied from interface:CSSEngine
Parse Selectors from InputSource value.- Specified by:
parseSelectors
in interfaceCSSEngine
- Throws:
IOException
-
parsePropertyValue
Description copied from interface:CSSEngine
Parse CSSValue from Reader reader.- Specified by:
parsePropertyValue
in interfaceCSSEngine
- Throws:
IOException
-
parsePropertyValue
Description copied from interface:CSSEngine
Parse CSSValue from InputStream stream.- Specified by:
parsePropertyValue
in interfaceCSSEngine
- Throws:
IOException
-
parsePropertyValue
Description copied from interface:CSSEngine
Parse CSSValue from String value.- Specified by:
parsePropertyValue
in interfaceCSSEngine
- Throws:
IOException
-
parsePropertyValue
Description copied from interface:CSSEngine
Parse CSSValue from InputSource source.- Specified by:
parsePropertyValue
in interfaceCSSEngine
- Throws:
IOException
-
applyStyles
Description copied from interface:CSSEngine
Apply styles to the Object node (SWT Text,...). IfapplyStylesToChildNodes
is true, apply styles to the child nodes (ex : if node is SWT Composite, styles are applied to the child controls too).- Specified by:
applyStyles
in interfaceCSSEngine
-
applyStyles
public void applyStyles(Object element, boolean applyStylesToChildNodes, boolean computeDefaultStyle) Description copied from interface:CSSEngine
Apply styles to the Object node (SWT Text,...). IfapplyStylesToChildNodes
is true, apply styles to the child nodes (ex : if node is SWT Composite, styles are applied to the child controls too). IfcomputeDefaultStyle
is true, default style is computed before apply styles.- Specified by:
applyStyles
in interfaceCSSEngine
-
isVisible
Allow the CSS engine to skip particular elements if they are not visible. Elements need to be restyled when they become visible.- Returns:
- true if the element is visible, false if not visible.
-
getStaticPseudoInstances
-
onStylesAppliedToChildNodes
Callback method called when styles applied ofnodes
children of theelement
. -
applyStyleDeclaration
Description copied from interface:CSSEngine
Apply style declaration to the object node.- Specified by:
applyStyleDeclaration
in interfaceCSSEngine
-
parseAndApplyStyleDeclaration
public CSSStyleDeclaration parseAndApplyStyleDeclaration(Object node, Reader reader) throws IOException Description copied from interface:CSSEngine
Parse and apply style declaration from Reader reader.- Specified by:
parseAndApplyStyleDeclaration
in interfaceCSSEngine
- Throws:
IOException
-
parseAndApplyStyleDeclaration
public CSSStyleDeclaration parseAndApplyStyleDeclaration(Object node, InputStream stream) throws IOException Description copied from interface:CSSEngine
Parse and apply style declaration from InputStream stream.- Specified by:
parseAndApplyStyleDeclaration
in interfaceCSSEngine
- Throws:
IOException
-
parseAndApplyStyleDeclaration
public CSSStyleDeclaration parseAndApplyStyleDeclaration(Object node, org.w3c.css.sac.InputSource source) throws IOException Description copied from interface:CSSEngine
Parse and apply style declaration from InputSource source.- Specified by:
parseAndApplyStyleDeclaration
in interfaceCSSEngine
- Throws:
IOException
-
parseAndApplyStyleDeclaration
public CSSStyleDeclaration parseAndApplyStyleDeclaration(Object node, String style) throws IOException Description copied from interface:CSSEngine
Parse and apply style declaration from String style.- Specified by:
parseAndApplyStyleDeclaration
in interfaceCSSEngine
- Throws:
IOException
-
applyInlineStyle
Description copied from interface:CSSEngine
Apply inline style of the object node. IfapplyStylesToChildNodes
is true, apply style inline to the child nodes (ex : if node is SWT Composite, styles are applied to the child controls too).- Specified by:
applyInlineStyle
in interfaceCSSEngine
-
getDefaultStyleDeclaration
Description copied from interface:CSSEngine
- Specified by:
getDefaultStyleDeclaration
in interfaceCSSEngine
-
getDefaultStyleDeclaration
public CSSStyleDeclaration getDefaultStyleDeclaration(Object widget, CSSStyleDeclaration newStyle, String pseudoE) -
applyDefaultStyleDeclaration
Description copied from interface:CSSEngine
Apply initial style of the object node. IfapplyStylesToChildNodes
is true, apply style inline to the child nodes (ex : if node is SWT Composite, styles are applied to the child controls too).- Specified by:
applyDefaultStyleDeclaration
in interfaceCSSEngine
-
applyDefaultStyleDeclaration
public void applyDefaultStyleDeclaration(Object element, boolean applyStylesToChildNodes, CSSStyleDeclaration newStyle, String pseudoE) -
applyCSSProperty
public ICSSPropertyHandler applyCSSProperty(Object element, String property, CSSValue value, String pseudo) throws Exception Delegates the handle method.- Specified by:
applyCSSProperty
in interfaceCSSEngine
- Parameters:
element
- may be a widget or a node or some object- Throws:
Exception
-
retrieveCSSProperty
Description copied from interface:CSSEngine
- Specified by:
retrieveCSSProperty
in interfaceCSSEngine
-
getCSSCompositePropertiesNames
Description copied from interface:CSSEngine
Return array of CSS property name of the CSSproperty
.- Specified by:
getCSSCompositePropertiesNames
in interfaceCSSEngine
-
getCSSPropertyHandlers
- Throws:
Exception
-
getCSSProperties
Return the set of property names and handlers for the provided node.- Specified by:
getCSSProperties
in interfaceCSSEngine
- Parameters:
element
- the DOM node or an element- Returns:
- the property names and handlers
-
getElementProvider
Description copied from interface:CSSEngine
GetIElementProvider
registered used to retrieve w3cElement
which wrap native widget.- Specified by:
getElementProvider
in interfaceCSSEngine
-
setElementProvider
Description copied from interface:CSSEngine
SetIElementProvider
registered used to retrieve w3cElement
which wrap native widget.- Specified by:
setElementProvider
in interfaceCSSEngine
-
getElement
Return the w3c Element linked to the Object element.- Specified by:
getElement
in interfaceCSSEngine
-
hookNativeWidget
Called when an element context is created for a native widget and registered with this engine. Subclasses should override and install a listener on the widget that will callhandleWidgetDisposed(Object)
when the widget is disposed.The default implementation of this method does nothing.
- Parameters:
widget
- the native widget to hook
-
handleWidgetDisposed
Called when a widget is disposed. Removes the element context from the element contexts map and the widgets map. Overriding classes must call the super implementation.- Specified by:
handleWidgetDisposed
in interfaceCSSEngine
- Parameters:
widget
- The widget that gets disposed.
-
getCSSElementContext
Description copied from interface:CSSEngine
Get theCSSElementContext
context of the objectnode
.- Specified by:
getCSSElementContext
in interfaceCSSEngine
-
getNativeWidget
-
getElementsContext
-
matches
Description copied from interface:CSSEngine
Check if theselector
matches the objectnode
. -
handleExceptions
Handle exceptions thrown while parsing, applying styles. By default this method call CSS Error Handler if it is initialized.- Specified by:
handleExceptions
in interfaceCSSEngine
-
getErrorHandler
Description copied from interface:CSSEngine
ReturnCSSErrorHandler
used to handles exception error.- Specified by:
getErrorHandler
in interfaceCSSEngine
-
setErrorHandler
Set the CSS Error Handler to manage exception.- Specified by:
setErrorHandler
in interfaceCSSEngine
-
getResourcesLocatorManager
Description copied from interface:CSSEngine
Get theIResourcesLocatorManager
to use manage resources.- Specified by:
getResourcesLocatorManager
in interfaceCSSEngine
-
setResourcesLocatorManager
Description copied from interface:CSSEngine
Set theIResourcesLocatorManager
to use manage resources.- Specified by:
setResourcesLocatorManager
in interfaceCSSEngine
-
getDocumentCSS
Description copied from interface:CSSEngine
Return theDocumentCSS
used to storeCSSStyleSheet
.- Specified by:
getDocumentCSS
in interfaceCSSEngine
-
getViewCSS
Description copied from interface:CSSEngine
Return theViewCSS
used to computeCSSStyleDeclaration
.- Specified by:
getViewCSS
in interfaceCSSEngine
-
dispose
public void dispose()Description copied from interface:CSSEngine
Call reset and dispose all resources -
reset
public void reset()Description copied from interface:CSSEngine
Reset all style sheet registered into CSS Engine. This method must be called if you want parse and apply new StyleSheet and remove the old StyleSheet parsed. -
getResourcesRegistry
Description copied from interface:CSSEngine
Get theIResourcesRegistry
registered used to cache/dispose resources.- Specified by:
getResourcesRegistry
in interfaceCSSEngine
-
setResourcesRegistry
Description copied from interface:CSSEngine
RegisterIResourcesRegistry
used to cache/dispose resources.- Specified by:
setResourcesRegistry
in interfaceCSSEngine
-
registerCSSPropertyHandlerProvider
-
unregisterCSSPropertyHandlerProvider
-
registerCSSValueConverter
Description copied from interface:CSSEngine
Register CSSValue converterICSSValueConverter
.- Specified by:
registerCSSValueConverter
in interfaceCSSEngine
-
unregisterCSSValueConverter
Description copied from interface:CSSEngine
Unregister CSSValue converterICSSValueConverter
.- Specified by:
unregisterCSSValueConverter
in interfaceCSSEngine
-
getCSSValueConverter
Description copied from interface:CSSEngine
Get CSSValue converterICSSValueConverter
which is enable to converttoType
Object.- Specified by:
getCSSValueConverter
in interfaceCSSEngine
-
convert
Description copied from interface:CSSEngine
Convert CSSValue into Object type oftoType
. (ex : convert CSSValue color:red into java.awt.Color). IfIResourcesRegistry
is registered intoCSSEngine
this method search before into cache ofIResourcesRegistry
if the Object was already converted. -
convert
Description copied from interface:CSSEngine
Convert Object type oftoType
into CSSValue String. -
makeCSSParser
Return instance of CSS Parser. -
setResourceRegistryKeyFactory
-