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

Collapse All | Expand All

(-)src/org/eclipse/swt/internal/widgets/ListModel.java (-10 / +19 lines)
Lines 45-51 Link Here
45
    System.arraycopy( selection, 0, result, 0, selection.length );
45
    System.arraycopy( selection, 0, result, 0, selection.length );
46
    return result;
46
    return result;
47
  }
47
  }
48
  
48
49
  public int getSelectionCount() {
49
  public int getSelectionCount() {
50
    return selection.length;
50
    return selection.length;
51
  }
51
  }
Lines 86-92 Link Here
86
      }
86
      }
87
    }
87
    }
88
  }
88
  }
89
  
89
90
  public void setSelection( final int start, final int end ) {
90
  public void setSelection( final int start, final int end ) {
91
    deselectAll();
91
    deselectAll();
92
    if( end >= 0 && start <= end && start <= getItemCount() - 1 ) {
92
    if( end >= 0 && start <= end && start <= getItemCount() - 1 ) {
Lines 106-112 Link Here
106
      }
106
      }
107
    }
107
    }
108
  }
108
  }
109
  
109
110
  public void setSelection( final String[] selection ) {
110
  public void setSelection( final String[] selection ) {
111
    if( selection == null ) {
111
    if( selection == null ) {
112
      SWT.error( SWT.ERROR_NULL_ARGUMENT );
112
      SWT.error( SWT.ERROR_NULL_ARGUMENT );
Lines 161-170 Link Here
161
  public void deselectAll() {
161
  public void deselectAll() {
162
    this.selection = EMPTY_SELECTION;
162
    this.selection = EMPTY_SELECTION;
163
  }
163
  }
164
  
164
165
  ////////////////////////////////
165
  ////////////////////////////////
166
  // Methods to maintain the items
166
  // Methods to maintain the items
167
  
167
168
  public void add( final String string ) {
168
  public void add( final String string ) {
169
    if( string == null ) {
169
    if( string == null ) {
170
      SWT.error( SWT.ERROR_NULL_ARGUMENT );
170
      SWT.error( SWT.ERROR_NULL_ARGUMENT );
Lines 195-201 Link Here
195
      remove( i );
195
      remove( i );
196
    }
196
    }
197
  }
197
  }
198
  
198
199
  public void remove( final int[] indices ) {
199
  public void remove( final int[] indices ) {
200
    if( indices == null ) {
200
    if( indices == null ) {
201
      SWT.error( SWT.ERROR_NULL_ARGUMENT );
201
      SWT.error( SWT.ERROR_NULL_ARGUMENT );
Lines 237-243 Link Here
237
  public void setItems( final String[] items ) {
237
  public void setItems( final String[] items ) {
238
    if( items == null ) {
238
    if( items == null ) {
239
      SWT.error( SWT.ERROR_NULL_ARGUMENT );
239
      SWT.error( SWT.ERROR_NULL_ARGUMENT );
240
    } 
240
    }
241
    for( int i = 0; i < items.length; i++ ) {
241
    for( int i = 0; i < items.length; i++ ) {
242
      if( items[ i ] == null ) {
242
      if( items[ i ] == null ) {
243
        SWT.error( SWT.ERROR_INVALID_ARGUMENT );
243
        SWT.error( SWT.ERROR_INVALID_ARGUMENT );
Lines 264-271 Link Here
264
  }
264
  }
265
265
266
  //////////////////
266
  //////////////////
267
  // Helping methods 
267
  // Helping methods
268
  
268
269
  /* If the given index is contained in the selection, it will be removed. */
269
  /* If the given index is contained in the selection, it will be removed. */
270
  private void removeFromSelection( final int index ) {
270
  private void removeFromSelection( final int index ) {
271
    boolean found = false;
271
    boolean found = false;
Lines 281-288 Link Here
281
        found = true;
281
        found = true;
282
      }
282
      }
283
    }
283
    }
284
    adjustSelectionIdices( index );
285
  }
286
287
  private void adjustSelectionIdices( final int removedIndex ) {
288
    for( int i = 0; i < selection.length; i++ ) {
289
      if( selection[ i ] >= removedIndex ) {
290
        selection[ i ] = selection[ i ] - 1;
291
      }
292
    }
284
  }
293
  }
285
  
294
286
  private int indexOf( final String string ) {
295
  private int indexOf( final String string ) {
287
    return items.indexOf( string );
296
    return items.indexOf( string );
288
  }
297
  }

Return to bug 278346