Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Tree really slow in IE7
Tree really slow in IE7 [message #86991] Tue, 13 May 2008 16:08 Go to next message
Torge Kummerow is currently offline Torge KummerowFriend
Messages: 26
Registered: July 2009
Junior Member
Hi all,

I tried to implement a tree with 5 coulumns. It has roughly 100 root
elements and each of it has ~5 subelements. Since in most cases the tree
needs to be expanded completely I didn´t use a content provider.

In firefox this works quite fine, but in IE7 the memory starts to explode
and the timout gets hit, asking if I want to kill the javascript.

To test if I really didn´t had something else slowing down I reduced the
core to this:

private void refreshTable() {
tree.removeAll();

for (int i=0; i<100; i++) {
TreeItem tiParent = new TreeItem(tree, SWT.NONE);
tiParent.setText("ParentItem Number "+i+" All Right!!");

for (int j=0;j<5;j++) {
TreeItem ti = new TreeItem(tiParent, SWT.NONE);
ti.setText(new String[]{"Child Item number "+j, "Propertiy 1",
"Property 2", "Property 3", "Property 4"});
}

}

}

It still hits the timeout (on a X2 6000+ 4GB RAM system!)

Since I can´t influence the used Browser (in a corporation) this means
really trouble for my code.

Any help?

Greetings,
Torge.
Re: Tree really slow in IE7 [message #87021 is a reply to message #86991] Tue, 13 May 2008 19:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: evolanakis.innoopract.com

This is a multi-part message in MIME format.
--------------050000030909010702010604
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi Torge,

the code you posted disposes and recreates every tree item in the tree.
This is quite an expensive operation since a big part of the work
happens on the browser side. In my experiments (see attached example),
letting a TreeViewer manage the TreeItems was more efficient.

Hope this helps.

Kind regards,
Elias.

---
Elias Volanakis
Innoopract, Inc.
http://www.innoopract.com


Torge Kummerow wrote:
> Hi all,
>
> I tried to implement a tree with 5 coulumns. It has roughly 100 root
> elements and each of it has ~5 subelements. Since in most cases the tree
> needs to be expanded completely I didn
Re: Tree really slow in IE7 [message #87212 is a reply to message #87021] Wed, 14 May 2008 14:08 Go to previous messageGo to next message
Torge Kummerow is currently offline Torge KummerowFriend
Messages: 26
Registered: July 2009
Junior Member
Well, thanks for the fast reply. I will try it, even though it means a lot
of rewriting for my code.
I Hope it will help. Even though I doubt it. It will be faster in
representing the root elements for sure. But will it be any faster if I
expand all nodes?
I will let you know the result.

Greetings,
Torge.

"Elias Volanakis" <evolanakis@innoopract.com> schrieb im Newsbeitrag
news:g0cram$slh$1@build.eclipse.org...
> Hi Torge,
>
> the code you posted disposes and recreates every tree item in the tree.
> This is quite an expensive operation since a big part of the work
> happens on the browser side. In my experiments (see attached example),
> letting a TreeViewer manage the TreeItems was more efficient.
>
> Hope this helps.
>
> Kind regards,
> Elias.
>
> ---
> Elias Volanakis
> Innoopract, Inc.
> http://www.innoopract.com
>
>
> Torge Kummerow wrote:
>> Hi all,
>>
>> I tried to implement a tree with 5 coulumns. It has roughly 100 root
>> elements and each of it has ~5 subelements. Since in most cases the tree
>> needs to be expanded completely I didn´t use a content provider.
>>
>> In firefox this works quite fine, but in IE7 the memory starts to
>> explode and the timout gets hit, asking if I want to kill the javascript.
>>
>> To test if I really didn´t had something else slowing down I reduced the
>> core to this:
>>
>> private void refreshTable() {
>> tree.removeAll();
>>
>> for (int i=0; i<100; i++) {
>> TreeItem tiParent = new TreeItem(tree, SWT.NONE);
>> tiParent.setText("ParentItem Number "+i+" All Right!!");
>>
>> for (int j=0;j<5;j++) {
>> TreeItem ti = new TreeItem(tiParent, SWT.NONE);
>> ti.setText(new String[]{"Child Item number "+j, "Propertiy 1",
>> "Property 2", "Property 3", "Property 4"});
>> }
>>
>> }
>>
>> }
>>
>> It still hits the timeout (on a X2 6000+ 4GB RAM system!)
>>
>> Since I can´t influence the used Browser (in a corporation) this means
>> really trouble for my code.
>>
>> Any help?
>>
>> Greetings,
>> Torge.
>
>


------------------------------------------------------------ --------------------


> /*********************************************************** ********************
> * Copyright (c) 2008 Innoopract Informationssysteme GmbH.
> * All rights reserved. This program and the accompanying materials
> * are made available under the terms of the Eclipse Public License v1.0
> * which accompanies this distribution, and is available at
> * http://www.eclipse.org/legal/epl-v10.html
> *
> * Contributors:
> * Innoopract Informationssysteme GmbH - initial API and implementation
> ************************************************************ ******************/
> package rap.example2;
>
> import java.util.ArrayList;
> import java.util.List;
>
> import org.eclipse.jface.dialogs.MessageDialog;
> import org.eclipse.jface.viewers.ITreeContentProvider;
> import org.eclipse.jface.viewers.LabelProvider;
> import org.eclipse.jface.viewers.TreeViewer;
> import org.eclipse.jface.viewers.Viewer;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.events.SelectionAdapter;
> import org.eclipse.swt.events.SelectionEvent;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Tree;
> import org.eclipse.ui.part.ViewPart;
>
> public class View extends ViewPart {
> public static final String ID = "rap.example2.view";
>
> /**
> * This is a callback that will allow us to create the viewer and
> initialize
> * it.
> */
> public void createPartControl(Composite parent) {
> final Tree tree = new Tree(parent, SWT.MULTI | SWT.BORDER);
> parent.setLayout(new FillLayout());
>
> final TreeViewer viewer = new TreeViewer(tree);
> viewer.setLabelProvider( new LabelProvider() );
> viewer.setContentProvider( new NodeContentProvider() );
> viewer.setInput( new Object[0] );
>
> Button b = new Button( parent, SWT.PUSH );
> b.setText("Refresh");
> b.addSelectionListener( new SelectionAdapter() {
> @Override
> public void widgetSelected( SelectionEvent e ) {
> long now = System.currentTimeMillis();
> // tree.setRedraw( false ); // this only makes sense in RCP
> viewer.setInput( createInput() );
> // tree.setRedraw( true ); // this only makes sense in RCP
> MessageDialog.openInformation( tree.getShell(), "huhu", "done");
> System.err.println("Approx. ELAPSED: " +
> (System.currentTimeMillis() - now));
> }
> });
>
> Button b2 = new Button( parent, SWT.PUSH );
> b2.setText( "Expand All" );
> b2.addSelectionListener( new SelectionAdapter() {
> @Override
> public void widgetSelected( SelectionEvent e ) {
> viewer.expandAll();
> }
> });
> }
>
> public void setFocus() {
> }
>
>
> // helping methods
> //////////////////
>
> private long iCount = 0;
>
> private Object[] createInput() {
> List<Object> nodes = new ArrayList<Object>();
> for (int i=0; i<100; i++) {
> Node node = new Node("ParentItem Number "+iCount+" All Right!!");
> iCount++;
> for (int j=0;j<5;j++) {
> Node child = new Node("Child Item number "+j);
> node.addChild( child );
> }
> nodes.add( node );
> }
> return nodes.toArray();
> }
>
> // helping classes
> //////////////////
>
> private static class NodeContentProvider implements ITreeContentProvider
> {
>
> public Object[] getChildren( Object parentElement ) {
> return ((Node) parentElement).getChildren();
> }
>
> public Object getParent( Object element ) {
> // unused
> return null;
> }
>
> public boolean hasChildren( Object element ) {
> return ((Node)element).hasChildren();
> }
>
> public Object[] getElements( Object inputElement ) {
> return ( Object[] )inputElement;
> }
>
> public void dispose() {
> // unused
> }
>
> public void inputChanged( Viewer viewer, Object oldInput, Object
> newInput )
> {
> // unused
> }
>
> }
>
> private static class Node {
> private String text;
> private List<Node> children;
>
> Node(String text) {
> this.text = text;
> }
>
> void addChild(Node node) {
> if(children == null) {
> children = new ArrayList<Node>();
> }
> children.add(node);
> }
>
> Node[] getChildren() {
> if(children == null) {
> return new Node[0];
> }
> return children.toArray(new Node[children.size()]);
> }
>
> boolean hasChildren() {
> return children == null ? false : !children.isEmpty();
> }
>
> public String toString() {
> return text;
> }
> }
>
> }
Re: Tree really slow in IE7 [message #87324 is a reply to message #87212] Wed, 14 May 2008 16:57 Go to previous message
Eclipse UserFriend
Originally posted by: evolanakis.innoopract.com

Torge,

your 've got a good point: Adding a viewer.expandAll() after the
viewer.setInput(...) in my example will slow it down to about 20s and I
get the "JavaScript takes too long" dialog.

I'll experiment a bit further...

Regards,
Elias.


Torge Kummerow wrote:
> Well, thanks for the fast reply. I will try it, even though it means a
> lot of rewriting for my code.
> I Hope it will help. Even though I doubt it. It will be faster in
> representing the root elements for sure. But will it be any faster if I
> expand all nodes?
> I will let you know the result.
>
> Greetings,
> Torge.
>
> "Elias Volanakis" <evolanakis@innoopract.com> schrieb im Newsbeitrag
> news:g0cram$slh$1@build.eclipse.org...
>> Hi Torge,
>>
>> the code you posted disposes and recreates every tree item in the tree.
>> This is quite an expensive operation since a big part of the work
>> happens on the browser side. In my experiments (see attached example),
>> letting a TreeViewer manage the TreeItems was more efficient.
>>
>> Hope this helps.
>>
>> Kind regards,
>> Elias.
>>
>> ---
>> Elias Volanakis
>> Innoopract, Inc.
>> http://www.innoopract.com
>>
>>
>> Torge Kummerow wrote:
>>> Hi all,
>>>
>>> I tried to implement a tree with 5 coulumns. It has roughly 100 root
>>> elements and each of it has ~5 subelements. Since in most cases the tree
>>> needs to be expanded completely I didn´t use a content provider.
>>>
>>> In firefox this works quite fine, but in IE7 the memory starts to
>>> explode and the timout gets hit, asking if I want to kill the
>>> javascript.
>>>
>>> To test if I really didn´t had something else slowing down I reduced the
>>> core to this:
>>>
>>> private void refreshTable() {
>>> tree.removeAll();
>>>
>>> for (int i=0; i<100; i++) {
>>> TreeItem tiParent = new TreeItem(tree, SWT.NONE);
>>> tiParent.setText("ParentItem Number "+i+" All Right!!");
>>>
>>> for (int j=0;j<5;j++) {
>>> TreeItem ti = new TreeItem(tiParent, SWT.NONE);
>>> ti.setText(new String[]{"Child Item number "+j, "Propertiy 1",
>>> "Property 2", "Property 3", "Property 4"});
>>> }
>>>
>>> }
>>>
>>> }
>>>
>>> It still hits the timeout (on a X2 6000+ 4GB RAM system!)
>>>
>>> Since I can´t influence the used Browser (in a corporation) this means
>>> really trouble for my code.
>>>
>>> Any help?
>>>
>>> Greetings,
>>> Torge.
>>
>>
>
>
> ------------------------------------------------------------ --------------------
>
>
>
>> /*********************************************************** ********************
>>
>> * Copyright (c) 2008 Innoopract Informationssysteme GmbH.
>> * All rights reserved. This program and the accompanying materials
>> * are made available under the terms of the Eclipse Public License v1.0
>> * which accompanies this distribution, and is available at
>> * http://www.eclipse.org/legal/epl-v10.html
>> *
>> * Contributors:
>> * Innoopract Informationssysteme GmbH - initial API and
>> implementation
>> ************************************************************ ******************/
>>
>> package rap.example2;
>>
>> import java.util.ArrayList;
>> import java.util.List;
>>
>> import org.eclipse.jface.dialogs.MessageDialog;
>> import org.eclipse.jface.viewers.ITreeContentProvider;
>> import org.eclipse.jface.viewers.LabelProvider;
>> import org.eclipse.jface.viewers.TreeViewer;
>> import org.eclipse.jface.viewers.Viewer;
>> import org.eclipse.swt.SWT;
>> import org.eclipse.swt.events.SelectionAdapter;
>> import org.eclipse.swt.events.SelectionEvent;
>> import org.eclipse.swt.layout.FillLayout;
>> import org.eclipse.swt.widgets.Button;
>> import org.eclipse.swt.widgets.Composite;
>> import org.eclipse.swt.widgets.Tree;
>> import org.eclipse.ui.part.ViewPart;
>>
>> public class View extends ViewPart {
>> public static final String ID = "rap.example2.view";
>>
>> /**
>> * This is a callback that will allow us to create the viewer and
>> initialize
>> * it.
>> */
>> public void createPartControl(Composite parent) {
>> final Tree tree = new Tree(parent, SWT.MULTI | SWT.BORDER);
>> parent.setLayout(new FillLayout());
>>
>> final TreeViewer viewer = new TreeViewer(tree);
>> viewer.setLabelProvider( new LabelProvider() );
>> viewer.setContentProvider( new NodeContentProvider() );
>> viewer.setInput( new Object[0] );
>>
>> Button b = new Button( parent, SWT.PUSH );
>> b.setText("Refresh");
>> b.addSelectionListener( new SelectionAdapter() {
>> @Override
>> public void widgetSelected( SelectionEvent e ) {
>> long now = System.currentTimeMillis();
>> // tree.setRedraw( false ); // this only makes sense in RCP
>> viewer.setInput( createInput() );
>> // tree.setRedraw( true ); // this only makes sense in RCP
>> MessageDialog.openInformation( tree.getShell(), "huhu", "done");
>> System.err.println("Approx. ELAPSED: " +
>> (System.currentTimeMillis() - now));
>> }
>> });
>>
>> Button b2 = new Button( parent, SWT.PUSH );
>> b2.setText( "Expand All" );
>> b2.addSelectionListener( new SelectionAdapter() {
>> @Override
>> public void widgetSelected( SelectionEvent e ) {
>> viewer.expandAll();
>> }
>> });
>> }
>>
>> public void setFocus() {
>> }
>>
>>
>> // helping methods
>> //////////////////
>>
>> private long iCount = 0;
>>
>> private Object[] createInput() {
>> List<Object> nodes = new ArrayList<Object>();
>> for (int i=0; i<100; i++) {
>> Node node = new Node("ParentItem Number "+iCount+" All Right!!");
>> iCount++;
>> for (int j=0;j<5;j++) {
>> Node child = new Node("Child Item number "+j);
>> node.addChild( child );
>> }
>> nodes.add( node );
>> }
>> return nodes.toArray();
>> }
>>
>> // helping classes
>> //////////////////
>>
>> private static class NodeContentProvider implements
>> ITreeContentProvider {
>>
>> public Object[] getChildren( Object parentElement ) {
>> return ((Node) parentElement).getChildren();
>> }
>>
>> public Object getParent( Object element ) {
>> // unused
>> return null;
>> }
>>
>> public boolean hasChildren( Object element ) {
>> return ((Node)element).hasChildren();
>> }
>>
>> public Object[] getElements( Object inputElement ) {
>> return ( Object[] )inputElement;
>> }
>>
>> public void dispose() {
>> // unused
>> }
>>
>> public void inputChanged( Viewer viewer, Object oldInput, Object
>> newInput )
>> {
>> // unused
>> }
>>
>> }
>>
>> private static class Node {
>> private String text;
>> private List<Node> children;
>>
>> Node(String text) {
>> this.text = text;
>> }
>>
>> void addChild(Node node) {
>> if(children == null) {
>> children = new ArrayList<Node>();
>> }
>> children.add(node);
>> }
>>
>> Node[] getChildren() {
>> if(children == null) {
>> return new Node[0];
>> }
>> return children.toArray(new Node[children.size()]);
>> }
>>
>> boolean hasChildren() {
>> return children == null ? false : !children.isEmpty();
>> }
>>
>> public String toString() {
>> return text;
>> }
>> }
>>
>> }
>


---
Elias Volanakis
Innoopract, Inc.
http://www.innoopract.com
Previous Topic:Image
Next Topic:can I handle cursor keys?
Goto Forum:
  


Current Time: Thu Sep 19 06:13:43 GMT 2024

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

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

Back to the top