AidenPearce
AidenPearce

Reputation: 93

Eclipse RCP CSS pack() does not consider new font

I work on a RCP-application and use the eclipse-css-feature too change the overall font of the application. But when used, the table-elements in the main-perspective does not adapt to the changes. In createPartControl(Composite) the table is filled with content and TableColumn.pack() is called on each one. Before I changed the overall font to Verdana 9px columns always were large enough to hold their content, e.g. "My very long text that is long". Now, however, the columns only display "My very long text that i...". Re-setting the content of the table (clear, fill and pack()) during the setFocus()-function seems to be working, but it also is a pretty bad workaround. Also, this does not solve the problem that I have to wait for the first click to do this.

How do I get my application to pack() table-columns properly on startup?

This is my css:

* {
    font: Verdana 8px;
    background-color: White;
}

Upvotes: 0

Views: 43

Answers (1)

greg-449
greg-449

Reputation: 111142

The problem is that the CSS styles are not applied until the SWT.Skin event is generated after the controls are created.

So you need to run your pack after that event. One way to do that is to use Display.asyncExec to run your pack code after the createPartControl has completed. The asyncExec Runnable should then run after the SWT.Skin.

Alternatively you can get the CSS styling engine and force the styling to happen. In a 3.x compatibility view/editor use:

IStylingEngine engine = getSite().getService(IStylingEngine.class);

engine.style(control);

Upvotes: 1

Related Questions