|
|
|
Re: TreeViewerFocusCellManager support for SWT.MULTI [message #334596 is a reply to message #334580] |
Thu, 19 February 2009 15:57 |
Greg Babcock Messages: 53 Registered: July 2009 |
Member |
|
|
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@bestsolution.at> wrote in message
news:gni3lt$ok6$1@build.eclipse.org...
> 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
> ------------------------------------------------------------ --------
>
|
|
|
|
Re: TreeViewerFocusCellManager support for SWT.MULTI [message #334598 is a reply to message #334597] |
Thu, 19 February 2009 18:19 |
Greg Babcock Messages: 53 Registered: July 2009 |
Member |
|
|
Tom,
There are essentially two scenerios that I need to support. Editing cells,
and selecting elements for delete or drag, and drop. The current
implementation works correctly for editing, but I need to be able to select
multiple elements for deleting and drag and drop. As you mentioned in an
earlier post, the selection part of SWT.MULTI is functional, but the
FocusCellOwnerDrawnHighlighter is not highlighting the entire selection. So
all did was add a filter in the Listener in
FocusCellOwnerDrawnHighlighter.hookListener(final ColunnViewer) to only
modify the highlighted cells when the selection size==1.
In short all I had to do was chang the following line in
FocusCellOwnerDrawnHighlighter.hookListener(final ColunnViewer) from
if ((event.detail & SWT.SELECTED) > 0) {
to
if ((event.detail & SWT.SELECTED) > 0 &&
((StructuredSelection)viewer.getSelection()).size()==1) {
While reviewing the change using snippet 48 I noticed that sometimes the row
area to the right of the last column is highlighted, and sometimes it is
not.
Regards,
GB
"Tom Schindl" <tom.schindl@bestsolution.at> wrote in message
news:gnk1ui$np$1@build.eclipse.org...
> Greg Babcock schrieb:
>> 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?
>
>
> When a ViewerCell is detached from the viewer we clone it because we
> internally reuse the ViewerRow and Viewercell IIRC.
>
> I guess I didn't get what you describe do you have a fully running
> example so that I can see the modified behaviour? Maybe it is feasable
> and a common use case so that we could provide a switch between the 2?
>
> Tom
>
> --
> B e s t S o l u t i o n . at
> ------------------------------------------------------------ --------
> Tom Schindl JFace-Committer
> ------------------------------------------------------------ --------
|
|
|
Re: TreeViewerFocusCellManager support for SWT.MULTI [message #334599 is a reply to message #334598] |
Thu, 19 February 2009 18:27 |
Greg Babcock Messages: 53 Registered: July 2009 |
Member |
|
|
When doing this the ColumnViewerEditorActivationStragegy should also be set
to not activate when there are multiple selections to prevent non-editor
cells from being highlighted.
"Greg Babcock" <greg.babcock@testadvantage.com> wrote in message
news:gnk7rl$t91$1@build.eclipse.org...
> Tom,
>
> There are essentially two scenerios that I need to support. Editing
> cells, and selecting elements for delete or drag, and drop. The current
> implementation works correctly for editing, but I need to be able to
> select multiple elements for deleting and drag and drop. As you mentioned
> in an earlier post, the selection part of SWT.MULTI is functional, but the
> FocusCellOwnerDrawnHighlighter is not highlighting the entire selection.
> So all did was add a filter in the Listener in
> FocusCellOwnerDrawnHighlighter.hookListener(final ColunnViewer) to only
> modify the highlighted cells when the selection size==1.
>
> In short all I had to do was chang the following line in
> FocusCellOwnerDrawnHighlighter.hookListener(final ColunnViewer) from
> if ((event.detail & SWT.SELECTED) > 0) {
> to
> if ((event.detail & SWT.SELECTED) > 0 &&
> ((StructuredSelection)viewer.getSelection()).size()==1) {
>
>
> While reviewing the change using snippet 48 I noticed that sometimes the
> row area to the right of the last column is highlighted, and sometimes it
> is not.
>
> Regards,
>
> GB
>
> "Tom Schindl" <tom.schindl@bestsolution.at> wrote in message
> news:gnk1ui$np$1@build.eclipse.org...
>> Greg Babcock schrieb:
>>> 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?
>>
>>
>> When a ViewerCell is detached from the viewer we clone it because we
>> internally reuse the ViewerRow and Viewercell IIRC.
>>
>> I guess I didn't get what you describe do you have a fully running
>> example so that I can see the modified behaviour? Maybe it is feasable
>> and a common use case so that we could provide a switch between the 2?
>>
>> Tom
>>
>> --
>> B e s t S o l u t i o n . at
>> ------------------------------------------------------------ --------
>> Tom Schindl JFace-Committer
>> ------------------------------------------------------------ --------
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02895 seconds