01: package vicazh.hyperpool.stream;
02:
03: import java.util.*;
04: import vicazh.hyperpool.*;
05:
06: /**
07: * The list selector
08: *
09: * @author Victor Zhigunov
10: * @version 0.4.0
11: */
12: public class ListSelector extends Selector implements ListSelectorMBean {
13:
14: private List<List<Object>> list;
15:
16: public List<List<Object>> getList() {
17: return list;
18: }
19:
20: public void setList(List<List<Object>> list) {
21: this .list = list;
22: }
23:
24: public List<Object> getListObject() {
25: return new ArrayList<Object>();
26: }
27:
28: public void setGroup(GroupMBean group) {
29: super .setGroup(group);
30: if (list != null)
31: for (int i = list.size(); i < group.getObjects().size(); i++)
32: list.add(i, getListObject());
33: }
34:
35: public void added(int index) {
36: list.add(index, getListObject());
37: super .added(index);
38: }
39:
40: public void removed(int index) {
41: list.remove(index);
42: super .removed(index);
43: }
44:
45: public int getIndex(Object object) {
46: for (int i = 0; i < list.size(); i++)
47: if (list.get(i).contains(object))
48: return i;
49: return getDef();
50: }
51:
52: public void setListAttribute(List<List<Object>> value)
53: throws Exception {
54: setList(value);
55: super.setAttribute(ListSelectorMBean.LIST, value);
56: }
57: }
|