Grid Nebula - Performance GridItem.setHeight ()

I am using the Nebula Grid widget in my RCP application. I added a control panel to my grid that will resize each height of the Grid row whenever the grid control is resized. The code snippet is as follows:

@Override public void controlResized(ControlEvent e) { GridColumn []cols = grid.getColumns(); for (GridItem item : grid.getItems()) { GC gc = new GC(item.getDisplay()); int max = 0; Point tb=null; for(GridColumn col : cols){ tb = col.getCellRenderer().computeSize(gc, col.getWidth(), SWT.DEFAULT, item); max = Math.max(max, tb.y); if(max > hmax){ break; } } if(hmax==-1){ }else if(max > hmax){ max=hmax; } gc.dispose(); item.setHeight(max); } } 

This works fine, i.e. height is adjusted every time the user resizes any column. But whenever the number of grid lines is huge, say, from a few hundred to thousands, resizing is not smooth. The user interface does not respond for a few seconds. by doing some analysis, I could narrow down the expression responsible for this delay. this statement is below:

 tb = col.getCellRenderer().computeSize(gc, col.getWidth(), SWT.DEFAULT, item); 

I could understand the reason for this. This above statement is called for each row and column, and this seems to be the reason. for a grid of 2,000 rows and 5 columns, this operator is called 10,000 times. How can I complete this process?

+5
source share

All Articles