GNU Classpath (0.95) | |
Frames | No Frames |
1: /* TableColumnModel.java -- 2: Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath 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 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: 39: package javax.swing.table; 40: 41: import java.util.Enumeration; 42: 43: import javax.swing.JTable; 44: import javax.swing.ListSelectionModel; 45: import javax.swing.event.ChangeEvent; 46: import javax.swing.event.TableColumnModelEvent; 47: import javax.swing.event.TableColumnModelListener; 48: 49: /** 50: * The interface used by {@link JTable} to access the columns in the table 51: * view. 52: * 53: * @author Andrew Selkirk 54: */ 55: public interface TableColumnModel 56: { 57: /** 58: * Adds a column to the model. 59: * 60: * @param column the new column (<code>null</code> not permitted). 61: * 62: * @throws IllegalArgumentException if <code>column</code> is 63: * <code>null</code>. 64: */ 65: void addColumn(TableColumn column); 66: 67: /** 68: * Removes a column from the model. If <code>column</code> is not defined 69: * in the model, this method does nothing. 70: * 71: * @param column TableColumn 72: */ 73: void removeColumn(TableColumn column); 74: 75: /** 76: * Moves a column. 77: * 78: * @param columnIndex Index of column to move 79: * @param newIndex New index of column 80: */ 81: void moveColumn(int columnIndex, int newIndex); 82: 83: /** 84: * Sets the column margin and sends a {@link ChangeEvent} to all registered 85: * {@link TableColumnModelListener}s registered with the model. 86: * 87: * @param margin the column margin. 88: * 89: * @see #getColumnMargin() 90: */ 91: void setColumnMargin(int margin); 92: 93: /** 94: * Returns the number of columns in the model. 95: * 96: * @return The column count. 97: */ 98: int getColumnCount(); 99: 100: /** 101: * Returns an enumeration of the columns in the model. 102: * 103: * @return An enumeration of the columns in the model. 104: */ 105: Enumeration<TableColumn> getColumns(); 106: 107: /** 108: * Returns the index of the {@link TableColumn} with the given identifier. 109: * 110: * @param identifier the identifier (<code>null</code> not permitted). 111: * 112: * @return The index of the {@link TableColumn} with the given identifier. 113: * 114: * @throws IllegalArgumentException if <code>identifier</code> is 115: * <code>null</code> or there is no column with that identifier. 116: */ 117: int getColumnIndex(Object identifier); 118: 119: /** 120: * Returns the <code>TableColumn</code> at the specified index. 121: * 122: * @param columnIndex the column index. 123: * 124: * @return The table column. 125: */ 126: TableColumn getColumn(int columnIndex); 127: 128: /** 129: * Returns the column margin. 130: * 131: * @return The column margin. 132: * 133: * @see #setColumnMargin(int) 134: */ 135: int getColumnMargin(); 136: 137: /** 138: * Returns the index of the column that contains the specified x-coordinate, 139: * assuming that: 140: * <ul> 141: * <li>column zero begins at position zero;</li> 142: * <li>all columns appear in order;</li> 143: * <li>individual column widths are taken into account, but the column margin 144: * is ignored.</li> 145: * </ul> 146: * If no column contains the specified position, this method returns 147: * <code>-1</code>. 148: * 149: * @param xPosition the x-position. 150: * 151: * @return The column index, or <code>-1</code>. 152: */ 153: int getColumnIndexAtX(int xPosition); 154: 155: /** 156: * Returns total width of all the columns in the model, ignoring the 157: * column margin (see {@link #getColumnMargin()}). 158: * 159: * @return The total width of all the columns. 160: */ 161: int getTotalColumnWidth(); 162: 163: /** 164: * Sets the flag that indicates whether or not column selection is allowed. 165: * 166: * @param allowed the new flag value. 167: * 168: * @see #getColumnSelectionAllowed() 169: */ 170: void setColumnSelectionAllowed(boolean allowed); 171: 172: /** 173: * Returns <code>true</code> if column selection is allowed, and 174: * <code>false</code> if column selection is not allowed. 175: * 176: * @return A boolean. 177: * 178: * @see #setColumnSelectionAllowed(boolean) 179: */ 180: boolean getColumnSelectionAllowed(); 181: 182: /** 183: * getSelectedColumns 184: * @return Selected columns 185: */ 186: int[] getSelectedColumns(); 187: 188: /** 189: * Returns the number of selected columns in the model. 190: * 191: * @return The selected column count. 192: * 193: * @see #getSelectionModel() 194: */ 195: int getSelectedColumnCount(); 196: 197: /** 198: * Sets the selection model that will be used to keep track of the selected 199: * columns. 200: * 201: * @param model the selection model (<code>null</code> not permitted). 202: * 203: * @throws IllegalArgumentException if <code>model</code> is 204: * <code>null</code>. 205: */ 206: void setSelectionModel(ListSelectionModel model); 207: 208: /** 209: * Returns the selection model used to track table column selections. 210: * 211: * @return The selection model. 212: * 213: * @see #setSelectionModel(ListSelectionModel) 214: */ 215: ListSelectionModel getSelectionModel(); 216: 217: /** 218: * Registers a listener with the model, so that it will receive 219: * {@link TableColumnModelEvent} notifications. 220: * 221: * @param listener the listener (<code>null</code> ignored). 222: */ 223: void addColumnModelListener(TableColumnModelListener listener); 224: 225: /** 226: * Deregisters a listener, so that it will no longer receive 227: * {@link TableColumnModelEvent} notifications. 228: * 229: * @param listener the listener. 230: */ 231: void removeColumnModelListener(TableColumnModelListener listener); 232: }
GNU Classpath (0.95) |