Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Text wrapping in row header region and cells in edit mode
Text wrapping in row header region and cells in edit mode [message #1775257] Fri, 27 October 2017 00:44 Go to next message
Louis Detweiler is currently offline Louis DetweilerFriend
Messages: 57
Registered: August 2017
Member
Hello,

I am trying to get text wrapping in the row header region and in cells that are being edited. I thought the following code would do it, but that is not the case. What am I missing?

    natTable.getConfigRegistry().registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, 
        new TextPainter(true, true, 2, true), DisplayMode.NORMAL, GridRegion.BODY);
    natTable.getConfigRegistry().registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, 
        new TextPainter(true, true, 2, true), DisplayMode.EDIT, GridRegion.BODY);
    natTable.getConfigRegistry().registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, 
        new TextPainter(true, true, 2, true), DisplayMode.NORMAL, GridRegion.ROW_HEADER);
    
    natTable.configure();
Re: Text wrapping in row header region and cells in edit mode [message #1775270 is a reply to message #1775257] Fri, 27 October 2017 05:39 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2614
Registered: July 2012
Senior Member
The way you are applying the configurations is incorrect in terms of the "life-cycle". NatTable#configure() is checking all registered configurations in all layers and applies them. This leads to an overriding of your configurations, as you directly write to the ConfigRegistry before.

Considering the configuration mechanism it is wrong what you are doing, because you don't know if there is a configuration in an IConfiguration registered somewhere, that would override your setting.

If you execute that code after NatTable#configure() it should work. Although I would say it is still a bad practice to do this as a general configuration. Directly writing to the ConfigRegistry afterwards is typically only done to dynamically change the configuration at runtime, not at initialization time.

Your configuration to get a multi-line text editor does not make any sense. You try to register a TextPainter for the edit mode. But in edit mode the painter is not even shown. The editor will take over. To get a multi-line TextEditor, you need to configure the editor. We have the MultiLineTextCellEditor to support editing with multiple lines.
Re: Text wrapping in row header region and cells in edit mode [message #1775346 is a reply to message #1775270] Sat, 28 October 2017 01:21 Go to previous messageGo to next message
Louis Detweiler is currently offline Louis DetweilerFriend
Messages: 57
Registered: August 2017
Member
Thanks for the response. When trying out the MultiLineTextCellEditor, I got some strange results. It says it should disable commit on enter, however when pressing enter it does commit the changes. Also, instead of wrapping text, it grows the cell horizontally when the text becomes larger than the cell bounds. See the attached image for what happens. Here's the code where I register the MultiLineTextCellEditor.
    configRegistry.registerConfigAttribute(
        EditConfigAttributes.CELL_EDITOR, new MultiLineTextCellEditor(true),
        DisplayMode.EDIT, RequirementsTableConstants.COLUMN_WITH_SINGLE_ENTRY_LABEL);
Re: Text wrapping in row header region and cells in edit mode [message #1775351 is a reply to message #1775346] Sat, 28 October 2017 06:28 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2614
Registered: July 2012
Senior Member
The Javadoc speaks about the behavior in a subdialog. In in line mode the commit behavior is the default one. To insert a line break you need to press alt+enter.

I think that was a bug report some years ago but I forgot to update the Javadoc.

Regarding the size increase I don't know. Need to check. Raise a ticket if the behaviour should be different.
Re: Text wrapping in row header region and cells in edit mode [message #1775353 is a reply to message #1775351] Sat, 28 October 2017 07:59 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2614
Registered: July 2012
Senior Member
Thinking about this more you are right. The behavior should be to not commit on enter but on a key combination. That would be more intuitive and consistent with the RichTextEditor.

Please create a ticket for this behavioral change.
Re: Text wrapping in row header region and cells in edit mode [message #1775385 is a reply to message #1775353] Sat, 28 October 2017 23:32 Go to previous message
Louis Detweiler is currently offline Louis DetweilerFriend
Messages: 57
Registered: August 2017
Member
Will do. I also submitted a bug report for the automatic text wrapping.

The bug reports are here https://bugs.eclipse.org/bugs/show_bug.cgi?id=526607 and here https://bugs.eclipse.org/bugs/show_bug.cgi?id=526608.

Again thanks for your help and responses.
Previous Topic:Gap between grid lines and cells in HDPI environments with CSS & swt.autoScale
Next Topic:A way to disable the default popup menu (right clicking on editable cell)?
Goto Forum:
  


Current Time: Fri Sep 21 05:35:11 GMT 2018

Powered by FUDForum. Page generated in 0.03771 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top