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 346458 | Differences between
and this patch

Collapse All | Expand All

(-)js/org/eclipse/rwt/widgets/Tree.js (-15 / +25 lines)
Lines 557-576 Link Here
557
        }
557
        }
558
      }
558
      }
559
      if( event.getData() === "remove" ) {
559
      if( event.getData() === "remove" ) {
560
        var oldItem = event.getRelatedTarget();
560
        this._topItem = null;
561
        this._deselectItem( oldItem, false );
561
        this.addToQueue( "checkDisposedItems" );
562
        if( this._topItem === oldItem ) {
563
          this._topItem = null;
564
        }
565
        if( this._leadItem === oldItem ) {
566
          this._leadItem = null;
567
        }
568
        if( this._focusItem === oldItem ) {
569
          this._focusItem = null;
570
        }
571
        if( this._hoverItem === oldItem ) {
572
          this._hoverItem = null;
573
        }
574
      }
562
      }
575
      this._sendItemChange( item, event );
563
      this._sendItemChange( item, event );
576
      this._renderItemChange( item, event );
564
      this._renderItemChange( item, event );
Lines 901-906 Link Here
901
889
902
    _layoutPost : function( changes ) {
890
    _layoutPost : function( changes ) {
903
      this.base( arguments, changes );
891
      this.base( arguments, changes );
892
      if( changes[ "checkDisposedItems" ] ) {
893
        this._checkDisposedItems();
894
      }
904
      if( changes[ "scrollHeight" ] ) {
895
      if( changes[ "scrollHeight" ] ) {
905
        this._updateScrollHeight();
896
        this._updateScrollHeight();
906
      }
897
      }
Lines 1317-1323 Link Here
1317
      this._scheduleUpdate();
1308
      this._scheduleUpdate();
1318
    },
1309
    },
1319
1310
1320
    
1311
    _checkDisposedItems : function() {
1312
      if( this._focusItem && this._focusItem.isDisposed() ) {
1313
        this._focusItem = null;
1314
      }
1315
      if( this._hoverItem && this._hoverItem.isDisposed() ) {
1316
        this._hoverItem = null;
1317
      }
1318
      if( this._leadItem && this._leadItem.isDisposed() ) {
1319
        this._leadItem = null;
1320
      }
1321
      var i = 0;
1322
      while( i < this._selection.length ) {
1323
        if( this._selection[ i ].isDisposed() ) {
1324
          this._deselectItem( this._selection[ i ], false );
1325
        } else {
1326
          i++;
1327
        }
1328
      }
1329
    },
1330
1321
    ////////////////////////////
1331
    ////////////////////////////
1322
    // internal layout & theming
1332
    // internal layout & theming
1323
    
1333
    
(-)js/org/eclipse/rwt/test/tests/TreeTest.js (-4 / +41 lines)
Lines 3192-3201 Link Here
3192
      assertEquals( child0, tree._hoverItem )
3192
      assertEquals( child0, tree._hoverItem )
3193
      assertEquals( [ child0 ], tree._selection );
3193
      assertEquals( [ child0 ], tree._selection );
3194
      child0.dispose();
3194
      child0.dispose();
3195
      assertNull( tree._topItem )
3195
      testUtil.flush();
3196
      assertNull( tree._focusItem )
3196
      assertNull( tree._focusItem );
3197
      assertNull( tree._leadItem )
3197
      assertNull( tree._leadItem );
3198
      assertNull( tree._hoverItem )
3198
      assertNull( tree._hoverItem );
3199
      assertEquals( [], tree._selection );
3200
      tree.destroy();
3201
    },
3202
    
3203
    testRemoveInderectlyDisposedItemFromState : function() {
3204
      var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
3205
      var wm = org.eclipse.swt.WidgetManager.getInstance();
3206
      var tree = this._createDefaultTree();
3207
      tree.setHasMultiSelection( true );
3208
      tree.setHeight( 15 );
3209
      tree.setItemHeight( 20 );
3210
      tree.setItemCount( 1 );
3211
      var child0 = new org.eclipse.rwt.widgets.TreeItem( tree.getRootItem(), 0 );
3212
      child0.setItemCount( 1 );
3213
      var child1 = new org.eclipse.rwt.widgets.TreeItem( child0, 0 );
3214
      child1.setTexts( [ "C1" ] );
3215
      child0.setExpanded( true );
3216
      tree.setTopItemIndex( 1 );
3217
      tree.setFocusItem( child1 );
3218
      testUtil.flush();      
3219
      assertEquals( child1, tree._topItem )
3220
      testUtil.mouseOver( tree._clientArea._children[ 0 ] );
3221
      testUtil.shiftClick( tree._clientArea._children[ 0 ] );
3222
      assertEquals( child1, tree._focusItem );
3223
      assertEquals( [ child1 ], tree._selection );
3224
      assertEquals( child1, tree._leadItem );
3225
      child0.dispose(); // Order is important for this test
3226
      child1.dispose();
3227
      var child0new = new org.eclipse.rwt.widgets.TreeItem( tree.getRootItem(), 0 );
3228
      child0new.setItemCount( 1 );
3229
      var child1new = new org.eclipse.rwt.widgets.TreeItem( child0new, 0 );
3230
      child1new.setTexts( [ "C1new" ] );
3231
      child0new.setExpanded( true );
3232
      testUtil.flush();
3233
      assertEquals( child1new, tree._topItem );
3234
      assertNull( tree._leadItem );
3235
      assertNull( tree._focusItem );
3199
      assertEquals( [], tree._selection );
3236
      assertEquals( [], tree._selection );
3200
      tree.destroy();
3237
      tree.destroy();
3201
    },
3238
    },

Return to bug 346458