Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 278193
Collapse All | Expand All

(-)src/org/eclipse/swt/widgets/Table_Test.java (-2 / +15 lines)
Lines 251-256 Link Here
251
      table.getItem( 3 ).dispose();
251
      table.getItem( 3 ).dispose();
252
    }
252
    }
253
    assertEquals( 0, table.getTopIndex() );
253
    assertEquals( 0, table.getTopIndex() );
254
255
    // Ensure that topIndex is adjusted if it is bigger than item count
256
    table.removeAll();
257
    for( int i = 0; i < 20; i++ ) {
258
      new TableItem( table, SWT.NONE );
259
    }
260
    table.setTopIndex( 14 );
261
    for( int i = 10; i < 20; i++ ) {
262
      table.getItem( 10 ).dispose();
263
    }
264
    int itemCount = table.getItemCount();
265
    int visibleItemCount = table.getVisibleItemCount( false );
266
    assertEquals( itemCount - visibleItemCount - 1, table.getTopIndex() );
254
  }
267
  }
255
268
256
  public void testDispose() {
269
  public void testDispose() {
Lines 1429-1435 Link Here
1429
    assertEquals( 0, table.getColumnOrder()[ 0 ] );
1442
    assertEquals( 0, table.getColumnOrder()[ 0 ] );
1430
    assertEquals( 1, table.getColumnOrder()[ 1 ] );
1443
    assertEquals( 1, table.getColumnOrder()[ 1 ] );
1431
  }
1444
  }
1432
  
1445
1433
  public void testRedrawAfterDisposeVirtual() {
1446
  public void testRedrawAfterDisposeVirtual() {
1434
    RWTFixture.fakePhase( PhaseId.PROCESS_ACTION );
1447
    RWTFixture.fakePhase( PhaseId.PROCESS_ACTION );
1435
    Display display = new Display();
1448
    Display display = new Display();
Lines 1437-1443 Link Here
1437
    Table table = new Table( shell, SWT.VIRTUAL );
1450
    Table table = new Table( shell, SWT.VIRTUAL );
1438
    table.setSize( 100, 100 );
1451
    table.setSize( 100, 100 );
1439
    table.setItemCount( 150 );
1452
    table.setItemCount( 150 );
1440
    // dispose the first item, this must cause a "redraw" which in turn triggers 
1453
    // dispose the first item, this must cause a "redraw" which in turn triggers
1441
    // a SetData event to populate the newly appeared item at the bottom of the
1454
    // a SetData event to populate the newly appeared item at the bottom of the
1442
    // table
1455
    // table
1443
    table.getItem( 0 ).dispose();
1456
    table.getItem( 0 ).dispose();
(-)src/org/eclipse/swt/widgets/Table.java (-6 / +3 lines)
Lines 2345-2356 Link Here
2345
  }
2345
  }
2346
2346
2347
  private void adjustTopIndex() {
2347
  private void adjustTopIndex() {
2348
    if( topIndex > itemCount - 1 ) {
2348
    int visibleItemCount = getVisibleItemCount( false );
2349
      if( needsVScrollBar() ) {
2349
    if( topIndex > itemCount - visibleItemCount - 1 ) {
2350
        topIndex = Math.max( 0, itemCount - 1 );
2350
      topIndex = Math.max( 0, itemCount - visibleItemCount - 1 );
2351
      } else {
2352
        topIndex = 0;
2353
      }
2354
    }
2351
    }
2355
  }
2352
  }
2356
2353

Return to bug 278193