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 346222
Collapse All | Expand All

(-)js/org/eclipse/swt/widgets/Table.js (-4 / +11 lines)
Lines 1059-1064 Link Here
1059
      } else {
1059
      } else {
1060
        this._items[ index ] = item;
1060
        this._items[ index ] = item;
1061
      }
1061
      }
1062
      this._adjustSelectedIndices( index, true );
1062
      this._updateScrollHeight();
1063
      this._updateScrollHeight();
1063
    },
1064
    },
1064
1065
Lines 1070-1076 Link Here
1070
      }
1071
      }
1071
      // Order is crucial here: first deselect item then adjust indices
1072
      // Order is crucial here: first deselect item then adjust indices
1072
      this._deselectItem( itemIndex, false );
1073
      this._deselectItem( itemIndex, false );
1073
      this._adjustSelectedIndices( itemIndex );
1074
      this._adjustSelectedIndices( itemIndex, false );
1074
      this._updateScrollHeight();
1075
      this._updateScrollHeight();
1075
    },
1076
    },
1076
1077
Lines 1105-1115 Link Here
1105
      }
1106
      }
1106
    },
1107
    },
1107
1108
1108
    _adjustSelectedIndices : function( itemIndex ) {
1109
    _adjustSelectedIndices : function( itemIndex, increment ) {
1109
      for( var i = 0; i < this._selected.length; i++ ) {
1110
      for( var i = 0; i < this._selected.length; i++ ) {
1110
        var index = this._selected[ i ];
1111
        var index = this._selected[ i ];
1111
        if( itemIndex < index ) {
1112
        if( increment ) {
1112
          this._selected[ i ] = index - 1;
1113
          if( itemIndex <= index ) {
1114
            this._selected[ i ] = index + 1;
1115
          }
1116
        } else {
1117
          if( itemIndex < index ) {
1118
            this._selected[ i ] = index - 1;
1119
          }
1113
        }
1120
        }
1114
      }
1121
      }
1115
    },
1122
    },
(-)js/org/eclipse/rwt/test/tests/TableTest.js (+29 lines)
Lines 175-180 Link Here
175
      table.destroy();
175
      table.destroy();
176
    },
176
    },
177
177
178
    testAdjustSelectedIndicesAfterAddingAnItem : function() {
179
      var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
180
      var table = this._createDefaultTable();
181
      for( var i = 0; i < 5; i++ ) {
182
        new org.eclipse.swt.widgets.TableItem( table, i );
183
      }
184
      table.selectItem( 1 );
185
      table.selectItem( 2 );
186
      table.selectItem( 4 );
187
      new org.eclipse.swt.widgets.TableItem( table, 2 );
188
      assertEquals( [ 1, 3, 5 ], table._selected );
189
      table.destroy();
190
    },
191
192
    testAdjustSelectedIndicesAfterRemovingAnItem : function() {
193
      var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
194
      var table = this._createDefaultTable();
195
      var items = [];
196
      for( var i = 0; i < 5; i++ ) {
197
        items[ i ] = new org.eclipse.swt.widgets.TableItem( table, i );
198
      }
199
      table.selectItem( 1 );
200
      table.selectItem( 2 );
201
      table.selectItem( 4 );
202
      items[ 1 ].dispose();
203
      assertEquals( [ 1, 3 ], table._selected );
204
      table.destroy();
205
    },
206
178
    /////////
207
    /////////
179
    // Helper
208
    // Helper
180
    
209
    

Return to bug 346222