0

I've header menu configuration added in my nat table as follows,where I've included "Select Columns" menu as well:

// Popup menu

this.natTable.addConfiguration(new HeaderMenuConfiguration(this.natTable) {

@Override

protected PopupMenuBuilder createColumnHeaderMenu(NatTable natTable) {

  return super.createColumnHeaderMenu(natTable) .withColumnChooserMenuItem(); }

});

// Column chooser

DisplayColumnChooserCommandHandler columnChooserCommandHandler = new DisplayColumnChooserCommandHandler( bodyLayer.getSelectionLayer(), bodyLayer.getColumnHideShowLayer(), columnHeaderLayer.getColumnHeaderLayer(), columnHeaderLayer.getColumnHeaderDataLayer(), columnHeaderLayer.getColumnGroupHeaderLayer(), columnGroupModel);

//If header name consists of multiple words then I've used ("\n") as a separator between words in //the header column name ,so that some space could be saved

// In that case on opening "Select Columns" context menu dialog only first word of column is visible

Can it be fixed by replacing all "\n" and white space character by single white space(" ") character in In org.eclipse.nebula.widgets.nattable.columnChooser.gui.ColumnChooserDialog //code to replace extra white spaces or new line character from column label with single space so that //header name is completely visible in populate tree method treeItem.setText(columnEntry.getLabel()); In that case can fix be provided to replace extra space with single space in column header name or is there any other alternative to fix it? Image with header names having multiple words For eg:"Issue Date",if header name is dispalyed as "Issue\nDate",only Issue is visible in "Select Columns" context menu dialog

User134
  • 1
  • 2

1 Answers1

0

IIRC you add the line breaks to save some space. They are not needed for any semantical reason. I would suggest to configure the TextPainter that renders the column header cell content to wrap automatically if not enough space is available. This could look like this for example:

configRegistry.registerConfigAttribute(
    CellConfigAttributes.CELL_PAINTER,
    new BeveledBorderDecorator(new TextPainter(true, false, false, true)),
    DisplayMode.NORMAL,
    GridRegion.COLUMN_HEADER);
Dirk Fauth
  • 4,128
  • 2
  • 13
  • 23
  • adding TextPainter was the first choice but in that case complete header name is not visible. – User134 Mar 24 '21 at 12:49
  • For example in case of "Issue Date" only "Issue..." is visible .That is why I added new line to see complete header name in the available space.Therefore requesting to remove extra space or new line character from treeItem.setText(columnEntry.getLabel()) in populateTree() of ColumnChooserDialog.So that complete header name is visible in Select columns dialog in header menu even on adding new line character in column header labels – User134 Mar 24 '21 at 12:53
  • Or is there any alternative way to make complete header name visible in header context menu Select Columns dialog when header labels have new line character? – User134 Mar 24 '21 at 12:56
  • If you register the TextPainter as shown in the snippet word wrapping row height calculation are enabled. So you should see the whole column header and no three dots. And no there is no way to handle new line characters in that dialog. But you can of course subclass and create your own dialog. – Dirk Fauth Mar 24 '21 at 15:59
  • Thank you very much Dirk Fauth.Text painter resolved the issue here.Text painter configuration was getting overwritten.Hence it was not effective earlier.After placing configuration correctly Text Painter worked in this case.Thank you ,this was helpful – User134 Mar 25 '21 at 12:19