| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| DataCellEditor |
|
| 1.0;1 |
| 1 | package org.jtheque.films.view.impl.editors; | |
| 2 | ||
| 3 | /* | |
| 4 | * This file is part of JTheque. | |
| 5 | * | |
| 6 | * JTheque 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. | |
| 9 | * | |
| 10 | * JTheque is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | * GNU General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU General Public License | |
| 16 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
| 17 | */ | |
| 18 | ||
| 19 | import org.jtheque.core.managers.persistence.able.DataContainer; | |
| 20 | import org.jtheque.primary.od.able.Data; | |
| 21 | import org.jtheque.primary.view.impl.models.DataContainerCachedComboBoxModel; | |
| 22 | ||
| 23 | import javax.swing.DefaultCellEditor; | |
| 24 | import javax.swing.JComboBox; | |
| 25 | ||
| 26 | /** | |
| 27 | * A CellEditor for JTable. This editor enable us to display a combo box of datas of dao in a cell of JTable. | |
| 28 | * | |
| 29 | * @author Baptiste Wicht | |
| 30 | */ | |
| 31 | public final class DataCellEditor extends DefaultCellEditor { | |
| 32 | private static final long serialVersionUID = 7853045852810480944L; | |
| 33 | ||
| 34 | /** | |
| 35 | * Construct a DataCellEditor for a data container. | |
| 36 | * | |
| 37 | * @param container The container. | |
| 38 | * @param <T> The type of data. | |
| 39 | */ | |
| 40 | public <T extends Data> DataCellEditor(DataContainer<T> container) { | |
| 41 | 0 | super(buildCombo(container)); |
| 42 | 0 | } |
| 43 | ||
| 44 | /** | |
| 45 | * Build a combo box for a data container. | |
| 46 | * | |
| 47 | * @param container The container. | |
| 48 | * @param <T> The type of data. | |
| 49 | * @return A JCombobox with a model bounded to the data container. | |
| 50 | */ | |
| 51 | private static <T extends Data> JComboBox buildCombo(DataContainer<T> container) { | |
| 52 | 0 | return new JComboBox(new DataContainerCachedComboBoxModel<T>(container)); |
| 53 | } | |
| 54 | } |