[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: 7 seconds for starting virtual tables

Thanks.

I will apply workaround.

R.


"Matthew Hall" <matthall@xxxxxxxxxxxxxxxxx> wrote in message 
news:fssat1$2ab$1@xxxxxxxxxxxxxxxxxxxx
>I can duplicate the delay in both 3.3 and 3.4M5 using the attached snippet.
>
> I get an 8-10 second delay if I set the item count *before* creating the
> first column.  If I the first column is created before setting the item
> count there is no delay.
>
> The delay only occurs with the first column.  I think this is because of
> the following section of code in Table.createItem(TableColumn, int):
>
> if ((parent.style & SWT.VIRTUAL) == 0) {
> LVITEM lvItem = new LVITEM ();
> lvItem.mask = OS.LVIF_TEXT | OS.LVIF_IMAGE;
> lvItem.pszText = OS.LPSTR_TEXTCALLBACK;
> lvItem.iImage = OS.I_IMAGECALLBACK;
> for (int i=0; i<itemCount; i++) {
> lvItem.iItem = i;
> OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
> }
> }
>
> I believe this should be:
>
> if ((style & SWT.VIRTUAL) == 0) {
>                      ^
>
> For now there is a reliable workaround: create at least one column
> before setting the item count.
>
> Matthew
>
> Robert B wrote:
>> It's taking time when the first column is added.
>> You may try with the following code. Basically that's my code.
>> I added displays and noticed that
>>   The "TableColumn tc = new TableColumn(table, SWT.NONE);" line
>> uses the time.
>>
>> ====================================================================
>> Table table = new Table(comp, SWT.VIRTUAL | SWT.BORDER |
>> SWT.FULL_SELECTION);
>> table.setItemCount(1000000);
>> table.setHeaderVisible(true);
>> table.setLinesVisible(true);
>>
>> // this line takes 7 seconds!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>> TableColumn tc = new TableColumn(table, SWT.NONE);
>> tc.setWidth(0);
>>
>> TableColumn tc1 = new TableColumn(table, SWT.NONE);
>>
>> // add columns.
>>
>> table.addListener (SWT.SetData, new Listener () {
>>   public void handleEvent (Event event) {
>>      TableItem item = (TableItem) event.item;
>>      int index = table.indexOf(item);
>>      String[] s = new String[2];
>>      s[1] = ""+index;
>>      item.setText(s);
>>   });
>>
>>
>>
>>
>>
>>
>> "Tom Schindl" <tom.schindl@xxxxxxxxxxxxxxx> wrote in message
>> news:fsro6t$d52$2@xxxxxxxxxxxxxxxxxxxx
>>> Please provide a small snippet to reproduce and people could take a look
>>> what's wrong with your implementation.
>>>
>>> Tom
>>>
>>> Robert B schrieb:
>>>> SWT 3.3 on Windows XP.
>>>>
>>>> R.
>>>>
>>>>
>>>> "Matthew Hall" <matthall@xxxxxxxxxxxxxxxxx> wrote in message
>>>> news:fsqunt$jfl$1@xxxxxxxxxxxxxxxxxxxx
>>>>> What version of SWT are you using?
>>>>>
>>>>> Matthew
>>>>>
>>>>> Robert B wrote:
>>>>>> Is there any other way for virtual table than this?
>>>>>> ==================================================================
>>>>>> Table table = new Table(comp, SWT.VIRTUAL | SWT.BORDER |
>>>>>> SWT.FULL_SELECTION);
>>>>>> table.setItemCount((int)dataset.rowcount);
>>>>>> table.setHeaderVisible(true);
>>>>>> table.setLinesVisible(true);
>>>>>> // add columns.
>>>>>>
>>>>>> table.addListener (SWT.SetData, new Listener () {
>>>>>>   public void handleEvent (Event event) {
>>>>>>      TableItem item = (TableItem) event.item;
>>>>>>      int index = table.indexOf(item);
>>>>>>      item.setText(dataset.getRecord(index));
>>>>>>   });
>>>>>> ===================================================================
>>>>>>
>>>>>> Data access is really fast as it uses direct and dynamic file
>>>>>> addressing. Once 7 mininutes is
>>>>>> spent for initializing, the rest is very fast. I mean scrolling 1
>>>>>> million records are no different
>>>>>> from scrolling 100 records! It's got to be something to with SWT or
>>>>>> Windows APIs.
>>>>>>
>>>>>> R.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> "Tom Schindl" <tom.schindl@xxxxxxxxxxxxxxx> wrote in message
>>>>>> news:fsijb6$14j$1@xxxxxxxxxxxxxxxxxxxx
>>>>>>> well it depends on how you load your data? Do you really do this
>>>>>>> lazily? If you are using JFace-Viewers you'll need to use a
>>>>>>> ILazyContentProvider?
>>>>>>>
>>>>>>> Tom
>>>>>>>
>>>>>>> Robert B schrieb:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I found that starting a new virtual table with 1 million rows
>>>>>>>> takes about 7 seconds. I don't know it should take
>>>>>>>> that long! It should not read more than a screenful of
>>>>>>>> data. Is it normal or ways to improve?
>>>>>>>>
>>>>>>>> R.
>>>>>>> -- 
>>>>>>> B e s t S o l u t i o n . at
>>>>>>> --------------------------------------------------------------------
>>>>>>> Tom Schindl                                          JFace-Committer
>>>>>>> -------------------------------------------------------------------- 
>>>>
>>>
>>> -- 
>>> B e s t S o l u t i o n . at
>>> --------------------------------------------------------------------
>>> Tom Schindl                                          JFace-Committer
>>> -------------------------------------------------------------------- 
>>
>>
>
>


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


> package snippet;
>
> import org.eclipse.jface.dialogs.InputDialog;
> import org.eclipse.jface.layout.GridDataFactory;
> import org.eclipse.jface.window.Window;
> import org.eclipse.jface.wizard.Wizard;
> import org.eclipse.jface.wizard.WizardDialog;
> import org.eclipse.jface.wizard.WizardPage;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.layout.RowLayout;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Event;
> import org.eclipse.swt.widgets.Label;
> import org.eclipse.swt.widgets.Listener;
> import org.eclipse.swt.widgets.Spinner;
> import org.eclipse.swt.widgets.Table;
> import org.eclipse.swt.widgets.TableColumn;
> import org.eclipse.swt.widgets.TableItem;
>
> public class SnippetVirtualTable {
>  static class VirtualTableWizardPage extends WizardPage {
>    private Table   table;
>    private Spinner itemCountSpinner;
>
>    public VirtualTableWizardPage() {
>      super( "virtualTable" );
>      setTitle( "Virtual table test" );
>      setDescription( "Use controls to manipulate virtual tree" );
>    }
>
>    public void createControl( Composite parent ) {
>      Composite composite = new Composite( parent, SWT.NONE );
>      composite.setLayout( new GridLayout() );
>      setControl( composite );
>
>      Composite buttonBar = new Composite( composite, SWT.NONE );
>      buttonBar.setLayout( new RowLayout( SWT.HORIZONTAL ) );
>      GridDataFactory.fillDefaults().grab( true, false ).applyTo( 
> buttonBar );
>
>      new Label( buttonBar, SWT.NONE ).setText( "Item count: " );
>
>      itemCountSpinner = new Spinner( buttonBar, SWT.BORDER );
>      itemCountSpinner.setMinimum( 0 );
>      itemCountSpinner.setMaximum( Integer.MAX_VALUE );
>      itemCountSpinner.setSelection( 1000000 );
>
>      Button setItemCount = new Button( buttonBar, SWT.PUSH );
>      setItemCount.setText( "Set item count" );
>      setItemCount.addListener( SWT.Selection, new Listener() {
>        public void handleEvent( Event event ) {
>          table.setItemCount( itemCountSpinner.getSelection() );
>        }
>      } );
>
>      Button addColumn = new Button( buttonBar, SWT.PUSH );
>      addColumn.setText( "Add column" );
>      addColumn.addListener( SWT.Selection, new Listener() {
>        public void handleEvent( Event event ) {
>          InputDialog dialog = new InputDialog( getShell(),
>                                                "Add table column",
>                                                "Enter table column name",
>                                                "",
>                                                null );
>          if ( dialog.open() == Window.OK ) {
>            String name = dialog.getValue();
>            TableColumn col = new TableColumn( table, SWT.NONE );
>            col.setText( name );
>            col.setWidth( 100 );
>          }
>        }
>      } );
>
>      table = new Table( composite, SWT.VIRTUAL | SWT.BORDER | 
> SWT.FULL_SELECTION );
>      GridDataFactory.fillDefaults().grab( true, true ).applyTo( table );
>      table.setHeaderVisible( true );
>      table.setLinesVisible( true );
>
>      table.addListener( SWT.SetData, new Listener() {
>        public void handleEvent( Event event ) {
>          TableItem item = (TableItem) event.item;
>          int index = table.indexOf( item );
>          String[] s = new String[table.getColumnCount()];
>          for ( int i = 0; i < s.length; i++ )
>            s[i] = "" + index + "," + i;
>          item.setText( s );
>        }
>      } );
>    }
>  }
>
>  public static void main( String[] args ) {
>    new Display();
>    Wizard wizard = new Wizard() {
>      @Override
>      public void addPages() {
>        addPage( new VirtualTableWizardPage() );
>      }
>
>      @Override
>      public boolean performFinish() {
>        return true;
>      }
>    };
>    WizardDialog dialog = new WizardDialog( null, wizard );
>    dialog.open();
>  }
> }
>