Statistics
| Revision:

gvsig-lrs / org.gvsig.lrs / trunk / org.gvsig.lrs / org.gvsig.lrs.swing / org.gvsig.lrs.swing.impl / src / main / java / org / gvsig / lrs / swing / impl / FeatureAttributeDescriptorsComboBoxModel.java @ 6

History | View | Annotate | Download (3.32 KB)

1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2015 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program 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 this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.lrs.swing.impl;
24

    
25
import java.util.ArrayList;
26
import java.util.List;
27

    
28
import javax.swing.AbstractListModel;
29
import javax.swing.MutableComboBoxModel;
30

    
31
import org.slf4j.Logger;
32
import org.slf4j.LoggerFactory;
33

    
34
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
35

    
36
/**
37
 * @author fdiaz
38
 *
39
 */
40
public class FeatureAttributeDescriptorsComboBoxModel extends AbstractListModel<FeatureAttributeDescriptor> implements MutableComboBoxModel<FeatureAttributeDescriptor> {
41

    
42

    
43

    
44
    private static final Logger logger = LoggerFactory.getLogger(FeatureAttributeDescriptorsComboBoxModel.class);
45

    
46
    private List<FeatureAttributeDescriptor> descriptors;
47
    private FeatureAttributeDescriptor selected;
48

    
49
    /**
50
     *
51
     */
52
    public FeatureAttributeDescriptorsComboBoxModel() {
53
        descriptors = new ArrayList<FeatureAttributeDescriptor>();
54
    }
55

    
56
    /*
57
     * (non-Javadoc)
58
     *
59
     * @see javax.swing.ListModel#getSize()
60
     */
61
    public int getSize() {
62
        return descriptors.size();
63
    }
64

    
65
    /*
66
     * (non-Javadoc)
67
     *
68
     * @see javax.swing.ListModel#getElementAt(int)
69
     */
70
    public FeatureAttributeDescriptor getElementAt(int index) {
71
        return descriptors.get(index);
72
    }
73

    
74
    /*
75
     * (non-Javadoc)
76
     *
77
     * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
78
     */
79
    public void setSelectedItem(final Object anItem) {
80
        selected = (FeatureAttributeDescriptor) anItem;
81
    }
82

    
83
    /*
84
     * (non-Javadoc)
85
     *
86
     * @see javax.swing.ComboBoxModel#getSelectedItem()
87
     */
88
    public Object getSelectedItem() {
89
        return selected;
90
    }
91

    
92
    /* (non-Javadoc)
93
     * @see javax.swing.MutableComboBoxModel#addElement(java.lang.Object)
94
     */
95
    public void addElement(FeatureAttributeDescriptor item) {
96
        descriptors.add(item);
97
    }
98

    
99
    /* (non-Javadoc)
100
     * @see javax.swing.MutableComboBoxModel#removeElement(java.lang.Object)
101
     */
102
    public void removeElement(Object obj) {
103
        descriptors.remove(obj);
104

    
105
    }
106

    
107
    /* (non-Javadoc)
108
     * @see javax.swing.MutableComboBoxModel#insertElementAt(java.lang.Object, int)
109
     */
110
    public void insertElementAt(FeatureAttributeDescriptor item, int index) {
111
        descriptors.add(index, item);
112

    
113
    }
114

    
115
    /* (non-Javadoc)
116
     * @see javax.swing.MutableComboBoxModel#removeElementAt(int)
117
     */
118
    public void removeElementAt(int index) {
119
        descriptors.remove(index);
120
    }
121

    
122
}