Revision 31496 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/table/FieldSelectionModel.java
FieldSelectionModel.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.ArrayList; |
4 | 4 |
import java.util.Iterator; |
5 |
import java.util.List; |
|
5 | 6 |
|
6 | 7 |
import org.gvsig.fmap.dal.exception.DataException; |
7 | 8 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
8 | 9 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
10 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
9 | 11 |
import org.gvsig.utils.swing.objectSelection.ObjectSelectionModel; |
10 | 12 |
import org.gvsig.utils.swing.objectSelection.SelectionException; |
11 | 13 |
|
12 | 14 |
|
13 | 15 |
|
14 | 16 |
/** |
15 |
* DOCUMENT ME! |
|
16 |
* |
|
17 | 17 |
* @author Fernando Gonz?lez Cort?s |
18 | 18 |
*/ |
19 | 19 |
public class FieldSelectionModel implements ObjectSelectionModel { |
20 |
// final static private Logger logger = LoggerFactory.getLogger(FieldSelectionModel.class); |
|
21 |
|
|
20 | 22 |
private FeatureStore fs; |
21 | 23 |
private String msg; |
22 |
private int type=-1;
|
|
24 |
private int type = DataTypes.INVALID;
|
|
23 | 25 |
|
24 | 26 |
/** |
25 | 27 |
* Crea un nuevo FirstFieldSelectionModel. |
26 | 28 |
* |
27 |
* @param ds DOCUMENT ME! |
|
28 |
* @param msg DOCUMENT ME! |
|
29 |
* @param allowedTypes DOCUMENT ME! |
|
30 | 29 |
*/ |
31 |
public FieldSelectionModel(FeatureStore fs, String msg, |
|
32 |
int type) { |
|
30 |
public FieldSelectionModel(FeatureStore fs, String msg, int type) { |
|
33 | 31 |
this.fs = fs; |
34 | 32 |
this.msg = msg; |
35 | 33 |
this.type = type; |
36 | 34 |
} |
37 | 35 |
|
38 |
/** |
|
39 |
* DOCUMENT ME! |
|
40 |
* |
|
41 |
* @return DOCUMENT ME! |
|
42 |
* |
|
43 |
* @throws SelectionException |
|
44 |
* |
|
45 |
* @see org.gvsig.utils.swing.objectSelection.ObjectSelectionModel#getObjects() |
|
46 |
*/ |
|
36 |
@SuppressWarnings("unchecked") |
|
47 | 37 |
public Object[] getObjects() throws SelectionException { |
48 |
// try { |
|
49 |
// ds.start(); |
|
50 | 38 |
|
51 |
ArrayList fields = new ArrayList();
|
|
52 |
Iterator iterator=null; |
|
39 |
List<String> fields = new ArrayList<String>();
|
|
40 |
Iterator<FeatureAttributeDescriptor> iterator=null;
|
|
53 | 41 |
try { |
54 | 42 |
iterator = fs.getDefaultFeatureType().iterator(); |
55 | 43 |
} catch (DataException e) { |
56 |
// TODO Auto-generated catch block |
|
57 |
e.printStackTrace(); |
|
44 |
throw new SelectionException("Can't create iterator for the atribute of feature type",e); |
|
58 | 45 |
} |
59 | 46 |
while (iterator.hasNext()) { |
60 |
FeatureAttributeDescriptor descriptor = (FeatureAttributeDescriptor) iterator.next();
|
|
61 |
if (type!=-1){
|
|
47 |
FeatureAttributeDescriptor descriptor = iterator.next(); |
|
48 |
if ( type != DataTypes.INVALID ){
|
|
62 | 49 |
if (descriptor.getDataType() == type) { |
63 | 50 |
fields.add(descriptor.getName()); |
64 | 51 |
} |
... | ... | |
66 | 53 |
fields.add(descriptor.getName()); |
67 | 54 |
} |
68 | 55 |
} |
69 |
// for (int i = 0; i < fs.getFieldCount(); i++) { |
|
70 |
// if (type != -1) { |
|
71 |
// System.out.println(fs.getFieldName(i) + " tipo: " + fs.getFieldType(i)); |
|
72 |
// if (fs.getFieldType(i) == type) { |
|
73 |
// fields.add(fs.getFieldName(i)); |
|
74 |
// } |
|
75 |
// } else { |
|
76 |
// fields.add(fs.getFieldName(i)); |
|
77 |
// } |
|
78 |
// } |
|
79 | 56 |
|
80 |
// ds.stop(); |
|
81 |
|
|
82 |
return (String[]) fields.toArray(new String[0]); |
|
83 |
// } catch (ReadException e) { |
|
84 |
// throw new SelectionException(e); |
|
85 |
// } |
|
57 |
return (String[]) fields.toArray(); |
|
86 | 58 |
} |
87 | 59 |
|
88 | 60 |
/** |
Also available in: Unified diff