Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to make a TableViewer virtual
How to make a TableViewer virtual [message #461006] |
Wed, 14 September 2005 09:35  |
Eclipse User |
|
|
|
Hi,
[Eclipse 3.1.0, JDK 1.4.2]
I'm looking for a documentation describing how-to make a TableViewer
virtual.
Does anyone know of such one or can anybody give me a hint how/where to
start?
Regards,
Michael
|
|
| | |
Re: How to make a TableViewer virtual [message #461078 is a reply to message #461035] |
Thu, 15 September 2005 11:32   |
Eclipse User |
|
|
|
Hi Yves,
First of all thanks for your help.
Do I guess right, that a "virtual" Table/TableViewer is only lazy loading
but not virtual the way Swing JTable and KTable are?
That means, with these kind of tables its possible to only load the first
n records, but the vertical scrollbar "knows" how much records there are
in the model. So you can scroll down and then the next batch of records
gets displayed.
IMHO, the problem with the SWT/JFace table seems that the table's
scrollbar also only knows of the number of records specified by
setItemCount(int) and so are actually displayed.
I know I could handle the scrollbar's events and re-fill the whole table
by doing a clear() and setItemCount() again, but the vertical scrollbar is
not in sync with the number of records in the model.
Am I right or am I missing anything?
Regards,
Michael
Am Thu, 15 Sep 2005 08:53:05 +0200 schrieb Yves Harms
<user@domain.invalid>:
> Table t = new Table(parent, SWT.VIRTUAL);
> //create columns
> for(int i=0;i<5;i++) new TableColumn(t,SWT.NONE).setText("#"+i);
>
> TableViewer v = new TableViewer(table);
>
> v.setContentProvider(new ILazyContentProvider(){
> //implement your Content Provider here
> })
>
> v.setLabelProvider(new ITableLabelProvider(){
> //implement your label Provider here
> });
>
> //for lazy tables setItemCount instead of v.setInput(yourinput)
> v.setItemCount(yourItemCount);
>
>
> You should put the ContentProvider and LabelProvider in seperate
> classfiles, I used anonymous classes to show which interfaces must be
> implemented.
>
> Howto enable Cellediting: This works the same ways as with non-lazy
> TableViewers.
>
> Regards,
> Yves
>
>
>
> michael wrote:
>> Hi,
>> [Eclipse 3.1.0, JDK 1.4.2]
>> I'm looking for a documentation describing how-to make a TableViewer
>> virtual.
>> Does anyone know of such one or can anybody give me a hint how/where
>> to start?
>> Regards,
>> Michael
>>
>
--
Erstellt mit M2, Operas revolutionärem E-Mail-Modul:
http://www.opera.com/m2/
|
|
| | |
Re: How to make a TableViewer virtual [message #461123 is a reply to message #461119] |
Fri, 16 September 2005 11:47   |
Eclipse User |
|
|
|
That is how it works. For a very minimal jface-level example of this see
the snippet below, or for an swt-level example of this see
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet144.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup .
public class TableViewerVIRTUAL {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10,10,300,300);
Table table = new Table(shell, SWT.VIRTUAL);
table.setBounds(10,10,200,200);
final TableViewer viewer = new TableViewer(table);
viewer.setItemCount(10000); // <------
viewer.setLabelProvider(new ITableLabelProvider() {
public void removeListener(ILabelProviderListener listener) {}
public boolean isLabelProperty(Object element, String property)
{
return false;
}
public void dispose() {}
public void addListener(ILabelProviderListener listener) {}
public String getColumnText(Object element, int columnIndex) {
return "virtual item: " +
String.valueOf(((Integer)element).intValue());
}
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
});
viewer.setContentProvider(new ILazyContentProvider() { // <------
public void inputChanged(Viewer viewer, Object oldInput, Object
newInput) {}
public void dispose() {}
public void updateElement(int index) {
System.out.println("setting: " + index);
viewer.replace(new Integer(index), index);
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
Grant
"Rich Kulp" <richkulp@us.NO_SPAM.ibm.com> wrote in message
news:dgekjc$l0u$3@news.eclipse.org...
> I think what he is getting at is, say there are actually 1000 items in
> the input to the table, but he doesn't want to get all 1000 items at
> once. But the scrollbar should actually look like there really are 1000
> items in the table even though there aren't 1000 TableItem's yet.
>
> I don't know if the virtual table works this way.
>
>
> --
> Thanks,
> Rich Kulp
|
|
| | |
Re: How to make a TableViewer virtual [message #462358 is a reply to message #462325] |
Tue, 11 October 2005 09:39  |
Eclipse User |
|
|
|
JFace has other dependencies, you also need to add org.eclipse.core.runtime
and org.eclipse.osgi.
Grant
"Mr. Burns" <Mr._Burns@web.de> wrote in message
news:didud4$3g6$1@news.eclipse.org...
Hello Grant,
I try to get your example TableViewerVIRTUAL to work. I get no compile
error, but if I run the project I get an error message saying:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/core/runtime/ISafeRunnableat
TableViewerVIRTUAL.main(TableViewerVIRTUAL.java:15)
I am working under Eclipse 3.1, and added a project dependency to SWT
project (described under http://www.eclipse.org/swt/eclipse.php).
I also added the the org.eclipse.jface_3.1.0.jar to my project.
What did I wrong? Is there something missing?
Thanks for any help!
|
|
|
Goto Forum:
Current Time: Mon Jul 07 20:51:32 EDT 2025
Powered by FUDForum. Page generated in 0.10234 seconds
|