[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Re: [jface.viewers] May CellLabelProvider.update be called by clients?

Daniel Krügler wrote:
Tom Schindl wrote:
I would expect that a redraw leads to callbacks into the ownerdraw
listeners who call back to the update()-method.

Hmmh, I can only partially confirm that. What I did is that I replaced my current call of

update(activeCell);

- where activeCell is the ViewerCell result from the previous getViewer().getCell(pt) call and update is the member method of my StyledCellLabelProvider derivative - by

Rectangle rect = activeCell.getBounds();
activeCell.getControl().redraw(rect.x, rect.y, rect.width,
    rect.height, true);

which is essentially the same call as FocusCellOwnerDrawHighlighter
does. I see that a short time later the triade SWT.MeasureItem,
SWT.EraseItem, and SWT.PaintItem of the OwnerDrawLabelProvider base
class listener are invoked properly delegating to the corresponding StyledCellLabelProvider callbacks, but none of them seems calls the
update method of my StyledCellLabelProvider derivative. There is no direct observable change (i.e. no color change) in contrast to my previous code.


Can this be correct? Let me note that OwnerDrawLabelProvider#update
itself calls

// Force a redraw
Rectangle cellBounds = cell.getBounds();
cell.getControl().redraw(cellBounds.x, cellBounds.y, cellBounds.width,
        cellBounds.height, true);

but if this would call update again, this would cause an infinitive
recursion. Currently I see no alternative to a direct call to my
StyledCellLabelProvider#update method, but I would be glad if someone
points to the obvious glitch in my code.

Here some more information:

a) I'm using Eclipse 3.4.2, but my own code (explicit call of update) also runs also with Eclipse 3.5.

b) In case it isn't clear what the update method of my CellLabelProvider
does, here is the essential part:

	public final void update(ViewerCell cell) {
                [..]
		Color fg = activeCell != null ?
                        activeLinkColor : linkColor;
		cell.setForeground(fg);
                [..]
		super.update(cell);
	}

Thanks,

Daniel