View | Details | Return to bug 27485
Collapse All | Expand All

(-)javax/swing/table/DefaultTableModel.java (-14 / +41 lines)
Lines 1-5 Link Here
1
/* DefaultTableModel.java --
1
/* DefaultTableModel.java --
2
   Copyright (C) 2002, 2004, 2005,  Free Software Foundation, Inc.
2
   Copyright (C) 2002, 2004, 2005, 2006,  Free Software Foundation, Inc.
3
3
4
This file is part of GNU Classpath.
4
This file is part of GNU Classpath.
5
5
Lines 294-305 Link Here
294
    else 
294
    else 
295
    {
295
    {
296
      int rowsToAdd = rowCount - existingRowCount;
296
      int rowsToAdd = rowCount - existingRowCount;
297
      for (int i = 0; i < rowsToAdd; i++) 
297
      addExtraRows(rowsToAdd, columnIdentifiers.size());
298
        {
299
          Vector tmp = new Vector();
300
          tmp.setSize(columnIdentifiers.size());
301
          dataVector.add(tmp);
302
        } 
303
      fireTableRowsInserted(existingRowCount,rowCount-1);
298
      fireTableRowsInserted(existingRowCount,rowCount-1);
304
    }
299
    }
305
  }
300
  }
Lines 366-377 Link Here
366
      if (columnData.length > dataVector.size()) 
361
      if (columnData.length > dataVector.size()) 
367
      {
362
      {
368
        int rowsToAdd = columnData.length - dataVector.size();
363
        int rowsToAdd = columnData.length - dataVector.size();
369
        for (int i = 0; i < rowsToAdd; i++) 
364
	addExtraRows(rowsToAdd, columnIdentifiers.size());
370
        {
371
          Vector tmp = new Vector();
372
          tmp.setSize(columnIdentifiers.size());
373
          dataVector.add(tmp);
374
        }
375
      }
365
      }
376
      else if (columnData.length < dataVector.size())
366
      else if (columnData.length < dataVector.size())
377
      {
367
      {
Lines 502-508 Link Here
502
    else 
492
    else 
503
    {
493
    {
504
      if (column < getColumnCount())
494
      if (column < getColumnCount())
505
      {  
495
      {
496
	checkSize();
497
506
        Object id = columnIdentifiers.get(column);
498
        Object id = columnIdentifiers.get(column);
507
        if (id != null) 
499
        if (id != null) 
508
          result = id.toString();
500
          result = id.toString();
Lines 516-521 Link Here
516
  }
508
  }
517
509
518
  /**
510
  /**
511
   * Checks the real columns/rows sizes against the ones returned by
512
   * <code>getColumnCount()</code> and <code>getRowCount()</code>.
513
   * If the supposed one are bigger, then we grow <code>columIdentifiers</code>
514
   * and <code>dataVector</code> to their expected size.
515
   */
516
  private void checkSize() {
517
    int columnCount = getColumnCount();
518
    int rowCount = getRowCount();
519
520
    if (columnCount > columnIdentifiers.size())
521
      columnIdentifiers.setSize(columnCount);
522
	    
523
    if (rowCount > dataVector.size())
524
      {
525
	int rowsToAdd = rowCount - dataVector.size();
526
	addExtraRows(rowsToAdd, columnCount);
527
      }
528
  }
529
530
  /**
531
   * This method adds some rows to <code>dataVector</code>.
532
   *
533
   * @param rowsToAdd number of rows to add
534
   * @param nbColumns size of the added rows
535
   */
536
  private void addExtraRows(int rowsToAdd, int nbColumns) {
537
    for (int i = 0; i < rowsToAdd; i++) 
538
      {
539
	Vector tmp = new Vector();
540
	tmp.setSize(nbColumns);
541
	dataVector.add(tmp);
542
      }     
543
  }
544
545
  /**
519
   * Returns <code>true</code> if the specified cell can be modified, and
546
   * Returns <code>true</code> if the specified cell can be modified, and
520
   * <code>false</code> otherwise.  For this implementation, the method
547
   * <code>false</code> otherwise.  For this implementation, the method
521
   * always returns <code>true</code>.
548
   * always returns <code>true</code>.

Return to bug 27485