I am using a JXTreeTable.
I want to show a text in a cell only if the row is collapsed. If the row is expanded the detailed values are shown in the childs so the shortened text in the parent should no longer be visible.
As far as I know this need to be implemented by providing a special ComponentProvider used by the DefaultTableRenderer. Anyhow the CellContext used by the ComponentProvider always indicates that the node is expanded. context.isExpanded() always returns true.
StringValue valueProvider = new StringValue()
{
@Override
public String getString(Object value)
{
return String.valueOf(value);
}
};
ComponentProvider<?> textProvider = new LabelProvider(valueProvider, JLabel.TRAILING)
{
@Override
protected String getValueAsString(CellContext context)
{
System.out.println("Context expanded " + context.isExpanded());
if (context.isExpanded())
{
return "";
}
return super.getValueAsString(context);
}
};
DefaultTableRenderer renderer = new DefaultTableRenderer(textProvider);
What do I have to change in the ComponentProvider to detect if the row of the cell is expanded or not?