Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Fill JFace TableViewer from background Thread
Fill JFace TableViewer from background Thread [message #448869] |
Fri, 14 January 2005 11:52 |
Eclipse User |
|
|
|
Originally posted by: joerg.von.frantzius.artnology.nospam.com
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
<br>
I'm trying to do pretty much the same as demonstrated in a <a
href=" http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet7.java?rev=HEAD&am p;amp;content-type=text/vnd.viewcvs-markup">snippet
for SWT Table </a> only that I want to fill a TableViewer instead of an
SWT Table. My TableViewer has a LabelProvider and everything works fine
if I fill it synchronously using setInput() and a ContentProvider.
Using a separate Thread and TableViewer.add(), I got it so far as the
table's scroll bar becoming smaller and smaller due to new objects
being added, but it does not show the actual contents in the table,
only the scroll bar becomes smaller!<br>
<br>
This is what my Thread's run method looks like:<br>
<br>
public void run() {<br>
for (Iterator iter = kunstwerke.iterator();
iter.hasNext();) {<br>
final Kunstwerk kunstwerk = (Kunstwerk) iter.next();<br>
d.syncExec(new Runnable() {<br>
public void run() {<br>
tableViewer.add(kunstwerk);<br>
//tableViewer.refresh();<br>
}<br>
});<br>
}<br>
<br>
"kunstwerke" is a Set containing the objects to be displayed in the
table and Display "d" was determined using
Display.findDisplay(Thread.currentThread()) in the main thread. I can
see my LabelProvider being called and returning Strings for the table's
columns, but they are not painted. I tried calling refresh as in the
comment above, and tableViewer.update(kunstwerk,null); after the add,
but it didn't help.<br>
<br>
Does anybody haven an idea what the problem might be here? This is with
Eclipse 3.1 M4 on Windows XP.<br>
<br>
Thanks,<br>
Jörg.<br>
</body>
</html>
|
|
|
Re: Fill JFace TableViewer from background Thread [message #448881 is a reply to message #448869] |
Fri, 14 January 2005 16:56 |
Eclipse User |
|
|
|
Originally posted by: joerg.von.frantzius.artnology.nospam.com
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Alright, nobody answered, which is good because it was entirely my
fault and not related to TableViewer at all... Please disregard.<br>
<br>
Joerg von Frantzius schrieb:
<blockquote cite="midcs8bpo$n7g$1@www.eclipse.org" type="cite">
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
Hi,<br>
<br>
I'm trying to do pretty much the same as demonstrated in a <a
href=" http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet7.java?rev=HEAD&am p;amp;content-type=text/vnd.viewcvs-markup">snippet
for SWT Table </a> only that I want to fill a TableViewer instead of an
SWT Table. My TableViewer has a LabelProvider and everything works fine
if I fill it synchronously using setInput() and a ContentProvider.
Using a separate Thread and TableViewer.add(), I got it so far as the
table's scroll bar becoming smaller and smaller due to new objects
being added, but it does not show the actual contents in the table,
only the scroll bar becomes smaller!<br>
<br>
This is what my Thread's run method looks like:<br>
<br>
public void run() {<br>
for (Iterator iter = kunstwerke.iterator();
iter.hasNext();) {<br>
final Kunstwerk kunstwerk = (Kunstwerk) iter.next();<br>
d.syncExec(new Runnable() {<br>
public void run() {<br>
tableViewer.add(kunstwerk);<br>
//tableViewer.refresh();<br>
}<br>
});<br>
}<br>
<br>
"kunstwerke" is a Set containing the objects to be displayed in the
table and Display "d" was determined using
Display.findDisplay(Thread.currentThread()) in the main thread. I can
see my LabelProvider being called and returning Strings for the table's
columns, but they are not painted. I tried calling refresh as in the
comment above, and tableViewer.update(kunstwerk,null); after the add,
but it didn't help.<br>
<br>
Does anybody haven an idea what the problem might be here? This is with
Eclipse 3.1 M4 on Windows XP.<br>
<br>
Thanks,<br>
Jörg.<br>
</blockquote>
<br>
</body>
</html>
|
|
|
Re: Fill JFace TableViewer from background Thread [message #448934 is a reply to message #448881] |
Sat, 15 January 2005 08:21 |
Eclipse User |
|
|
|
Originally posted by: petra_h.hotmail.com
Hi Joerg!
I tried to do the same as you describe but unfortunately my table viewer
stay empty as well. What was the problem you had, maybe I do the same
mistake...
I wrote the following code:
final Display display = PlatformUI.getWorkbench().getDisplay();
Thread thread = new Thread () {
public void run() {
//get dbObject display in this editor
DBObject editorObj = ListSection.editorInput;
//get the elements to set in the table
Object[] elements = ((TableContentProvider)collectionViewer.
getContentProvider()).getElements(editorObj);
for (int i=0; i< elements.length; i++){
final DBObject dbObj = (DBObject)elements[i];
display.syncExec(new Runnable() {
public void run() {
collectionViewer.add(dbObj);
collectionViewer.refresh();
}
});
}
};
};
thread.start();
Thanks for your answer,
Petra
Joerg von Frantzius wrote:
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
> <meta content="text/html;charset=ISO-8859-15"
> http-equiv="Content-Type">
> </head>
> <body bgcolor="#ffffff" text="#000000">
> Alright, nobody answered, which is good because it was entirely my
> fault and not related to TableViewer at all... Please disregard.<br>
> <br>
> Joerg von Frantzius schrieb:
> <blockquote cite="midcs8bpo$n7g$1@www.eclipse.org" type="cite">
> <meta content="text/html;charset=ISO-8859-15"
> http-equiv="Content-Type">
> <title></title>
> Hi,<br>
> <br>
> I'm trying to do pretty much the same as demonstrated in a <a
>
href=" http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet7.java?rev=HEAD&am p;content-type=text/vnd.viewcvs-markup">snippet
> for SWT Table </a> only that I want to fill a TableViewer instead of an
> SWT Table. My TableViewer has a LabelProvider and everything works fine
> if I fill it synchronously using setInput() and a ContentProvider.
> Using a separate Thread and TableViewer.add(), I got it so far as the
> table's scroll bar becoming smaller and smaller due to new objects
> being added, but it does not show the actual contents in the table,
> only the scroll bar becomes smaller!<br>
> <br>
> This is what my Thread's run method looks like:<br>
> <br>
> public void run() {<br>
> for (Iterator iter = kunstwerke.iterator();
> iter.hasNext();) {<br>
> final Kunstwerk kunstwerk = (Kunstwerk) iter.next();<br>
> d.syncExec(new Runnable() {<br>
> public void run() {<br>
> tableViewer.add(kunstwerk);<br>
> //tableViewer.refresh();<br>
> }<br>
> });<br>
> }<br>
> <br>
> "kunstwerke" is a Set containing the objects to be displayed in the
> table and Display "d" was determined using
> Display.findDisplay(Thread.currentThread()) in the main thread. I can
> see my LabelProvider being called and returning Strings for the table's
> columns, but they are not painted. I tried calling refresh as in the
> comment above, and tableViewer.update(kunstwerk,null); after the add,
> but it didn't help.<br>
> <br>
> Does anybody haven an idea what the problem might be here? This is with
> Eclipse 3.1 M4 on Windows XP.<br>
> <br>
> Thanks,<br>
> Jörg.<br>
> </blockquote>
> <br>
> </body>
> </html>
|
|
|
TreeViewer? Re: Fill JFace TableViewer from background Thread [message #448936 is a reply to message #448934] |
Sat, 15 January 2005 08:58 |
Eclipse User |
|
|
|
Originally posted by: petra_h.hotmail.com
Hi!
I also managed it to get it working. But another question (maybe someone
knows an answer): is the same behavior possible for a tree viewer instead
of a table viewer? My problem is that the first two levels of the tree
expand quite quickly, but then the third level needs a lot of time. Is it
possible to do this third expansion in a lazy manner?
Thanks for any help.
Petra
Petra Hangartner wrote:
> Hi Joerg!
> I tried to do the same as you describe but unfortunately my table viewer
> stay empty as well. What was the problem you had, maybe I do the same
> mistake...
> I wrote the following code:
> final Display display = PlatformUI.getWorkbench().getDisplay();
> Thread thread = new Thread () {
> public void run() {
> //get dbObject display in this editor
> DBObject editorObj = ListSection.editorInput;
> //get the elements to set in the table
> Object[] elements = ((TableContentProvider)collectionViewer.
> getContentProvider()).getElements(editorObj);
> for (int i=0; i< elements.length; i++){
> final DBObject dbObj = (DBObject)elements[i];
> display.syncExec(new Runnable() {
> public void run() {
> collectionViewer.add(dbObj);
> collectionViewer.refresh();
> }
> });
> }
> };
> };
> thread.start();
> Thanks for your answer,
> Petra
> Joerg von Frantzius wrote:
>> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>> <html>
>> <head>
>> <meta content="text/html;charset=ISO-8859-15"
>> http-equiv="Content-Type">
>> </head>
>> <body bgcolor="#ffffff" text="#000000">
>> Alright, nobody answered, which is good because it was entirely my
>> fault and not related to TableViewer at all... Please disregard.<br>
>> <br>
>> Joerg von Frantzius schrieb:
>> <blockquote cite="midcs8bpo$n7g$1@www.eclipse.org" type="cite">
>> <meta content="text/html;charset=ISO-8859-15"
>> http-equiv="Content-Type">
>> <title></title>
>> Hi,<br>
>> <br>
>> I'm trying to do pretty much the same as demonstrated in a <a
>>
>
href=" http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet7.java?rev=HEAD&am p;content-type=text/vnd.viewcvs-markup">snippet
>> for SWT Table </a> only that I want to fill a TableViewer instead of an
>> SWT Table. My TableViewer has a LabelProvider and everything works fine
>> if I fill it synchronously using setInput() and a ContentProvider.
>> Using a separate Thread and TableViewer.add(), I got it so far as the
>> table's scroll bar becoming smaller and smaller due to new objects
>> being added, but it does not show the actual contents in the table,
>> only the scroll bar becomes smaller!<br>
>> <br>
>> This is what my Thread's run method looks like:<br>
>> <br>
>> public void run() {<br>
>> for (Iterator iter = kunstwerke.iterator();
>> iter.hasNext();) {<br>
>> final Kunstwerk kunstwerk = (Kunstwerk) iter.next();<br>
>> d.syncExec(new Runnable() {<br>
>> public void run() {<br>
>> tableViewer.add(kunstwerk);<br>
>> //tableViewer.refresh();<br>
>> }<br>
>> });<br>
>> }<br>
>> <br>
>> "kunstwerke" is a Set containing the objects to be displayed in the
>> table and Display "d" was determined using
>> Display.findDisplay(Thread.currentThread()) in the main thread. I can
>> see my LabelProvider being called and returning Strings for the table's
>> columns, but they are not painted. I tried calling refresh as in the
>> comment above, and tableViewer.update(kunstwerk,null); after the add,
>> but it didn't help.<br>
>> <br>
>> Does anybody haven an idea what the problem might be here? This is with
>> Eclipse 3.1 M4 on Windows XP.<br>
>> <br>
>> Thanks,<br>
>> Jörg.<br>
>> </blockquote>
>> <br>
>> </body>
>> </html>
|
|
| |
Goto Forum:
Current Time: Thu Sep 26 17:30:25 GMT 2024
Powered by FUDForum. Page generated in 0.04415 seconds
|