1 | |
package org.jtheque.core.managers.view.impl.components.model; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.managers.Managers; |
20 | |
import org.jtheque.core.managers.update.IUpdateManager; |
21 | |
import org.jtheque.core.managers.update.Updatable; |
22 | |
import org.jtheque.core.managers.update.UpdatableListener; |
23 | |
import org.jtheque.utils.collections.CollectionUtils; |
24 | |
|
25 | |
import javax.swing.DefaultListModel; |
26 | |
import java.util.List; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
public final class UpdatableListModel extends DefaultListModel implements UpdatableListener { |
34 | |
private final List<Updatable> updatables; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
public UpdatableListModel() { |
40 | 0 | super(); |
41 | |
|
42 | 0 | updatables = CollectionUtils.copyOf(Managers.getManager(IUpdateManager.class).getUpdatables()); |
43 | |
|
44 | 0 | Managers.getManager(IUpdateManager.class).addUpdatableListener(this); |
45 | 0 | } |
46 | |
|
47 | |
@Override |
48 | |
public Object getElementAt(int index) { |
49 | 0 | return updatables.get(index); |
50 | |
} |
51 | |
|
52 | |
@Override |
53 | |
public Object get(int index) { |
54 | 0 | return updatables.get(index); |
55 | |
} |
56 | |
|
57 | |
@Override |
58 | |
public int getSize() { |
59 | 0 | return updatables.size(); |
60 | |
} |
61 | |
|
62 | |
@Override |
63 | |
public void updatableAdded() { |
64 | 0 | updatables.clear(); |
65 | 0 | updatables.addAll(Managers.getManager(IUpdateManager.class).getUpdatables()); |
66 | 0 | } |
67 | |
} |