Community
Participate
Working Groups
Background: RAP re-uses the JFace source code with some internal modifications to provide the same API for web-development as is known from rich-client -development. To minimize the changes necessary to adopt the JFaces sources I suggest the following change: All code that manipulates FontData should re-create fonts instead of using the setStyle() and setHeight() methods. RAP shares FontData across sessions and thus provides a subset of the FontData class from SWT that is immutable and hence does not have setters. This change would bring RAP one step closer re-use JFace code without changes. I will attach a patch with the necessary changes.
Created attachment 159338 [details] Patch
Rüdiger, did you look at the performance implications of making this change? It would be good to understand if this could lead to cases where Eclipse got slower in a way that is noticeable by end users.
I did a very naive test (currentTimeMillis, see code below) that simulates calling FontDescriptor#setHeight() before and after the change. On my machine, the change becomes measurable (1 ms) after 200 iterations. Is this low enough to count as not noticeable? public static void main( String[] args ) { int count = 200; Display display = Display.getDefault(); Font systemFont = display.getSystemFont(); FontData fontData = systemFont.getFontData()[ 0 ]; // simulate "old" approach: FontDescriptor#setHeight is forwarded to FontData#setHeight int delta = 1; long start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { fontData.setHeight( fontData.getHeight() + delta ); delta = delta * ( -1 ); } System.out.println( "duration before patch: " + ( System.currentTimeMillis() - start ) ); // simulate "RAP-frienly" approach: FontDescriptor#setHeight re-creates FontData delta = 1; for (int i = 0; i < count; i++) { fontData = new FontData( fontData.getName(), fontData.getHeight() + delta, fontData.getStyle() ); delta = delta * ( -1 ); } System.out.println( "duration after patch: " + ( System.currentTimeMillis() - start ) ); }
In the meanwhile we found a way to support the setStyle() and setHeight() methods in RAP.