001: /*
002: ItsNat Java Web Application Framework
003: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004: Author: Jose Maria Arranz Santamaria
005:
006: This program is free software: you can redistribute it and/or modify
007: it under the terms of the GNU Affero General Public License as published by
008: the Free Software Foundation, either version 3 of the License, or
009: (at your option) any later version. See the GNU Affero General Public
010: License for more details. See the copy of the GNU Affero General Public License
011: included in this program. If not, see <http://www.gnu.org/licenses/>.
012: */
013:
014: package org.itsnat.comp;
015:
016: import javax.swing.ListSelectionModel;
017: import org.itsnat.comp.ui.ItsNatTableHeaderUI;
018:
019: /**
020: * Is the base interface of table header components.
021: *
022: * <p>A table header component depends on a table component and is created automatically
023: * by the table whether the table markup has a header (for instance a <thead>).</p>
024: *
025: * <p>A header component is not very different to a list but column values (header data model)
026: * are managed by the <code>javax.swing.table.TableModel</code> data model of the parent table
027: * (see <code>DefaultTableModel.addColumn(Object)</code>).</code>
028: *
029: * <p>Any change to the header data model is notified to the component and the markup
030: * is rendered again. The data model ever mandates over the markup,
031: * any initial markup content (initial header cell) is removed.</p>
032: *
033: * <p>Almost a header cell must be present in the markup, this cell is used as pattern
034: * to create new cells, and is removed because by default the header model is empty.</p>
035: *
036: * <p>If a header column is clicked the column is selected.</p>
037: *
038: * <p>There is no default header cell decoration when a complete column is selected,
039: * use a column selection model listener to detect when a column is selected.</p>
040: *
041: * <p>Header cell indexes start in 0.</p>
042: *
043: * @author Jose Maria Arranz Santamaria
044: */
045: public interface ItsNatTableHeader extends ItsNatElementComponent {
046: /**
047: * Returns the table component this header belongs to.
048: *
049: * @return the parent table component. Never is null.
050: */
051: public ItsNatTable getItsNatTable();
052:
053: /**
054: * Returns the user interface manager of this component.
055: *
056: * @return the user interface manager.
057: */
058: public ItsNatTableHeaderUI getItsNatTableHeaderUI();
059:
060: /**
061: * Returns the current component renderer. This renderer converts a column value of the table header to markup.
062: *
063: * @return the current renderer. By default uses the default renderer ({@link ItsNatComponentManager#createDefaultItsNatTableHeaderCellRenderer()})
064: * @see #setItsNatTableHeaderCellRenderer(ItsNatTableHeaderCellRenderer)
065: */
066: public ItsNatTableHeaderCellRenderer getItsNatTableHeaderCellRenderer();
067:
068: /**
069: * Sets the component renderer.
070: *
071: * @param renderer the new renderer.
072: * @see #getItsNatTableHeaderCellRenderer()
073: */
074: public void setItsNatTableHeaderCellRenderer(
075: ItsNatTableHeaderCellRenderer renderer);
076:
077: /**
078: * Returns the current header selection model. This selection model is used
079: * to manage only the selection state of header columns.
080: *
081: * <p>By default if a header cell is clicked the selection model is used
082: * to remember this selection, may be used to do typical tasks like to sort
083: * the rows by the selected column.</p>
084: *
085: * @return the current selection model. By default a <code>javax.swing.DefaultListSelectionModel</code> instance
086: * in <code>ListSelectionModel.SINGLE_SELECTION</code> mode.
087: * @see #setListSelectionModel(javax.swing.ListSelectionModel)
088: */
089: public ListSelectionModel getListSelectionModel();
090:
091: /**
092: * Sets the new selection model.
093: *
094: * <p>If the new selection model is the current defined then is "reset",
095: * component listener is removed and added again. Use this technique if
096: * you want to add a listener to be executed <i>before</i> the default component listener.
097: *
098: * @param selectionModel the new selection model.
099: * @see #getListSelectionModel()
100: */
101: public void setListSelectionModel(ListSelectionModel selectionModel);
102:
103: /**
104: * Returns the index of the first selected header column. If the component
105: * allows multiple selection returns the first one.
106: *
107: * @return index of the first selected header column. -1 if none is selected.
108: */
109: public int getSelectedIndex();
110:
111: /**
112: * Selects the specified header column. If this component allows multiple selection,
113: * the current selection is cleared before.
114: *
115: * @param index the index of the item to select
116: */
117: public void setSelectedIndex(int index);
118: }
|