------_=_NextPart_001_01C39E2B.11BB3650
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Maybe=20
I don't understand you question but couldn't you use a separate thread =
to fill=20
the table and display.asyncExec (new Runnable ()..); to =
update the GUI.=20
That what I did in a situation where I was loading a lot of data into a =
table=20
and didn't what the user to wait for the table loading to=20
complete.
-----Original Message-----
From: Cyril Araud=20
[mailto:ca@xxxxxxxxxxxx]
Sent: Wednesday, October 29, 2003 =
1:51=20
AM
To: platform-swt-dev@xxxxxxxxxxx
Subject:=20
[platform-swt-dev] lazy loading for =
table
Hello,
I want to fill a table whith a lot of lines.
In order to increase performances, I was thinking of using a
LabelProvider.
I was hopping that the Label Provider would be called only
for visible lines.
But the label provider is called for each line, as you can see if you
run
the enclosed snippet, as soon as the Table.setInput() is called.
Is it possible that the label provider is called only for visible line
?(in
fact
I have a lot of calculations to do to compute the content of each cell
so i want to do them only if needed)
How can I turn on this feature if it exists ?
Thank for your help,
Cyril Araud
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
public class Test {
public
static void main(String[] args){
Display
display =3D new Display ();
final
Shell shell =3D new Shell (display);
GridLayout
layout =3D new GridLayout();
layout.numColumns
=3D 1;
shell.setLayout(la=
yout);
Table
t =3D new Table(shell, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
String[]
headers =3D new String[]{"",""};
for
(int i =3D 0; i < headers.length; i++) {
TableColumn
column =3D new TableColumn(t, SWT.NONE);
column.setText(headers[i]);=
column.setWidth(90);
}
t.setLayoutData(ne=
w
GridData(GridData.FILL_BOTH));
ITableLabelProvide=
r
provider =3D new LabelProvider();
TableViewer
tv =3D new TableViewer(t);
tv.setLabelProvide=
r(provider);
tv.setContentProvi=
der(new
ContentProvider());
shell.setSize(250,=
250);
shell.open
();
String[]
iKs =3D new String[10000];
for
(int i=3D0; i<10000; i++){
iKs[i]
=3D "line " + i;
}
tv.setInput(iKs);
while
(!shell.isDisposed ()) {
if
(!display.readAndDispatch ()) display.sleep ();
}
display.dispose
();
}
}
class LabelProvider implements ITableLabelProvider{
public
Image getColumnImage(Object arg0, int arg1) {
return
null;
}
public
String getColumnText(Object s, int arg1) {
System.out.println=
("LabelProvider.
getColumnText(" + s+" )");
return
s.toString();
}
public
void addListener(ILabelProviderListener arg0) {
}
public
void dispose() {
}
public
boolean isLabelProperty(Object arg0, String arg1) {
return
false;
}
public
void removeListener(ILabelProviderListener arg0) {
}
}
class ContentProvider implements IStructuredContentProvider{
public
Object[] getElements(Object o) {
if
(o instanceof String[]){
return
(String[])o;
}
return
null;
}
public
void dispose() {
}
public
void inputChanged(Viewer arg0, Object arg1, Object arg2) {
}
}
------_=_NextPart_001_01C39E2B.11BB3650--
--__--__--
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev
End of platform-swt-dev Digest