[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: TableCursors, TableViewers and multi-line selection
|
John,
I'm sorry that I have to disappoint you but I currently don't support
multi-selection. There's a feature request [1] for this but I didn't had
time in 3.4 to work on it (it's currently on my 3.5 TODO-List and if you
want to push this forward I'm happy to work with you on this feature).
Until then you need to solve this your own but believe me it's hard to
get it right :-(
The reason the selection you see is still valid is that we only erase
the selection color using ownerdraw the underlying widget still reports
the correct selection although I also want to provide a specialized
StructuredSelection in future reporting the selected cells [2,3].
Tom
[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=206692
[2] https://bugs.eclipse.org/bugs/show_bug.cgi?id=198260
[3] https://bugs.eclipse.org/bugs/show_bug.cgi?id=151377
John Buslawski schrieb:
We have an Eclipse application that displays model objects and their
properties in multiple tables. Because there are a quite a few
properties for some model objects we display the most accessed
properties directly in the table and use a properties view to display
the complete list of properties for the model object. We enable
multi-select so that someone can select a range of model objects (rows)
in the table, go to the properties view and edit a property and have the
value propagate to all of the selected model objects. We also use custom
cell editors for just about every property so it would be quite a bit of
change to create these editors inside a listener as suggested in some of
the JFace TableCursor snippets.
Some of our users have asked for the ability to navigate the table with
the arrow keys like they do an Excel spreadsheet. We have looked through
some of the newsgroups and JFace snippets and have added the following
lines from Snippet036FocusBorderCellHighlighter into our existing code:
TableViewerFocusCellManager focusCellManager = new
TableViewerFocusCellManager(v,new FocusBorderCellHighlighter(v));
ColumnViewerEditorActivationStrategy actSupport = new
ColumnViewerEditorActivationStrategy(v) {
protected boolean
isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
return event.eventType ==
ColumnViewerEditorActivationEvent.TRAVERSAL
|| event.eventType ==
ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
|| (event.eventType ==
ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == ' ')
|| event.eventType ==
ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
};
TableViewerEditor.create(v, focusCellManager, actSupport,
ColumnViewerEditor.TABBING_HORIZONTAL
| ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
| ColumnViewerEditor.TABBING_VERTICAL |
ColumnViewerEditor.KEYBOARD_ACTIVATION);
The code performs as advertised. The table navigation works fine and the
cell editors get activated correctly. However, there is what appears to
be a bug with multi-line selections. When you make the last mouse
selection for a range of rows while holding down the shift key, only
that last selected cell is highlighted, not the full range of rows as
you would expect in a multi-select. However, if you were to go to the
properties view and modify a property, the new value would be
propagated to all of the correct cells in the multi-select, not just the
highlighted cell. It appears as though the multi-select is still
functional but the hightlighting in the table is not correct. The range
of selected rows should be highlighted, not just the last selected cell.
First, is this a known bug or working as designed? We have looked
through the SWT bugs and there really isn't anything that describes this
problem accurately.
We are familiar with the TableCursor snippet where listeners are used to
recognize the shift and control keys and disable/enable the TableCursor
as appropriate. Is this snippet better suited for the capability we want
(arrow key navigation but be able to multi-select and highlight
correctly). It eliminates the FocusCellManager and from tracing through
the code it appears as though the SWTFocusCellManager is involved in
limiting the selection to the last cell chosen.
Our application is currently based on Eclipse 3.3. We can easily move to
Eclipse 3.4 if necessary.
--
B e s t S o l u t i o n . at
--------------------------------------------------------------------
Tom Schindl JFace-Committer
--------------------------------------------------------------------