Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Row-height defined via CSS not being applied to data added at runtime(Row-height defined via CSS not being applied to data added at runtime)
Row-height defined via CSS not being applied to data added at runtime [message #1743201] Tue, 13 September 2016 09:37 Go to next message
Lothar L. is currently offline Lothar L.Friend
Messages: 27
Registered: July 2016
Junior Member
We are using CSS to style our table. All classes are applied to the rows and columns - when the table is loaded.

However, when we add more data to the table the row-height does not seem to be being applied anymore. We can reprdoduce this behaviour for example in the NatTable DarkExample.

The DarkExample uses the styling classes .dark for the base styling and "sub" classes for the coulumns. In order to reproduce the problem we define the class

/* DARK CONFIGURATION */

.dark {
tree-structure-painter: background padding tree;
table-border-color: auto;
cell-background-color: black;
color: #F8F8F8;
text-align: left;
padding: 0 5;
invert-icons: true;
}

.dark > .COLUMN_DEFAULT
{
color: black;
row-height: 40px;
cell-background-color: #fafafa;
}

The class is being applied the class in the colum label accumulator. For this example we changed the ColumnLabelAccumulator to always return this label for the columns, i.e. the class is applied to all columns.

    /**
     * The common prefix of column labels (value is {@value} ).
     */
    public static final String COLUMN_LABEL_PREFIX = "COLUMN_"; //$NON-NLS-1$

    @Override
    public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
        configLabels.addLabel("COLUMN_DEFAULT"); //$NON-NLS-1$
    }

    /**
     * {@inheritDoc}
     *
     * @since 1.4
     */
    @Override
    public Collection<String> getProvidedLabels() {
        Collection<String> result = new HashSet<String>();
        if (this.dataProvider != null) {
            for (int i = 0; i < this.dataProvider.getColumnCount(); i++) {
                result.add("COLUMN_DEFAULT"); //$NON-NLS-1$
            }
        }
        return result;
    }


When we open the table the rows have the correct height.

index.php/fa/27040/0/

When we add rows via the Add Data button the row-height is wrong - the colors are applied though.

index.php/fa/27041/0/[img]index.php/fa/27040/0/[/img]

In some cases the row-height gets corrected when the table is being redrawn, i.e. the GUI gets moved.

[Updated on: Tue, 13 September 2016 10:05]

Report message to a moderator

Re: Row-height defined via CSS not being applied to data added at runtime [message #1743225 is a reply to message #1743201] Tue, 13 September 2016 11:58 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
The first thing I wonder is, why do you specify a ROW height for a COLUMN? But in fact the necessary RowSizeConfigurationCommandHandler is registered on the DataLayer and inspects the labels of the first column in the row to apply the row height.

The problem is that the CSSEngine is not triggered on an update of the data, and therefore the row size configured in CSS is not applied to the new rows. You could manually trigger this via

CSSEngine engine = WidgetElement.getEngine(natTable);
if (engine != null) {
    engine.applyStyles(natTable, true);
}


Alternatively we could think about support for specifying the row height per region. This is currently not working as the command handler is registered on the DataLayer, who is not aware of the region. But maybe it would be possible to create some delegation command handler that transports the command only down the layer stack of the corresponding region. Could be worth to think about. Please file a ticket for this.
Re: Row-height defined via CSS not being applied to data added at runtime [message #1743237 is a reply to message #1743225] Tue, 13 September 2016 13:58 Go to previous messageGo to next message
Lothar L. is currently offline Lothar L.Friend
Messages: 27
Registered: July 2016
Junior Member
Dirk Fauth wrote on Tue, 13 September 2016 11:58

...
The problem is that the CSSEngine is not triggered on an update of the data, and therefore the row size configured in CSS is not applied to the new rows. You could manually trigger this via

CSSEngine engine = WidgetElement.getEngine(natTable);
if (engine != null) {
    engine.applyStyles(natTable, true);
}


Alternatively we could think about support for specifying the row height per region. This is currently not working as the command handler is registered on the DataLayer, who is not aware of the region. But maybe it would be possible to create some delegation command handler that transports the command only down the layer stack of the corresponding region. Could be worth to think about. Please file a ticket for this.


The code solved the issue. Thank you. Mh...do we have to expect a noticeable performance penalty for this?

We filled the ticked https://bugs.eclipse.org/bugs/show_bug.cgi?id=501336 as requested.

Quote:

The first thing I wonder is, why do you specify a ROW height for a COLUMN? But in fact the necessary RowSizeConfigurationCommandHandler is registered on the DataLayer and inspects the labels of the first column in the row to apply the row height.


If there is an alternative to setting the label for the required CSS styling on every cell then we are not aware of it. The label references a CSS class that contains more information than the height but also font, alignment, colors, etc ... But the height seems to be the only styling to be applied anymore.


Thank you again for your support!

Re: Row-height defined via CSS not being applied to data added at runtime [message #1743244 is a reply to message #1743237] Tue, 13 September 2016 14:10 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Quote:
do we have to expect a noticeable performance penalty for this?


It is basically the same behavior as if you switch to another part or min/max the shell. The CSS styling engine is generally not something with a great performance, but if it is noticable in case you only style the NatTable instance I can't tell. Honestly I'm not a big fan of the CSS styling support we added to NatTable. The available styling abilities and even the theme styling support based on that are working stable and fast for a long time.

Regarding your the CSS row height styling. The problem is that internally the handling of the row height is different to styling. Styling is registered in the ConfigRegistry. The styles registered there are applied correctly at runtime based on labels. This is the stable configuration mechanism I was talking about, on which the CSS styling is based. The cell dimensions (row height and column width) are stored on the DataLayer, as these are very basic informations that are needed for the whole rendering and handling. So they are not style informations. By applying the row height per row (which is what you are doing) a row height value needs to be actually set to the size configuration. Therefore the engine needs to run so the values are applied for the new rows.

What you really want to achieve is to specify a new default height for all rows in the body region. I looked into the code and this should already work if you specify the row-height in general (without pseudo sub class). The reason is that you are using a grid and in a grid the body always gets the first chance to handle a command. But of course this is not the ideal solution.
Re: Row-height defined via CSS not being applied to data added at runtime [message #1743595 is a reply to message #1743244] Fri, 16 September 2016 16:52 Go to previous message
Lothar L. is currently offline Lothar L.Friend
Messages: 27
Registered: July 2016
Junior Member
Just to let you know the call to the CSS engine did not solve the problem for us because it also reset any size adjustments users would have done. However, your explanation that the data layer actually knows the height helped us find a workaround setting the height on the data directly which currently works for us.

Thanks!
Previous Topic:ShowCellInViewportCommand on _513_FreezeExample
Goto Forum:
  


Current Time: Thu Apr 25 05:46:19 GMT 2024

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

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

Back to the top