Class NatTableCSSHelper
java.lang.Object
org.eclipse.nebula.widgets.nattable.extension.e4.css.NatTableCSSHelper
Helper class for converting and applying CSS styles.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidapplyNatTableStyle(NatTable natTable, ConfigAttribute<IStyle> styleAttribute, ConfigAttribute<T> styleConfig, T value, DisplayMode displayMode, String configLabel) Apply a style attribute value for theIStyleregistered for the given styleAttribute.static <T> voidapplyNatTableStyle(NatTable natTable, ConfigAttribute<T> styleConfig, T value, DisplayMode displayMode, String configLabel) Apply a style attribute value for theIStyleregistered forCellConfigAttributes.CELL_STYLE.static booleangetBoolean(CSSValue value, boolean defaultValue) Return thebooleanvalue that represents the givenCSSValue.static BorderStylegetBorderStyle(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, DisplayMode displayMode) static CellEdgeEnumgetCellEdgeEnum(String value) Returns the NatTableCellEdgeEnumfor the given string representation.static ObjectgetContextValue(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, DisplayMode displayMode, Object key) Search the value for the given key andDisplayModeout of the givenCSSElementContext.static ObjectgetContextValueInherited(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, org.eclipse.e4.ui.css.core.engine.CSSElementContext natTableContext, DisplayMode targetDisplayMode, Object key) Search the value for the given key andDisplayModeout of the givenCSSElementContext.getDecoratorPainter(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, DisplayMode displayMode) Returns the string representation list of cell painter decorators that should be used to build up the cell painter for rendering.static IDisplayConvertergetDisplayConverter(String value, boolean format, Integer minFractionDigits, Integer maxFractionDigits, String datePattern) Returns the NatTableIDisplayConverterfor the given string representation.static StringgetDisplayConverterString(IDisplayConverter converter) static DisplayModegetDisplayMode(String pseudo) Returns the NatTableDisplayModefor the given pseudo class.static org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontPropertiesgetFontProperties(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, String contextKey, NatTable natTable, DisplayMode displayMode, String label) Returns theCSS2FontPropertiesout of the givenCSSElementContextfor the given parameters.static <T> TgetNatTableStyle(NatTable natTable, ConfigAttribute<T> styleConfig, DisplayMode displayMode, String... configLabels) Retrieves the style attribute for the given display mode and config labels out of the NatTable configuration.getPainterProperties(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, DisplayMode displayMode) Returns the painter properties out of the givenCSSElementContextfor the givenDisplayMode.getPainterPropertiesInherited(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, org.eclipse.e4.ui.css.core.engine.CSSElementContext natTableContext, DisplayMode targetDisplayMode) Returns the painter properties out of the givenCSSElementContextfor the givenDisplayModeenriched with the painter property values out of inheritance.static booleanisConverterString(String value) static booleanresolvePainter(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, org.eclipse.e4.ui.css.core.engine.CSSElementContext natTableContext, DisplayMode displayMode) Check if the automatic painter resolution is enabled or disabled via CSS property.Resolves the painter representations out of the givenCSSValue.static voidsetFontProperties(CSSValueList valueList, org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontProperties font) Sets the values from the givenCSSValueListto the givenCSS2FontPropertiesCSS2FontProperties.static voidstoreBorderStyle(CSSValueList valueList, BorderStyle borderStyle, org.eclipse.e4.ui.css.core.engine.CSSEngine engine, org.eclipse.swt.widgets.Display display) Convert and store the values of the givenCSSValueListto the givenBorderStyle.static voidstoreContextValue(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, DisplayMode displayMode, Object key, Object value) Put a value for the given key andDisplayModeto the givenCSSElementContext.static voidstorePadding(String paddingKey, CSSValue value, org.eclipse.e4.ui.css.core.engine.CSSElementContext context, DisplayMode displayMode) Convert and store the padding value for the given key in the painter properties map.
-
Method Details
-
getBoolean
Return thebooleanvalue that represents the givenCSSValue.- Parameters:
value- The value for which the boolean value should be returned.defaultValue- The default value to return if the given value can not be converted to a boolean.- Returns:
- The boolean representation of the given value or the default value if it can not be converted.
-
getDisplayMode
Returns the NatTableDisplayModefor the given pseudo class.- Parameters:
pseudo- The pseudo class.- Returns:
- The
DisplayModevalue for the given pseudo class. - Since:
- 2.0
-
getCellEdgeEnum
Returns the NatTableCellEdgeEnumfor the given string representation.- Parameters:
value- The string representation of theCellEdgeEnum- Returns:
- The
CellEdgeEnumfor the string representation.
-
getDisplayConverter
public static IDisplayConverter getDisplayConverter(String value, boolean format, Integer minFractionDigits, Integer maxFractionDigits, String datePattern) Returns the NatTableIDisplayConverterfor the given string representation.- Parameters:
value- The string representation of theIDisplayConverterformat- flag for number display converters to specify whetherNumberFormatshould be used to format or not.minFractionDigits- number of minimum fraction digits to use in case aNumberFormatis used for formatting a number valuemaxFractionDigits- number of maximum fraction digits to use in case aNumberFormatis used for formatting a number valuedatePattern- The pattern to use for formatting a date value when a date display converter requested- Returns:
- The
IDisplayConverterfor the string representation.
-
getDisplayConverterString
- Parameters:
converter- TheIDisplayConverterfor which the String representation is requested.- Returns:
- The String representation for the given
IDisplayConverter.
-
isConverterString
- Parameters:
value- The value to check.- Returns:
trueif the given value represents a valid converter key,falseif not.
-
getNatTableStyle
public static <T> T getNatTableStyle(NatTable natTable, ConfigAttribute<T> styleConfig, DisplayMode displayMode, String... configLabels) Retrieves the style attribute for the given display mode and config labels out of the NatTable configuration. Uses the NatTable internal inheritance model to always retrieve a style configuration attribute if there is one configured at any level.- Type Parameters:
T- The type of the configuration attribute.- Parameters:
natTable- The NatTable whoseConfigRegistryshould be checked for the style configuration.styleConfig- The styleConfigAttributethat is requested.displayMode- TheDisplayModefor which the configuration is requested.configLabels- The config labels for which the configuration is requested.- Returns:
- The style attribute for the given display mode and config labels out of the NatTable configuration.
- Since:
- 2.0
-
applyNatTableStyle
public static <T> void applyNatTableStyle(NatTable natTable, ConfigAttribute<T> styleConfig, T value, DisplayMode displayMode, String configLabel) Apply a style attribute value for theIStyleregistered forCellConfigAttributes.CELL_STYLE.- Type Parameters:
T- The type of the configuration attribute.- Parameters:
natTable- The NatTable to apply the style configuration to.styleConfig- The styleConfigAttributethat should be applied.value- The value to apply.displayMode- TheDisplayModefor which the configuration should be applied.configLabel- The label for which the configuration should be applied.- Since:
- 2.0
-
applyNatTableStyle
public static <T> void applyNatTableStyle(NatTable natTable, ConfigAttribute<IStyle> styleAttribute, ConfigAttribute<T> styleConfig, T value, DisplayMode displayMode, String configLabel) Apply a style attribute value for theIStyleregistered for the given styleAttribute.- Type Parameters:
T- The type of the configuration attribute.- Parameters:
natTable- The NatTable to apply the style configuration to.styleAttribute- TheConfigAttributethat points to theIStylethat should be configured.styleConfig- The styleConfigAttributethat should be applied.value- The value to apply.displayMode- TheDisplayModefor which the configuration should be applied.configLabel- The label for which the configuration should be applied.- Since:
- 2.0
-
getFontProperties
public static org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontProperties getFontProperties(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, String contextKey, NatTable natTable, DisplayMode displayMode, String label) Returns theCSS2FontPropertiesout of the givenCSSElementContextfor the given parameters. If noCSS2FontPropertiesexist, a new instance will be created and pre-filled with font values based on inheritance.- Parameters:
context- TheCSSElementContextto search for the context value.contextKey- The context key under which the font properties are stored.natTable- The NatTable instance to apply the styles todisplayMode- The targetDisplayModeto check for the value.label- The label for which the font properties are requested.- Returns:
- The
CSS2FontPropertiesfor the given attributes. - Since:
- 2.0
-
setFontProperties
public static void setFontProperties(CSSValueList valueList, org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontProperties font) Sets the values from the givenCSSValueListto the givenCSS2FontPropertiesCSS2FontProperties.- Parameters:
valueList- The value list containing the css property valuesfont- The font properties to set the values to
-
getBorderStyle
public static BorderStyle getBorderStyle(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, DisplayMode displayMode) - Parameters:
context- TheCSSElementContextto search for the context value.displayMode- TheDisplayModefor which the value should be stored.- Returns:
- The
BorderStyle - Since:
- 2.0
-
storeBorderStyle
public static void storeBorderStyle(CSSValueList valueList, BorderStyle borderStyle, org.eclipse.e4.ui.css.core.engine.CSSEngine engine, org.eclipse.swt.widgets.Display display) throws Exception Convert and store the values of the givenCSSValueListto the givenBorderStyle.- Parameters:
valueList- TheCSSValueListwith the values to convert.borderStyle- TheBorderStyleto store the converted values to.engine- TheCSSEngineneeded for conversion.display- The display needed for color conversion.- Throws:
Exception- if the value conversion fails
-
storePadding
public static void storePadding(String paddingKey, CSSValue value, org.eclipse.e4.ui.css.core.engine.CSSElementContext context, DisplayMode displayMode) Convert and store the padding value for the given key in the painter properties map.- Parameters:
paddingKey- The key of the padding property.value- TheCSSValueof the padding that should be converted and stored.context- TheCSSElementContextto search for the configuration value.displayMode- The targetDisplayModeto check for the value.- Since:
- 2.0
-
resolvePainter
public static boolean resolvePainter(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, org.eclipse.e4.ui.css.core.engine.CSSElementContext natTableContext, DisplayMode displayMode) Check if the automatic painter resolution is enabled or disabled via CSS property.- Parameters:
context- TheCSSElementContextto search for the configuration value.natTableContext- TheCSSElementContextof the parent NatTable ornullin case the context parameter is already from the NatTable itself.displayMode- The targetDisplayModeto check for the value.- Returns:
trueif the painter to use should be automatically resolved,falseif the painter is configured elsewhere and therefore no automatic resolution should be performed. Default istrue.- Since:
- 2.0
-
getDecoratorPainter
public static List<String> getDecoratorPainter(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, DisplayMode displayMode) Returns the string representation list of cell painter decorators that should be used to build up the cell painter for rendering.- Parameters:
context- TheCSSElementContextto search for the context value.displayMode- TheDisplayModefor which the value should be stored.- Returns:
- The string representation of decorator painter that should be used for rendering.
- Since:
- 2.0
-
getPainterProperties
public static Map<String,Object> getPainterProperties(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, DisplayMode displayMode) Returns the painter properties out of the givenCSSElementContextfor the givenDisplayMode.- Parameters:
context- TheCSSElementContextto search for the context value.displayMode- TheDisplayModefor which the value should be stored.- Returns:
- The properties that should be used to create content painter.
- Since:
- 2.0
-
getPainterPropertiesInherited
public static Map<String,Object> getPainterPropertiesInherited(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, org.eclipse.e4.ui.css.core.engine.CSSElementContext natTableContext, DisplayMode targetDisplayMode) Returns the painter properties out of the givenCSSElementContextfor the givenDisplayModeenriched with the painter property values out of inheritance.- Parameters:
context- TheCSSElementContextto search for the context value.natTableContext- TheCSSElementContextof the parent NatTable ornullin case the context parameter is already from the NatTable itself.targetDisplayMode- The targetDisplayModeto check for the value.- Returns:
- The painter properties with values out of inheritance
- Since:
- 2.0
-
resolvePainterRepresentation
Resolves the painter representations out of the givenCSSValue.- Parameters:
value- TheCSSValueto resolve.- Returns:
- The list of string representations for painters.
-
storeContextValue
public static void storeContextValue(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, DisplayMode displayMode, Object key, Object value) Put a value for the given key andDisplayModeto the givenCSSElementContext.- Parameters:
context- TheCSSElementContextto put the value to.displayMode- TheDisplayModefor which the value should be stored.key- The key for which the value should be stored.value- The value to store.- Since:
- 2.0
-
getContextValue
public static Object getContextValue(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, DisplayMode displayMode, Object key) Search the value for the given key andDisplayModeout of the givenCSSElementContext.- Parameters:
context- TheCSSElementContextout of which the value should be retrieved.displayMode- TheDisplayModefor which the value is requested.key- The key for which the value is requested.- Returns:
- The value for the given
DisplayModeand key out of the givenCSSElementContext. If no value is found for the givenDisplayMode, the value out of the givenCSSElementContextdirectly is returned. Can benull. - Since:
- 2.0
-
getContextValueInherited
public static Object getContextValueInherited(org.eclipse.e4.ui.css.core.engine.CSSElementContext context, org.eclipse.e4.ui.css.core.engine.CSSElementContext natTableContext, DisplayMode targetDisplayMode, Object key) Search the value for the given key andDisplayModeout of the givenCSSElementContext. Will search for the value also via inheritance, that means first it will check theIDisplayModeOrderingand if there is no value found, it searches in the parent NatTable context.- Parameters:
context- TheCSSElementContextto search for the context value.natTableContext- TheCSSElementContextof the parent NatTable ornullin case the context parameter is already from the NatTable itself.targetDisplayMode- The targetDisplayModeto check for the value.key- The key of the context value to search for.- Returns:
- The context value for the given key.
- Since:
- 2.0
-