Francis Upton schrieb:
I'm writing a search facility for my product. When searching, it's
possible for hundreds of results to be returned. Each result is shown
as a table row with up to 3 links in it (to various levels of the
hierarchy representing the result). The table is shown through a dialog
of a few rows.
Previously this all worked fine (except without the hyperlinks) by
having a TableViewer. The scrolling and resizing was fast, even if
there were thousands of results.
Now I'm trying to add the links. I see the following options:
1) Using a plain Table with a TableEditor (which refers to a Link
control). This worked reasonably well, except for performance. It's
unusable with more than a small number of rows. There is also this bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=166720
So this option won't work (unless I'm doing it wrong or there is another
way to do it).
Well if you really have so many results that's a problem because your
Table has to handle very many Widgets whereas is in TableViewer there
aren't hardly any!
2) TableViewer - I don't think it's possible to have an arbitrary
control for rendering a table cell in use with a TableViewer unless I
subclass it. Creating a CellEditor does no good, as this replaces the
control only when the cell is edited.
My next step is to consider subclassing TableViewer and having it use a
TableEditor referring to a Link, however, I'm concerned I will run into
the same issues I have with option 1.
Why does it have to be a TableEditor. You could make the String look
like a link (underlining maybe is a problem but you can resolve it using
custom drawing).
To change the foreground color ITableColorProvider and to underline an
item you can look at the owner draw support:
Owner Draw is shown in:
- http://www.eclipse.org/swt/snippets/
-
http://www.eclipse.org/articles/Article-CustomDrawingTableAndTreeItems/customDraw.htm
If you want to open a link when the user clicks one of the emulated
links you only need to track mouse clicks on your like shown in this
snippet.
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet110.java
If you are using 3.3 for development and there is/will be a bunch of new
API which make all the above fairly easy.
OwnerDraw:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/Snippet010OwnerDraw.java?rev=HEAD&content-type=text/vnd.viewcvs-markup
(broken if you run it against current CVS)
CellSelection:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=151377
3) Use a TreeViewer. The search results can be represented as a tree,
where each node then has only one link in it. I have not looked into
this, but I would assume I will have to subclass TreeViewer as in option
2 to have it render a Link.
Are there other options? Am I missing something obvious?
The same as for TableViewer.
TIA,
Francis