View Javadoc

1   /*
2    * Copyright (c) 2003-2008 by Cosylab d. d.
3    *
4    * This file is part of CosyBeans-Common.
5    *
6    * CosyBeans-Common is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU General Public License as published by
8    * the Free Software Foundation, either version 3 of the License, or
9    * (at your option) any later version.
10   *
11   * CosyBeans-Common is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU General Public License
17   * along with CosyBeans-Common.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  
20  package com.cosylab.gui.components.table;
21  
22  /**
23   * <code>TableRowModel</code> is table model which natural organization of data
24   * is grouped by rows. This model can not be used directly in
25   * <code>JTable</code>, it must be used in collaboration with
26   * <code>TableModelRows</code> or similar implementation of
27   * <code>TableModel</code>.
28   *
29   * @author <a href="mailto:igor.kriznar@cosylab.com">Igor Kriznar</a>
30   * @version $Id: TableRowModel.java,v 1.4 2008-04-22 12:28:40 jbobnar Exp $
31   *
32   * @since May 3, 2004.
33   */
34  public interface TableRowModel
35  {
36  	/**
37  	 * Number of columns inside this model.
38  	 *
39  	 * @return number of columns inside this model
40  	 */
41  	public int getColumnCount();
42  
43  	/**
44  	 * Returns number of rows contained in this model.
45  	 *
46  	 * @return number of  rows
47  	 */
48  	public int getRowCount();
49  
50  	/**
51  	 * Returns a row object at row index.
52  	 *
53  	 * @param rowIndex the row index
54  	 *
55  	 * @return a row at the row index
56  	 */
57  	public TableRow getRowAt(int rowIndex);
58  
59  	/**
60  	 * Returns index of a row.
61  	 *
62  	 * @param row a row form this model
63  	 *
64  	 * @return the index ot the row
65  	 */
66  	public int getRowIndex(TableRow row);
67  
68  	/**
69  	 * Add listener, which receives notification of changes in the model.
70  	 *
71  	 * @param l a <code>TableRowModelListener</code> listener
72  	 */
73  	public void addTableRowModelListener(TableRowModelListener l);
74  
75  	/**
76  	 * Removes listener.
77  	 *
78  	 * @param l a <code>TableRowModelListener</code> listener
79  	 */
80  	public void removeTableRowModelListener(TableRowModelListener l);
81  
82  	/**
83  	 * Returns name of column.
84  	 *
85  	 * @param index the index of  the colummn
86  	 *
87  	 * @return the name of the column under provided index
88  	 *
89  	 * @see javax.swing.table.TableModel#getColumnName(int)
90  	 */
91  	public String getColumnName(int index);
92  
93  	/**
94  	 * This method is called from table row, when wants to notify its parent
95  	 * model about value change.
96  	 *
97  	 * @param row the row which value has changes
98  	 * @param valueIndex the index of the value, if <code>-1</code> all values
99  	 *        has been changed
100 	 */
101 	public void fireRowUpdate(TableRow row, int valueIndex);
102 
103 	/**
104 	 * Sort rows in ascending or descengin order according to the natural order
105 	 * of cells in specified column. Natural order is determined by cells,
106 	 * which implements <code>Comparable</code>.
107 	 *
108 	 * @param column the column index, according to which rows are sorted
109 	 * @param descending sorted rows are ordered ascending if
110 	 *        <code>false</code>, or descending if <code>true</code>.
111 	 */
112 	public void sortRows(int column, boolean descending);
113 }
114 
115 /* __oOo__ */