Class MarkupDisplayConverter
java.lang.Object
org.eclipse.nebula.widgets.nattable.data.convert.ContextualDisplayConverter
org.eclipse.nebula.widgets.nattable.extension.nebula.richtext.MarkupDisplayConverter
- All Implemented Interfaces:
IDisplayConverter
IDisplayConverter
that can be used to add HTML markups via String
replacements. Intended to be used in combination with the
RichTextCellPainter
to support dynamic text highlighting.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
Simple value class to store the original value and the markup replacement.protected class
Simple value class to store the original value and the markup replacement. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<String,
MarkupProcessor> Collection of general markups.protected List<MarkupDisplayConverter.MarkupValueForLabels>
Collection of markups that are registered for specific labels.protected IDisplayConverter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncanonicalToDisplayValue
(ILayerCell cell, IConfigRegistry configRegistry, Object canonicalValue) Convert backing data value to value to be displayed.void
Remove all registered markups.displayToCanonicalValue
(ILayerCell cell, IConfigRegistry configRegistry, Object displayValue) Convert from display value to value in the backing data structure.protected List<MarkupProcessor>
Get the list ofMarkupProcessor
that should be applied on the givenILayerCell
.void
registerMarkup
(String value, String markupPrefix, String markupSuffix) Registers a value and the markup that should be placed around the value while rendering.void
registerMarkup
(String id, MarkupProcessor processor) Registers a customMarkupProcessor
for a given id.void
registerMarkupForLabel
(String value, String markupPrefix, String markupSuffix, String... labels) Registers a value and the markup that should be placed around the value while rendering.void
Registers a value and the markup that should be placed around the value while rendering.void
registerMarkupForLabel
(MarkupProcessor processor, String... labels) Registers a customMarkupProcessor
for a given id.void
registerMarkupForLabel
(MarkupProcessor processor, List<String> labels) Registers a customMarkupProcessor
for a given id.void
registerRegexMarkup
(String value, String markupPrefix, String markupSuffix) Registers a regular expression and a markup that should be placed around the value that is specified by the regular expression.void
registerRegexMarkupForLabel
(String value, String markupPrefix, String markupSuffix, String... labels) Registers a regular expression and a markup that should be placed around the value that is specified by the regular expression.void
registerRegexMarkupForLabel
(String value, String markupPrefix, String markupSuffix, List<String> labels) Registers a regular expression and a markup that should be placed around the value that is specified by the regular expression.void
unregisterMarkup
(String value) Unregister the markup that was registered for the given value.void
unregisterMarkupForLabel
(String... labels) Unregister the markup that was registered for the given labels.Methods inherited from class org.eclipse.nebula.widgets.nattable.data.convert.ContextualDisplayConverter
canonicalToDisplayValue, displayToCanonicalValue
-
Field Details
-
wrappedConverter
-
markups
Collection of general markups. -
markupsForLabels
Collection of markups that are registered for specific labels.- Since:
- 2.3
-
-
Constructor Details
-
MarkupDisplayConverter
public MarkupDisplayConverter() -
MarkupDisplayConverter
-
-
Method Details
-
canonicalToDisplayValue
public Object canonicalToDisplayValue(ILayerCell cell, IConfigRegistry configRegistry, Object canonicalValue) Description copied from interface:IDisplayConverter
Convert backing data value to value to be displayed. Typically converts to a String for display. Use this method for contextual conversion.Note that on returning a different type than String,
toString()
will be called on the returned object to render the value for displaying.- Specified by:
canonicalToDisplayValue
in interfaceIDisplayConverter
- Specified by:
canonicalToDisplayValue
in classContextualDisplayConverter
- Parameters:
cell
- TheILayerCell
whose canonical value should be converted.configRegistry
- TheIConfigRegistry
of the NatTable to which theILayerCell
belongs.canonicalValue
- The data value from the backing data.- Returns:
- The converted value to display.
-
displayToCanonicalValue
public Object displayToCanonicalValue(ILayerCell cell, IConfigRegistry configRegistry, Object displayValue) Description copied from interface:IDisplayConverter
Convert from display value to value in the backing data structure.NOTE:
The type the display value is converted to must match the type in the setter of the backing bean/row object Use this method for contextual conversion.- Specified by:
displayToCanonicalValue
in interfaceIDisplayConverter
- Specified by:
displayToCanonicalValue
in classContextualDisplayConverter
- Parameters:
cell
- TheILayerCell
whose canonical value should be converted.configRegistry
- TheIConfigRegistry
of the NatTable to which theILayerCell
belongs.displayValue
- The display value that should be converted to the data value that matches the backing data.- Returns:
- The converted value to put to the backing data.
-
getMarkupProcessors
Get the list ofMarkupProcessor
that should be applied on the givenILayerCell
.- Parameters:
cell
- TheILayerCell
to get theMarkupProcessor
s for.- Returns:
- The list of
MarkupProcessor
that should be applied on the givenILayerCell
. - Since:
- 2.3
-
registerMarkup
Registers a value and the markup that should be placed around the value while rendering.- Parameters:
value
- The value that should be replacement with the markup for rendering.markupPrefix
- The String that will be added as prefix to the value.markupSuffix
- The String that will be added as suffix to the value.
-
registerMarkupForLabel
public void registerMarkupForLabel(String value, String markupPrefix, String markupSuffix, String... labels) Registers a value and the markup that should be placed around the value while rendering.- Parameters:
value
- The value that should be replacement with the markup for rendering.markupPrefix
- The String that will be added as prefix to the value.markupSuffix
- The String that will be added as suffix to the value.labels
- The cell labels for which a markup should be registered.- Since:
- 2.3
-
registerMarkupForLabel
public void registerMarkupForLabel(String value, String markupPrefix, String markupSuffix, List<String> labels) Registers a value and the markup that should be placed around the value while rendering.- Parameters:
value
- The value that should be replacement with the markup for rendering.markupPrefix
- The String that will be added as prefix to the value.markupSuffix
- The String that will be added as suffix to the value.labels
- The cell labels for which a markup should be registered.- Since:
- 2.3
-
registerRegexMarkup
Registers a regular expression and a markup that should be placed around the value that is specified by the regular expression. The regular expression needs to contain at least one group.Example: (IMPORTANT|URGENT) as value will result as either of both words will be surrounded by the markup.
- Parameters:
value
- A regular expression that specifies the value that should be replacement with the markup for rendering. Needs to contain at least one group that will be replaced.markupPrefix
- The String that will be added as prefix to the value.markupSuffix
- The String that will be added as suffix to the value.- Since:
- 1.1
-
registerRegexMarkupForLabel
public void registerRegexMarkupForLabel(String value, String markupPrefix, String markupSuffix, String... labels) Registers a regular expression and a markup that should be placed around the value that is specified by the regular expression. The regular expression needs to contain at least one group.Example: (IMPORTANT|URGENT) as value will result as either of both words will be surrounded by the markup.
- Parameters:
value
- A regular expression that specifies the value that should be replacement with the markup for rendering. Needs to contain at least one group that will be replaced.markupPrefix
- The String that will be added as prefix to the value.markupSuffix
- The String that will be added as suffix to the value.labels
- The cell labels for which a markup should be registered.- Since:
- 2.3
-
registerRegexMarkupForLabel
public void registerRegexMarkupForLabel(String value, String markupPrefix, String markupSuffix, List<String> labels) Registers a regular expression and a markup that should be placed around the value that is specified by the regular expression. The regular expression needs to contain at least one group.Example: (IMPORTANT|URGENT) as value will result as either of both words will be surrounded by the markup.
- Parameters:
value
- A regular expression that specifies the value that should be replacement with the markup for rendering. Needs to contain at least one group that will be replaced.markupPrefix
- The String that will be added as prefix to the value.markupSuffix
- The String that will be added as suffix to the value.labels
- The cell labels for which a markup should be registered.- Since:
- 2.3
-
registerMarkup
Registers a customMarkupProcessor
for a given id.- Parameters:
id
- The id under which theMarkupProcessor
should be registered.processor
- The customMarkupProcessor
that should be registered.- Since:
- 1.1
-
unregisterMarkup
Unregister the markup that was registered for the given value.- Parameters:
value
- The value for which a markup was registered. In case of a value or regex markup this is the value for which the markup was registered. In case of a customMarkupProcessor
it needs to be the id for which it was registered.
-
registerMarkupForLabel
Registers a customMarkupProcessor
for a given id.- Parameters:
processor
- The customMarkupProcessor
that should be registered.labels
- The cell labels for which a markup should be registered.- Since:
- 2.3
-
registerMarkupForLabel
Registers a customMarkupProcessor
for a given id.- Parameters:
processor
- The customMarkupProcessor
that should be registered.labels
- The cell labels for which a markup should be registered.- Since:
- 2.3
-
unregisterMarkupForLabel
Unregister the markup that was registered for the given labels.- Parameters:
labels
- The cell labels for which a markup was registered.- Since:
- 2.3
-
clearMarkups
public void clearMarkups()Remove all registered markups.
-