Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ModuleRepositoryListModel |
|
| 1.0;1 |
1 | package org.jtheque.core.managers.view.impl.components.model; | |
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.Managers; | |
20 | import org.jtheque.core.managers.module.IModuleManager; | |
21 | import org.jtheque.core.managers.update.repository.ModuleDescription; | |
22 | import org.jtheque.utils.collections.CollectionUtils; | |
23 | ||
24 | import javax.swing.DefaultListModel; | |
25 | import java.util.List; | |
26 | ||
27 | /** | |
28 | * A List model to display the modules from a repository. | |
29 | * | |
30 | * @author Baptiste Wicht | |
31 | */ | |
32 | public final class ModuleRepositoryListModel extends DefaultListModel { | |
33 | private final List<ModuleDescription> modules; | |
34 | ||
35 | /** | |
36 | * Construct a new ModuleListModel. | |
37 | */ | |
38 | public ModuleRepositoryListModel() { | |
39 | 0 | super(); |
40 | ||
41 | 0 | modules = CollectionUtils.copyOf(Managers.getManager(IModuleManager.class).getModulesFromRepository()); |
42 | 0 | } |
43 | ||
44 | @Override | |
45 | public Object getElementAt(int index) { | |
46 | 0 | return modules.get(index); |
47 | } | |
48 | ||
49 | @Override | |
50 | public Object get(int index) { | |
51 | 0 | return modules.get(index); |
52 | } | |
53 | ||
54 | @Override | |
55 | public int getSize() { | |
56 | 0 | return modules.size(); |
57 | } | |
58 | } |