[英]Highlight text in nattable cell
I have a nettable with different columns and rows filled with data.我有一个带有不同列和行的网络表,其中填充了数据。 I want to highlight specific text in cells when some text is searched in a text field.
当在文本字段中搜索某些文本时,我想突出显示单元格中的特定文本。
After lookin into https://www.eclipse.org/nattable/nandn/nandn_150.php I tried the following but nothing is highlighted when I press the apply button查看https://www.eclipse.org/nattable/nandn/nandn_150.php后,我尝试了以下操作,但是当我按下应用按钮时没有突出显示
this.applyButton = new Button(parent, SWT.PUSH);
this.applyButton.addSelectionListener(getSelectionListener());
private SelectionListener getSelectionListener(){
return new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String text = textBox.getText();
if(!text.trim().isEmpty()) {
applyHighlighting(text);
}
}
};
}
public void applyHighlighting(String text) {
RegexMarkupValue regexMarkup = new RegexMarkupValue("", "<span style=\"background-color:rgb(255, 255, 0)\">",
"</span>");
natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {
{
this.cellPainter = new BackgroundPainter(new PaddingDecorator(new RichTextCellPainter(), 2));
}
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
super.configureRegistry(configRegistry);
// markup for highlighting
MarkupDisplayConverter markupConverter = new MarkupDisplayConverter();
markupConverter.registerMarkup("highlight", regexMarkup);
// register markup display converter for normal display mode in the body
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, markupConverter,
DisplayMode.NORMAL, GridRegion.BODY);
}
});
regexMarkup.setRegexValue(text.isEmpty() ? "" : "(" + text + ")");
}
so with this I assumed when I type something in the text field and click on apply button text in the cells provided in the text field should be highlighted but nothing is changed.因此,我假设当我在文本字段中输入内容并单击文本字段中提供的单元格中的应用按钮文本时,应该突出显示,但没有任何更改。 Any help?
有什么帮助吗?
Thanks谢谢
If you only want to highlight parts of a text inside a cell, you need the Nebula Extension.如果您只想突出显示单元格内的部分文本,则需要 Nebula Extension。 It is described in the New & Noteworthy of 1.5
在 1.5 的 New & Noteworthy 中有描述
https://www.eclipse.org/nattable/nandn/nandn_150.php https://www.eclipse.org/nattable/nandn/nandn_150.php
There is also a pointer to the corresponding example.还有一个指向相应示例的指针。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.