Revision 44337 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/searchpanel/AdvancedAttributeSelectionTreeModel.java
AdvancedAttributeSelectionTreeModel.java | ||
---|---|---|
11 | 11 |
import javax.swing.tree.TreePath; |
12 | 12 |
import org.apache.commons.lang3.StringUtils; |
13 | 13 |
import org.gvsig.fmap.dal.complements.Search; |
14 |
import org.gvsig.fmap.dal.complements.Search.OrderedAttribute; |
|
14 | 15 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
15 | 16 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
16 | 17 |
import org.gvsig.fmap.dal.feature.FeatureType; |
... | ... | |
42 | 43 |
|
43 | 44 |
private List<Node> childs; |
44 | 45 |
private final FeatureStore store; |
46 |
private final int type; |
|
45 | 47 |
|
46 |
public DefaultNode(FeatureStore store, List<FeatureAttributeDescriptor> attributes) {
|
|
48 |
public DefaultNode(FeatureStore store, List<OrderedAttribute> attributes) {
|
|
47 | 49 |
super(store==null? "":store.getName(), null); |
48 | 50 |
this.store = store; |
51 |
this.type = OrderedAttribute.TYPE_REGURAL; |
|
49 | 52 |
this.childs = new ArrayList<>(); |
50 |
for (FeatureAttributeDescriptor attribute : attributes) {
|
|
51 |
this.childs.add(new DefaultNode(store, attribute)); |
|
53 |
for (OrderedAttribute attribute : attributes) {
|
|
54 |
this.childs.add(new DefaultNode(store, attribute.getDescriptor(), this.type));
|
|
52 | 55 |
} |
53 | 56 |
} |
54 | 57 |
|
55 |
private DefaultNode(FeatureStore store, FeatureAttributeDescriptor attribute) { |
|
58 |
private DefaultNode(FeatureStore store, FeatureAttributeDescriptor attribute, int type) {
|
|
56 | 59 |
super(attribute.getLabel(), attribute); |
57 | 60 |
this.store = store; |
61 |
this.type = type; |
|
58 | 62 |
this.childs = null; |
59 | 63 |
} |
60 | 64 |
|
61 | 65 |
@Override |
62 | 66 |
public String getLabel() { |
67 |
String theLabel; |
|
63 | 68 |
FeatureAttributeDescriptor attrdesc = this.getValue(); |
64 | 69 |
if( attrdesc!=null && attrdesc.isForeingKey() ) { |
65 | 70 |
ForeingKey foreingKey = attrdesc.getForeingKey(); |
66 |
return String.format("%s [%s]", super.getLabel(), foreingKey.getTableName()); |
|
71 |
theLabel = String.format("%s [%s]", super.getLabel(), foreingKey.getTableName()); |
|
72 |
} else { |
|
73 |
theLabel = super.getLabel(); |
|
67 | 74 |
} |
68 |
return super.getLabel(); |
|
75 |
switch(this.type) { |
|
76 |
case Search.OrderedAttribute.TYPE_REGURAL: |
|
77 |
break; |
|
78 |
case Search.OrderedAttribute.TYPE_FAVORITE: |
|
79 |
theLabel = "<b>"+theLabel+"</b>"; |
|
80 |
break; |
|
81 |
case Search.OrderedAttribute.TYPE_RECENT: |
|
82 |
theLabel = "<i><b>"+theLabel+"</b></i>"; |
|
83 |
break; |
|
84 |
} |
|
85 |
return theLabel; |
|
69 | 86 |
} |
70 | 87 |
|
71 | 88 |
@Override |
... | ... | |
95 | 112 |
Search featureTypeSearch = (Search) ToolsLocator.getComplementsManager().get( |
96 | 113 |
Search.COMPLEMENT_MANE, featureType |
97 | 114 |
); |
98 |
List<FeatureAttributeDescriptor> attributes = featureTypeSearch.getOrderedAttributes(
|
|
115 |
List<Search.OrderedAttribute> attributes = featureTypeSearch.getOrderedAttributes(
|
|
99 | 116 |
filterByDataType, |
100 | 117 |
Search.LABEL_ORDER, |
101 | 118 |
-1 |
102 | 119 |
); |
103 | 120 |
this.childs = new ArrayList<>(); |
104 |
for (FeatureAttributeDescriptor attribute : attributes) {
|
|
105 |
this.childs.add(new DefaultNode(theStore, attribute)); |
|
121 |
for (Search.OrderedAttribute attribute : attributes) {
|
|
122 |
this.childs.add(new DefaultNode(theStore, attribute.getDescriptor(), attribute.getType()));
|
|
106 | 123 |
} |
107 | 124 |
} |
108 | 125 |
} else { |
... | ... | |
137 | 154 |
Search featureTypeSearch = (Search) ToolsLocator.getComplementsManager().get( |
138 | 155 |
Search.COMPLEMENT_MANE, featureType |
139 | 156 |
); |
140 |
List<FeatureAttributeDescriptor> attributes = featureTypeSearch.getOrderedAttributes(
|
|
157 |
List<Search.OrderedAttribute> attributes = featureTypeSearch.getOrderedAttributes(
|
|
141 | 158 |
filterByDataType, |
142 | 159 |
Search.LABEL_ORDER, |
143 | 160 |
-1 |
Also available in: Unified diff