5 |
5 |
import java.util.Collection;
|
6 |
6 |
import java.util.Iterator;
|
7 |
7 |
import java.util.List;
|
8 |
|
import java.util.Objects;
|
9 |
8 |
import org.apache.commons.lang3.StringUtils;
|
10 |
9 |
import org.gvsig.expressionevaluator.Function;
|
11 |
10 |
import org.gvsig.expressionevaluator.swing.Element;
|
... | ... | |
13 |
12 |
import org.gvsig.expressionevaluator.swing.Element.SimpleElement;
|
14 |
13 |
import org.gvsig.expressionevaluator.swing.ExpressionBuilderConfig;
|
15 |
14 |
import org.gvsig.expressionevaluator.swing.spi.AbstractElement;
|
|
15 |
import org.gvsig.fmap.dal.DALLocator;
|
16 |
16 |
import org.gvsig.fmap.dal.complements.Search;
|
|
17 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable;
|
|
18 |
import org.gvsig.fmap.dal.feature.Feature;
|
17 |
19 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
|
18 |
20 |
import org.gvsig.fmap.dal.feature.FeatureStore;
|
19 |
21 |
import org.gvsig.fmap.dal.feature.ForeingKey;
|
20 |
22 |
import org.gvsig.fmap.dal.swing.expressionevaluator.FeatureStoreElement;
|
21 |
23 |
import org.gvsig.fmap.dal.swing.impl.searchpanel.AdvancedAttributeSelectionTreeModel;
|
22 |
24 |
import org.gvsig.fmap.dal.swing.impl.searchpanel.AdvancedAttributeSelectionTreeModel.Node;
|
23 |
|
import static org.gvsig.tools.dataTypes.DataTypes.URL;
|
24 |
25 |
import org.gvsig.tools.swing.api.ToolsSwingLocator;
|
25 |
26 |
import org.gvsig.tools.swing.icontheme.IconTheme;
|
26 |
27 |
|
... | ... | |
32 |
33 |
extends AbstractElement
|
33 |
34 |
implements SimpleElement, GroupElement, FeatureStoreElement {
|
34 |
35 |
|
|
36 |
private final static String DEFAULT_ELEMENT_NAME = "store";
|
|
37 |
|
35 |
38 |
private class ForeingKeyElement
|
36 |
39 |
extends FeatureAttributeElement
|
37 |
40 |
implements SimpleElement, GroupElement {
|
... | ... | |
158 |
161 |
private AdvancedAttributeSelectionTreeModel treemodel;
|
159 |
162 |
|
160 |
163 |
public DefaultFeatureStoreElement2(FeatureStore store) {
|
161 |
|
super("store", "store", "featurestore-table");
|
|
164 |
super(DEFAULT_ELEMENT_NAME, "store", "featurestore-table");
|
162 |
165 |
this.setFeatureStore(store);
|
163 |
166 |
}
|
164 |
167 |
|
... | ... | |
192 |
195 |
|
193 |
196 |
@Override
|
194 |
197 |
public List<Element> getElements() {
|
|
198 |
if( this.treemodel==null ) {
|
|
199 |
return null;
|
|
200 |
}
|
195 |
201 |
if (this.elements == null) {
|
196 |
202 |
this.elements = new ArrayList<>();
|
197 |
203 |
Node root = (Node) treemodel.getRoot();
|
... | ... | |
233 |
239 |
}
|
234 |
240 |
|
235 |
241 |
@Override
|
236 |
|
public final void setFeatureStore(FeatureStore store) {
|
237 |
|
this.store = store;
|
238 |
|
if (store == null) {
|
239 |
|
this.treemodel = null;
|
240 |
|
} else {
|
241 |
|
this.treemodel = new AdvancedAttributeSelectionTreeModel(store, Search.ALL_FILTER);
|
242 |
|
}
|
|
242 |
public FeatureStore getFeatureStore() {
|
|
243 |
return this.store;
|
243 |
244 |
}
|
244 |
245 |
|
245 |
246 |
@Override
|
246 |
|
public FeatureStore getFeatureStore() {
|
247 |
|
return this.store;
|
|
247 |
public final void setFeatureStore(FeatureStore store) {
|
|
248 |
this.store = store;
|
|
249 |
this.init();
|
248 |
250 |
}
|
249 |
251 |
|
250 |
252 |
@Override
|
251 |
253 |
public Element setConfig(ExpressionBuilderConfig config) {
|
252 |
254 |
super.setConfig(config);
|
253 |
|
if (this.elements != null) {
|
254 |
|
for (Element element : this.elements) {
|
255 |
|
element.setConfig(config);
|
256 |
|
}
|
257 |
|
}
|
|
255 |
this.init();
|
258 |
256 |
return this;
|
259 |
257 |
}
|
260 |
258 |
|
|
259 |
private void init() {
|
|
260 |
this.treemodel = null;
|
|
261 |
this.elements = null;
|
|
262 |
if (this.store == null || this.getConfig()==null ) {
|
|
263 |
return;
|
|
264 |
}
|
|
265 |
if( StringUtils.equalsIgnoreCase(DEFAULT_ELEMENT_NAME, this.store.getName()) ) {
|
|
266 |
this.setName(this.store.getName());
|
|
267 |
}
|
|
268 |
Feature sampleFeature = this.store.getSampleFeature();
|
|
269 |
if( sampleFeature!=null ) {
|
|
270 |
FeatureSymbolTable featureSymbolTable = DALLocator.getDataManager().createFeatureSymbolTable();
|
|
271 |
featureSymbolTable.setFeature(sampleFeature);
|
|
272 |
this.getConfig().setPreviewSymbolTable(featureSymbolTable.createParent());
|
|
273 |
}
|
|
274 |
this.treemodel = new AdvancedAttributeSelectionTreeModel(this.store, Search.ALL_FILTER);
|
|
275 |
}
|
261 |
276 |
}
|