| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| SitesComboBoxModel |
|
| 1.0;1 |
| 1 | package org.jtheque.films.view.impl.models.combo; | |
| 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.films.utils.Constants.Site; | |
| 20 | ||
| 21 | import javax.swing.DefaultComboBoxModel; | |
| 22 | ||
| 23 | /** | |
| 24 | * A combo box model for sites. | |
| 25 | * | |
| 26 | * @author Baptiste Wicht | |
| 27 | */ | |
| 28 | public final class SitesComboBoxModel extends DefaultComboBoxModel { | |
| 29 | private static final long serialVersionUID = 229679641284881689L; | |
| 30 | ||
| 31 | private final Site[] sites; | |
| 32 | ||
| 33 | /** | |
| 34 | * Construct a new SitesComboBoxModel and fill it with the available sites. | |
| 35 | */ | |
| 36 | public SitesComboBoxModel() { | |
| 37 | 0 | super(); |
| 38 | ||
| 39 | 0 | sites = Site.values(); |
| 40 | 0 | } |
| 41 | ||
| 42 | @Override | |
| 43 | public Object getElementAt(int index) { | |
| 44 | 0 | return sites[index]; |
| 45 | } | |
| 46 | ||
| 47 | @Override | |
| 48 | public int getSize() { | |
| 49 | 0 | return sites.length; |
| 50 | } | |
| 51 | ||
| 52 | /** | |
| 53 | * Return the selected site. | |
| 54 | * | |
| 55 | * @return The selected site. | |
| 56 | */ | |
| 57 | public Site getSelectedSite() { | |
| 58 | 0 | return (Site) getSelectedItem(); |
| 59 | } | |
| 60 | } |