[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform] Re: TreeViewerFocusCellManager support for SWT.MULTI

Tom,

Thanks for the timely response and the insight.

One of the things I realized is that if the SWT.MULTI flag is set the 
highligted cell is probably (I have only done limited testing) belongs to 
the last element in the selection list.  It may be wise to add an Assert 
!SWT.MULTI to the FocusCellOwnerDrawHighlighter.

In any case I have been able to get the selection behavior I was looking for 
by only performing cell highlighing when there is a single selection. 
Instead of going though the effort to link in the source for the entire 
jface class to my I just copied the FocusCellOwnerDrawHighlighter class to 
my workspace and made the modification.  To do so I had to replace 
viewer.getViewerRowFromItem(event.item); with  focusCell.getViewerRow(); 
because the first one was hidden.  Under what circumstances would the two 
methods return different results?

Regards,

GB
private void hookListener(final ColumnViewer viewer) {


Listener listener = new Listener() {


public void handleEvent(Event event) {

if ((event.detail & SWT.SELECTED) > 0) {

ViewerCell focusCell = getFocusCell();

ViewerRow row = focusCell.getViewerRow(); // 
viewer.getViewerRowFromItem(event.item);


Assert

.isNotNull(row,

"Internal structure invalid. Item without associated row is not possible."); 
//$NON-NLS-1$


ViewerCell cell = row.getCell(event.index);


TreeSelection s = (TreeSelection) viewer.getSelection();

if(s.size()==1){                            // added this

if (focusCell == null || !cell.equals(focusCell)) {

removeSelectionInformation(event, cell);

} else {

markFocusedCell(event, cell);

}

}

}

}


};

viewer.getControl().addListener(SWT.EraseItem, listener);

}

"Tom Schindl" <tom.schindl@xxxxxxxxxxxxxxx> wrote in message 
news:gni3lt$ok6$1@xxxxxxxxxxxxxxxxxxxx
> Hi,
>
> IMHO this is not an issue of the FocusCellManager because only one cell
> at a time can have the focus.
>
> It is only an issue of the renderer IIRC (the owner draw one) because it
> removes all selection information (if you query the selection it should
> hold multiple elements).
>
> The feature request in question is
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=206692 but because of time
> constraints I'm unable to implement this feature but if you want to work
> on it I can mentor you.
>
> The first question you'll need to answer is what SWT.MULTI in a
> cell-selection mode means. I guess you mean multiple Cells are selected?
>
> Tom
>
> Greg Babcock schrieb:
>> Are there any plans for the TreeViewerFocusCellManager to support 
>> multi-line
>> selection?  I am considering implementing a custom solution, and would
>> appreciate any insight from anybody that has investigated this issue.
>>
>> Thank You,
>>
>> GB
>>
>>
>
>
> -- 
> B e s t S o l u t i o n . at
> --------------------------------------------------------------------
> Tom Schindl                                          JFace-Committer
> --------------------------------------------------------------------
>