Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Any efficient way to display a huge amount of items?
Any efficient way to display a huge amount of items? [message #318005] Wed, 18 July 2007 10:29 Go to next message
Eclipse UserFriend
Originally posted by: ku_long.hotmail.com

Hey,

I am trying to create a eclipse view to display memory information
when our projects are running. It turned out that I always have about
50 thousands (even more) items to display. For some reason, I am not
supposed to follow the eclipse tradition, e.g. just display a default
number of items first and let user to set filter. I am asked to display
them all. We have a similar tools which was developed using general
java awt and swing lib. It displays all the itms in a table, and seems
not too slow (e.g. for 50 thousands item, it takes 5-6 seconds to display).
But when I try to use a TreeView wieh contain provider and label provider
to display them, it takes me about 1 minute or more to display the whole
bunch of items. Is there any other way that can handle this kind of
huge amount of items?

Thanks.
Re: Any efficient way to display a huge amount of items? [message #318006 is a reply to message #318005] Wed, 18 July 2007 10:47 Go to previous messageGo to next message
Eclipse UserFriend
Raymond wrote:
> Hey,
>
> I am trying to create a eclipse view to display memory information
> when our projects are running. It turned out that I always have about 50
> thousands (even more) items to display. For some reason, I am not
> supposed to follow the eclipse tradition, e.g. just display a default
> number of items first and let user to set filter. I am asked to display
> them all. We have a similar tools which was developed using general
> java awt and swing lib. It displays all the itms in a table, and seems
> not too slow (e.g. for 50 thousands item, it takes 5-6 seconds to display).
> But when I try to use a TreeView wieh contain provider and label provider
> to display them, it takes me about 1 minute or more to display the whole
> bunch of items. Is there any other way that can handle this kind of
> huge amount of items?

I think you want the SWT.VIRTUAL flag and the ILazyTreeContentProvider
(3.2) or ILazyTreePathContentProvider (3.3). I've never used them so I
don't know if the 3.3's recommended over the other, but anyway.

Regards,
Rem
Re: Any efficient way to display a huge amount of items? [message #318012 is a reply to message #318006] Wed, 18 July 2007 11:57 Go to previous messageGo to next message
Eclipse UserFriend
Well Remy is right but Raymond talks about Tables:

-http://wiki.eclipse.org/index.php/JFaceSnippets#Snippet029V irtualTableViewer
-http://wiki.eclipse.org/index.php/JFaceSnippets#Snippet030V irtualLazyTableViewer
-http://wiki.eclipse.org/index.php/JFaceSnippets#Snippet041T ableViewerAlternatingColors

You have the choice between the normal content provider and the lazy
one. The advantage when using the normal content provider is that you
can use sorting and filtering APIs from JFace.

Tom

Remy Chi Jian Suen schrieb:
> Raymond wrote:
>> Hey,
>>
>> I am trying to create a eclipse view to display memory information
>> when our projects are running. It turned out that I always have about
>> 50 thousands (even more) items to display. For some reason, I am not
>> supposed to follow the eclipse tradition, e.g. just display a default
>> number of items first and let user to set filter. I am asked to display
>> them all. We have a similar tools which was developed using general
>> java awt and swing lib. It displays all the itms in a table, and seems
>> not too slow (e.g. for 50 thousands item, it takes 5-6 seconds to
>> display).
>> But when I try to use a TreeView wieh contain provider and label provider
>> to display them, it takes me about 1 minute or more to display the whole
>> bunch of items. Is there any other way that can handle this kind of
>> huge amount of items?
>
> I think you want the SWT.VIRTUAL flag and the ILazyTreeContentProvider
> (3.2) or ILazyTreePathContentProvider (3.3). I've never used them so I
> don't know if the 3.3's recommended over the other, but anyway.
>
> Regards,
> Rem


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Any efficient way to display a huge amount of items? [message #318015 is a reply to message #318012] Wed, 18 July 2007 12:51 Go to previous messageGo to next message
Eclipse UserFriend
Tom Schindl wrote:
> Well Remy is right but Raymond talks about Tables:

I see he mentioned table for awt/swing but then brought up TreeView. I'm
not sure which one you're going to implement on the JFace side, Raymond,
but anyway, as Tom has pointed out, both TableViewers and TreeViewers
supports the SWT.VIRTUAL style bit.

Regards,
Rem
Re: Any efficient way to display a huge amount of items? [message #318017 is a reply to message #318015] Wed, 18 July 2007 13:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ku_long.hotmail.com

Ok, I will check it out. Actually I am going to use
TreeView. I mentioned table because in our old tools,
it was implemented ussing awt/swing.
BTW, does you guys mean that if I am going to use the
lazy contain provider, I can not do sorting and filting
anymore?
Re: Any efficient way to display a huge amount of items? [message #318019 is a reply to message #318017] Wed, 18 July 2007 13:52 Go to previous messageGo to next message
Eclipse UserFriend
Raymond schrieb:
> Ok, I will check it out. Actually I am going to use
> TreeView. I mentioned table because in our old tools,
> it was implemented ussing awt/swing. BTW, does you guys mean that if I
> am going to use the
> lazy contain provider, I can not do sorting and filting
> anymore?
>

No you can't because to do sorting and filtering the whole dataset has
to be loaded. Currently only TableViewer (since 3.3) with the
VIRTUAL-Bit and a normal content provider can do sorting and filtering.

If you do it your own you need to implement it yourself in the content
provider.

Tom

--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Any efficient way to display a huge amount of items? [message #318025 is a reply to message #318019] Wed, 18 July 2007 16:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ku_long.hotmail.com

Hey,
I tried to design a simple program to see how to use
ILazyTreeContainProvider, but it seems it stuck on the
Tree.setItemCount(int) for a long time when I set the
number of item as a big number such as 50000; and also
got an out a java.lang.StackOverflowError when the UI
was displayed(actually the UI was no displayed due to
the exception). I attach my test code as following, anyone
can point out what's wrong with it? It should pass the
compile if you have necessory eclipse libs included.
(Name of the test java file is: TreeViewTest.java)

Thanks.




/***************************************************
* My test code
****************************************************/
import java.util.ArrayList;
import java.util.List;

import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ILazyContentProvider;
import org.eclipse.jface.viewers.ILazyTreeContentProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;

public class TreeViewTest {
TreeViewer _viewer;

class MyContentProvider implements ILazyTreeContentProvider{
private TreeViewer _myViewer;
private Object[] _models;

public MyContentProvider(TreeViewer viewer){
_myViewer = viewer;
}
@Override
public Object getParent(Object element) {
// TODO Auto-generated method stub
return null;
}

@Override
public void updateChildCount(Object element, int currentChildCount) {
// TODO Auto-generated method stub

}

@Override
public void updateElement(Object parent, int index) {
_myViewer.replace(parent, index, _models[index]);
}

@Override
public void dispose() {
// TODO Auto-generated method stub

}

@Override
public void inputChanged(Viewer viewer, Object oldInput, Object
newInput) {
if (newInput == null)
_models = new Object[0];
else
_models = ((List)newInput).toArray();
}

}

/**
* Label provider of objects tree view.
*/
class MyLabelProvider implements ITableLabelProvider {
/**
* (no java doc)
* @see ITableLabelProvider#getColumnImage(Object, int)
*/
public Image getColumnImage(Object element, int columnIndex) {
return null;
}

/**
* (no java doc)
* @see ITableLabelProvider#getColumnText(Object, int)
*/
public String getColumnText(Object element, int columnIndex) {
MyModel model = (MyModel)element;
// System.out.println(element.toString() + " ColumnIndex: " +
columnIndex);
switch (columnIndex){
case 0:
return model.getName();
case 1:
return model.getType();
case 2:
return model.getComments();
default:
return "";
}
}

/**
* (no java doc)
* @see IBaseLabelProvider#addListener(ILabelProviderListener)
*/
public void addListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub

}

/**
* (no java doc)
* @see IBaseLabelProvider#dispose()
*/
public void dispose() {
// TODO Auto-generated method stub

}

/**
* (no java doc)
* @see IBaseLabelProvider#isLabelProperty(Object, String)
*/
public boolean isLabelProperty(Object element, String property) {
// TODO Auto-generated method stub
return false;
}

/**
* (no java doc)
* @see IBaseLabelProvider#removeListener(ILabelProviderListener)
*/
public void removeListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub

}
}

class MyModel {
public int counter;
private String type;
private String comments = "hello";

public MyModel(int counter) {
this.counter = counter;
}

public String getType(){
return counter % 2 == 0?"male":"female";
}
public String getName() {
return "Item " + this.counter;
}
public String getComments(){
return comments;
}
}

public TreeViewTest(Shell shell) {
shell.setText("TreeView Test");
// final TableViewer v = new TableViewer(shell, SWT.VIRTUAL);
_viewer = new TreeViewer(shell, SWT.VIRTUAL);
Tree tree = _viewer.getTree();
TreeColumn column1 = new TreeColumn(tree, SWT.CENTER);
column1.setText("Name");
column1.pack();
TreeColumn column2 = new TreeColumn(tree, SWT.CENTER);
column2.setText("Type");
column2.pack();
TreeColumn column3 = new TreeColumn(tree, SWT.CENTER);
column3.setText("Comments");
column3.pack();
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
_viewer.setLabelProvider(new MyLabelProvider());
_viewer.setContentProvider(new MyContentProvider(_viewer));
List model = createModel();
long start = System.currentTimeMillis();
_viewer.setInput(model);
System.out.println("Used " + (System.currentTimeMillis() - start) + "
milliseconds to display");
start = System.currentTimeMillis();
tree.setItemCount(model.size());
System.out.println("Used " + (System.currentTimeMillis() - start) + "
milliseconds to set size");
}

private List createModel() {
List list = new ArrayList();

for (int i = 0; i < 10000; i++) {
list.add(new MyModel(i));
}

return list;
}

/**
* @param args
*/
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
new TreeViewTest(shell);
shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}

display.dispose();

}

}
Re: Any efficient way to display a huge amount of items? [message #318028 is a reply to message #318025] Wed, 18 July 2007 17:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ku_long.hotmail.com

I created another program which used TableViewer to display
50000 items (the same data model as I used in the previous
TreeView test code). It was realy fast to display 50000 items
in the table, just several seconds. Why their performances
are so different?

Thanks.
Re: Any efficient way to display a huge amount of items? [message #319488 is a reply to message #318028] Wed, 22 August 2007 14:58 Go to previous message
Eclipse UserFriend
Originally posted by: iboutbou.lehman.com

Raymond, do you have any update since last month ?

I faced similar issues, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=200214

Thanks
Previous Topic:Home made update site: NullPointerException when selecting feature
Next Topic:ant editor returns class cast exception
Goto Forum:
  


Current Time: Fri Nov 07 20:36:44 EST 2025

Powered by FUDForum. Page generated in 0.07493 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top