简体   繁体   English

更改NatTable单元格选择颜色

[英]Changing the NatTable cell selection color

When I click on a row, the entire row color changes as expected. 当我单击一行时,整个行的颜色将按预期变化。 However the cell that the mouse is over changes to a different color than the rest of the row. 但是,鼠标所在的单元格将更改为与该行其余部分不同的颜色。 I am trying to prevent the cell from changing to a color that is different from the rest of the row. 我试图防止单元格更改为不同于该行其余部分的颜色。

I am trying to figure out where the cell selection color is getting set and how to remove that (let the cell selection use the cells current background color). 我试图弄清楚要在哪里设置单元格选择颜色以及如何删除它(让单元格选择使用当前背景色的单元格)。

I have unsuccessfully tried things like modifying the CellConfigAttribute or unregistering it via: 我尝试通过修改CellConfigAttribute或通过以下方式取消注册等操作均未成功:

getNatTable().getConfigRegistry().
  unregisterConfigAttribute(CellConfigAttributes.CELL_STYLE); 

but no luck. 但没有运气。 I have no clue how to iterate over all the styles in order and see where this is generated from. 我不知道如何依次遍历所有样式并查看其来源。 I would have liked to see an existing method similar to: 我希望看到一个类似于以下内容的现有方法:

List<ConfigAttribute<IStyle>> list = getNatTable().getConfigRegistry().
  getConfigAttributesInOrder();

Unfortunately all I see is something like this, which I don't find useful for my situation: 不幸的是,我看到的只是这样的东西,对于我的情况我认为没有用:

List<String> strings = getNatTable().getConfigRegistry().
  getDisplayModeOrdering().getDisplayModeOrdering("SELECT");

I have read the documentation which has some general advice but seen no explicit code samples showing how to do this. 我已经阅读了具有一些一般性建议的文档,但是没有看到明确的代码示例来说明如何执行此操作。 So, show do I determine where the cell is getting modified and how do I prevent it? 因此,显示如何确定要在哪里修改单元格以及如何防止它被修改?

The code I am using for complete row selection is: 我用于完整行选择的代码是:

public void foo() {
    final SelectionLayer selectionLayer = glazedListsGridLayer.
      getBodyLayerStack().getSelectionLayer();
    final RowOnlySelectionConfiguration<T> selectionConfig = 
      new RowOnlySelectionConfiguration<>();
    selectionLayer.addConfiguration(selectionConfig);
    getNatTable().addConfiguration(new RowOnlySelectionBindings());
}

You are talking about the selection anchor. 您正在谈论选择锚。 And the only thing you have to do is to register the same style for DisplayMode.SELECT and label SelectionStyleLabels.SELECTION_ANCHOR_STYLE that you register for only DisplayMode.SELECT. 唯一要做的就是为DisplayMode.SELECT注册相同的样式,并为您仅为DisplayMode.SELECT注册的标签贴上SelectionStyleLabels.SELECTION_ANCHOR_STYLE。 The different style is registered in DefaultSelectionStyleConfiguration 在DefaultSelectionStyleConfiguration中注册了不同的样式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM