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 / FeatureStoresComboBoxModel.java @ 11
History | View | Annotate | Download (3.24 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 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
36 |
|
37 |
/**
|
38 |
* @author dmartinez
|
39 |
*
|
40 |
*/
|
41 |
public class FeatureStoresComboBoxModel extends AbstractListModel<FeatureStore> implements MutableComboBoxModel<FeatureStore> { |
42 |
|
43 |
|
44 |
|
45 |
private static final Logger logger = LoggerFactory.getLogger(FeatureStoresComboBoxModel.class); |
46 |
|
47 |
private List<FeatureStore> featureStores; |
48 |
private FeatureStore selected;
|
49 |
|
50 |
/**
|
51 |
*
|
52 |
*/
|
53 |
public FeatureStoresComboBoxModel(List<FeatureStore> featureStores) { |
54 |
this.featureStores = featureStores;
|
55 |
} |
56 |
|
57 |
/*
|
58 |
* (non-Javadoc)
|
59 |
*
|
60 |
* @see javax.swing.ListModel#getSize()
|
61 |
*/
|
62 |
public int getSize() { |
63 |
return featureStores.size();
|
64 |
} |
65 |
|
66 |
/*
|
67 |
* (non-Javadoc)
|
68 |
*
|
69 |
* @see javax.swing.ListModel#getElementAt(int)
|
70 |
*/
|
71 |
public FeatureStore getElementAt(int index) { |
72 |
return featureStores.get(index);
|
73 |
} |
74 |
|
75 |
/*
|
76 |
* (non-Javadoc)
|
77 |
*
|
78 |
* @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
|
79 |
*/
|
80 |
public void setSelectedItem(final Object anItem) { |
81 |
selected = (FeatureStore) anItem; |
82 |
} |
83 |
|
84 |
/*
|
85 |
* (non-Javadoc)
|
86 |
*
|
87 |
* @see javax.swing.ComboBoxModel#getSelectedItem()
|
88 |
*/
|
89 |
public Object getSelectedItem() { |
90 |
return selected;
|
91 |
} |
92 |
|
93 |
/* (non-Javadoc)
|
94 |
* @see javax.swing.MutableComboBoxModel#addElement(java.lang.Object)
|
95 |
*/
|
96 |
public void addElement(FeatureStore item) { |
97 |
featureStores.add(item); |
98 |
} |
99 |
|
100 |
/* (non-Javadoc)
|
101 |
* @see javax.swing.MutableComboBoxModel#removeElement(java.lang.Object)
|
102 |
*/
|
103 |
public void removeElement(Object obj) { |
104 |
featureStores.remove(obj); |
105 |
|
106 |
} |
107 |
|
108 |
/* (non-Javadoc)
|
109 |
* @see javax.swing.MutableComboBoxModel#insertElementAt(java.lang.Object, int)
|
110 |
*/
|
111 |
public void insertElementAt(FeatureStore item, int index) { |
112 |
featureStores.add(index, item); |
113 |
|
114 |
} |
115 |
|
116 |
/* (non-Javadoc)
|
117 |
* @see javax.swing.MutableComboBoxModel#removeElementAt(int)
|
118 |
*/
|
119 |
public void removeElementAt(int index) { |
120 |
featureStores.remove(index); |
121 |
} |
122 |
|
123 |
} |