001 /* 002 * Copyright 2002-2004 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 005 * use this file except in compliance with the License. You may obtain a copy of 006 * the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 013 * License for the specific language governing permissions and limitations under 014 * the License. 015 */ 016 package org.springframework.richclient.table; 017 018 import java.util.List; 019 020 import javax.swing.table.TableModel; 021 022 /** 023 * A table model whose contents can change. 024 * 025 * @author Keith Donald 026 */ 027 public interface MutableTableModel extends TableModel { 028 029 /** 030 * Adds the given row to the end of the list of existing rows in the table model. All 031 * registered table model listeners will be notified of the additional row. 032 * 033 * @param row The row to be added. Must not be null. 034 * 035 * @throws IllegalArgumentException if {@code row} is null. 036 */ 037 public void addRow(Object row); 038 039 /** 040 * Adds the given rows to the end of the list of existing rows in the table model. All 041 * registered table model listeners will be notified of the additional rows. 042 * 043 * @param rows The rows to be added. May be empty but must not be null. 044 * 045 * @throws IllegalArgumentException if {@code rows} is null. 046 */ 047 public void addRows(List rows); 048 049 /** 050 * Removes from the table model the row at the given position in the list of rows. All 051 * registered table model listeners will be notified of the removal of the row. 052 * 053 * @param index The zero-based position of the row to be removed. 054 * 055 * @throws IndexOutOfBoundsException if {@code index} is not within the bounds of the 056 * model's collection of rows. 057 */ 058 public void remove(int index); 059 060 /** 061 * Removes all of the rows from {@code firstIndex} to {@code lastIndex} inclusive. All 062 * registered table model listeners will be notified of the removal of the rows. 063 * 064 * @param firstIndex The zero-based position of the first row to be removed. 065 * @param lastIndex The zero-based position of the last row to be removed. 066 * 067 * @throws IllegalArgumentException if {@code lastIndex} is less than {@code firstIndex}. 068 * @throws IndexOutOfBoundsException if either argument is outside the bounds of the 069 * number of rows in the model. 070 */ 071 public void remove(int firstIndex, int lastIndex); 072 073 /** 074 * Removes the rows at each of the given positions. All registered table model listeners 075 * will be notified of the removal of the rows. 076 * 077 * @param indexes The array of zero-based indexes of the rows to be removed. May be empty 078 * but must not be null. 079 * 080 * @throws IllegalArgumentException if {@code indexes} is null. 081 * @throws IndexOutOfBoundsException if any of the elements in the array are not within the 082 * bounds of the model's collection of rows. 083 */ 084 public void remove(int[] indexes); 085 086 /** 087 * Removes all rows from the table model. All registered table model listeners will be 088 * notified of the removal of the rows. 089 */ 090 public void clear(); 091 092 }