svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.swing / org.gvsig.fmap.dal.swing.impl / src / main / java / org / gvsig / fmap / dal / swing / impl / expressionevaluator / FeatureStoreElement.java @ 43983
History | View | Annotate | Download (2.65 KB)
1 |
package org.gvsig.fmap.dal.swing.impl.expressionevaluator; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
import java.util.Collections; |
5 |
import java.util.Comparator; |
6 |
import java.util.Iterator; |
7 |
import java.util.List; |
8 |
import org.gvsig.expressionevaluator.Function; |
9 |
import org.gvsig.expressionevaluator.swing.Element; |
10 |
import org.gvsig.expressionevaluator.swing.Element.GroupElement; |
11 |
import org.gvsig.expressionevaluator.swing.ExpressionBuilderConfig; |
12 |
import org.gvsig.expressionevaluator.swing.spi.AbstractElement; |
13 |
import org.gvsig.fmap.dal.exception.DataException; |
14 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
15 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
16 |
import org.gvsig.fmap.dal.feature.FeatureType; |
17 |
|
18 |
/**
|
19 |
*
|
20 |
* @author jjdelcerro
|
21 |
*/
|
22 |
public class FeatureStoreElement |
23 |
extends AbstractElement
|
24 |
implements GroupElement
|
25 |
{ |
26 |
|
27 |
final FeatureStore store;
|
28 |
final FeatureType type;
|
29 |
final List<Element> elements; |
30 |
final ExpressionBuilderConfig configPanel;
|
31 |
|
32 |
public FeatureStoreElement(ExpressionBuilderConfig configPanel, FeatureStore store) {
|
33 |
super(store.getName(), null, "expressionbuilder-element-table"); |
34 |
this.configPanel = configPanel;
|
35 |
try {
|
36 |
this.store = store;
|
37 |
this.type = this.store.getDefaultFeatureType(); |
38 |
this.elements = new ArrayList<>(); |
39 |
for (FeatureAttributeDescriptor attrdesc : type) {
|
40 |
this.elements.add(new FeatureAttributeElement( |
41 |
this.configPanel,
|
42 |
this.store,
|
43 |
attrdesc |
44 |
) |
45 |
); |
46 |
} |
47 |
Collections.sort(elements, new Comparator<Element>() { |
48 |
@Override
|
49 |
public int compare(Element o1, Element o2) { |
50 |
return o1.getName().compareTo(o2.getName());
|
51 |
} |
52 |
}); |
53 |
} catch (DataException ex) {
|
54 |
throw new RuntimeException(ex); |
55 |
} |
56 |
} |
57 |
|
58 |
@Override
|
59 |
public Element get(int index) { |
60 |
return this.elements.get(index); |
61 |
} |
62 |
|
63 |
@Override
|
64 |
public int size() { |
65 |
return this.type.size(); |
66 |
} |
67 |
|
68 |
@Override
|
69 |
public Iterator<Element> iterator() { |
70 |
return this.elements.iterator(); |
71 |
} |
72 |
|
73 |
@Override
|
74 |
public void addElement(Element element) { |
75 |
} |
76 |
|
77 |
@Override
|
78 |
public void addElement(Function function) { |
79 |
} |
80 |
|
81 |
@Override
|
82 |
public List<Element> getElements() { |
83 |
return Collections.unmodifiableList(this.elements); |
84 |
} |
85 |
|
86 |
@Override
|
87 |
public boolean hasSubgroups() { |
88 |
return true; |
89 |
} |
90 |
|
91 |
@Override
|
92 |
public boolean hasMoreElements() { |
93 |
return false; |
94 |
} |
95 |
|
96 |
|
97 |
} |