Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » TreeViewerFocusCellManager support for SWT.MULTI
TreeViewerFocusCellManager support for SWT.MULTI [message #334579] Wed, 18 February 2009 22:43 Go to next message
Greg Babcock is currently offline Greg BabcockFriend
Messages: 53
Registered: July 2009
Member
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
Re: TreeViewerFocusCellManager support for SWT.MULTI [message #334580 is a reply to message #334579] Wed, 18 February 2009 22:55 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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 #334581 is a reply to message #334580] Wed, 18 February 2009 23:00 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
By the way "native" multi-cell selection is provided by Nebula-Grid.

Tom

Tom Schindl schrieb:
> 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 #334596 is a reply to message #334580] Thu, 19 February 2009 15:57 Go to previous messageGo to next message
Greg Babcock is currently offline Greg BabcockFriend
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 #334597 is a reply to message #334596] Thu, 19 February 2009 16:38 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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 #334598 is a reply to message #334597] Thu, 19 February 2009 18:19 Go to previous messageGo to next message
Greg Babcock is currently offline Greg BabcockFriend
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 Go to previous message
Greg Babcock is currently offline Greg BabcockFriend
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
>> ------------------------------------------------------------ --------
>
>
Previous Topic:Wrapping broken in ScrolledForm with GridLayout?
Next Topic:(EMF generated) editor plugin does not run (without reported errors)
Goto Forum:
  


Current Time: Thu Dec 26 19:53:28 GMT 2024

Powered by FUDForum. Page generated in 0.02895 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top