Revision 46472
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.api/src/main/java/org/gvsig/fmap/dal/swing/DataSwingManager.java | ||
---|---|---|
34 | 34 |
import javax.swing.table.TableModel; |
35 | 35 |
import javax.swing.text.JTextComponent; |
36 | 36 |
import javax.swing.tree.TreeModel; |
37 |
import org.gvsig.expressionevaluator.Expression; |
|
37 | 38 |
import org.gvsig.expressionevaluator.swing.ExpressionBuilderConfig; |
38 | 39 |
import org.gvsig.expressionevaluator.swing.ExpressionPickerController; |
39 | 40 |
import org.gvsig.expressionevaluator.swing.JExpressionBuilder; |
... | ... | |
156 | 157 |
|
157 | 158 |
public SimpleFeaturesTableModel createSimpleFeaturesTableModel(FeatureType featureType, List<String> columnNames, List<Feature> features); |
158 | 159 |
|
160 |
public SimpleFeaturesTableModel createSimpleFeaturesTableModel(FeatureStore store, Expression filter); |
|
161 |
|
|
162 |
public SimpleFeaturesTableModel createSimpleEditedFeaturesTableModel(FeatureStore store, Expression filter); |
|
163 |
|
|
164 |
public SimpleFeaturesTableModel createSimpleSelectedFeaturesTableModel(FeatureStore store, Expression filter); |
|
165 |
|
|
159 | 166 |
public FeatureAttributeListCellRenderer createDefaultFeatureAttributeListCellRenderer(); |
160 | 167 |
|
161 | 168 |
public FeatureQueryOrderPanel createFeatureStoreOrderPanel(); |
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/DefaultDataSwingManager.java | ||
---|---|---|
38 | 38 |
import javax.swing.text.JTextComponent; |
39 | 39 |
import javax.swing.tree.TreeModel; |
40 | 40 |
import org.apache.commons.lang3.StringUtils; |
41 |
import org.gvsig.expressionevaluator.Expression; |
|
41 | 42 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
42 | 43 |
import org.gvsig.expressionevaluator.swing.Element; |
43 | 44 |
import org.gvsig.expressionevaluator.swing.ExpressionBuilderConfig; |
... | ... | |
99 | 100 |
import org.gvsig.tools.exception.BaseException; |
100 | 101 |
import org.gvsig.fmap.dal.swing.DALActionFactory; |
101 | 102 |
import org.gvsig.fmap.dal.swing.DALActionFactory.DALActionContext; |
102 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
|
103 | 103 |
import org.gvsig.fmap.dal.swing.ProjectionPickerController; |
104 | 104 |
import org.gvsig.fmap.dal.swing.impl.featuretable.SimpleFeaturesTableModelImpl; |
105 | 105 |
import org.gvsig.fmap.dal.swing.impl.featuretype.FeatureAttributeListCellRendererImpl; |
... | ... | |
119 | 119 |
import org.gvsig.fmap.dal.swing.impl.expressionevaluator.suggestions.QuotesForFieldNameSuggestionProviderFactory; |
120 | 120 |
import org.gvsig.fmap.dal.swing.impl.expressionevaluator.suggestions.StorePointFieldSuggestionProviderFactory; |
121 | 121 |
import org.gvsig.fmap.dal.swing.impl.expressionevaluator.suggestions.WrongNameFieldSuggestionProviderFactory; |
122 |
import org.gvsig.fmap.dal.swing.impl.featuretable.SimpleEditedFeaturesTableModelImpl; |
|
123 |
import org.gvsig.fmap.dal.swing.impl.featuretable.SimpleSelectedFeaturesTableModelImpl; |
|
122 | 124 |
import org.gvsig.fmap.dal.swing.impl.storerepository.StoresRepositoryTreeModel; |
123 | 125 |
import org.gvsig.fmap.dal.swing.searchPostProcess.SearchPostProcessFactory; |
124 | 126 |
import org.gvsig.tools.dynform.DynFormDefinition; |
... | ... | |
478 | 480 |
throw new RuntimeException("Can't creatre SimpleFeaturesTableModel.", ex); |
479 | 481 |
} |
480 | 482 |
} |
483 |
|
|
484 |
@Override |
|
485 |
public SimpleFeaturesTableModel createSimpleFeaturesTableModel(FeatureStore store, Expression filter) { |
|
486 |
try { |
|
487 |
SimpleFeaturesTableModelImpl m = new SimpleFeaturesTableModelImpl(store, filter); |
|
488 |
return m; |
|
489 |
} catch (DataException ex) { |
|
490 |
throw new RuntimeException("Can't creatre SimpleFeaturesTableModel.", ex); |
|
491 |
} |
|
492 |
} |
|
493 |
|
|
494 |
@Override |
|
495 |
public SimpleFeaturesTableModel createSimpleEditedFeaturesTableModel(FeatureStore store, Expression filter) { |
|
496 |
SimpleFeaturesTableModelImpl m = new SimpleEditedFeaturesTableModelImpl(store, filter); |
|
497 |
return m; |
|
498 |
} |
|
481 | 499 |
|
482 | 500 |
@Override |
501 |
public SimpleFeaturesTableModel createSimpleSelectedFeaturesTableModel(FeatureStore store, Expression filter) { |
|
502 |
SimpleFeaturesTableModelImpl m = new SimpleSelectedFeaturesTableModelImpl(store, filter); |
|
503 |
return m; |
|
504 |
} |
|
505 |
|
|
506 |
@Override |
|
483 | 507 |
public SimpleFeaturesTableModel createSimpleFeaturesTableModel(FeatureType featureType, List<String> columnNames, List<Feature> features) { |
484 | 508 |
SimpleFeaturesTableModelImpl m = new SimpleFeaturesTableModelImpl(featureType, columnNames, features); |
485 | 509 |
return m; |
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/featuretable/SimpleEditedFeaturesTableModelImpl.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.swing.impl.featuretable; |
|
2 |
|
|
3 |
import org.gvsig.expressionevaluator.Expression; |
|
4 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
5 |
|
|
6 |
/** |
|
7 |
* |
|
8 |
* @author jjdelcerro |
|
9 |
*/ |
|
10 |
public class SimpleEditedFeaturesTableModelImpl extends SimpleFeatureReferencesTableModelImpl { |
|
11 |
// |
|
12 |
// FIXME: Esta clase es provisional y habria que rehacerla para que tirase |
|
13 |
// de una version especial del PagingHelper. |
|
14 |
// |
|
15 |
|
|
16 |
public SimpleEditedFeaturesTableModelImpl(FeatureStore store, Expression filter) { |
|
17 |
super(store.getDefaultFeatureTypeQuietly(), store.getEditedFeatures(), filter); |
|
18 |
} |
|
19 |
} |
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/featuretable/SimpleFeatureReferencesTableModelImpl.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.swing.impl.featuretable; |
|
2 |
|
|
3 |
import java.util.AbstractList; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.List; |
|
6 |
import org.gvsig.expressionevaluator.Expression; |
|
7 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
|
8 |
import org.gvsig.fmap.dal.DALLocator; |
|
9 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable; |
|
10 |
import org.gvsig.fmap.dal.feature.Feature; |
|
11 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
12 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
13 |
import org.gvsig.tools.dataTypes.DataTypeUtils; |
|
14 |
|
|
15 |
/** |
|
16 |
* |
|
17 |
* @author jjdelcerro |
|
18 |
*/ |
|
19 |
@SuppressWarnings("UseSpecificCatch") |
|
20 |
public class SimpleFeatureReferencesTableModelImpl extends SimpleFeaturesTableModelImpl { |
|
21 |
// |
|
22 |
// FIXME: Esta clase es provisional y habria que rehacerla para que tirase |
|
23 |
// de una version especial del PagingHelper. |
|
24 |
// |
|
25 |
|
|
26 |
private static class FeatureReferenceListToFeatureListAdapter extends AbstractList<Feature> { |
|
27 |
|
|
28 |
private final List<FeatureReference> references; |
|
29 |
private Feature lastFeature; |
|
30 |
private int lastIndex; |
|
31 |
|
|
32 |
public FeatureReferenceListToFeatureListAdapter(List<FeatureReference> references) { |
|
33 |
this.references = references; |
|
34 |
this.lastFeature = null; |
|
35 |
this.lastIndex = -1; |
|
36 |
|
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public Feature get(int index) { |
|
41 |
if( index == this.lastIndex && this.lastFeature != null ) { |
|
42 |
return this.lastFeature; |
|
43 |
} |
|
44 |
try { |
|
45 |
this.lastFeature = this.references.get(index).getFeature(); |
|
46 |
this.lastIndex = index; |
|
47 |
return this.lastFeature; |
|
48 |
} catch(Exception ex) { |
|
49 |
// FIXME |
|
50 |
return null; |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public int size() { |
|
56 |
return this.references.size(); |
|
57 |
} |
|
58 |
|
|
59 |
} |
|
60 |
|
|
61 |
public SimpleFeatureReferencesTableModelImpl(FeatureType featureType, List<FeatureReference> references, Expression filter) { |
|
62 |
super(featureType, null, createAdapter(references, filter)); |
|
63 |
} |
|
64 |
|
|
65 |
private static List<Feature> createAdapter(List<FeatureReference> references, Expression filter) { |
|
66 |
if( ExpressionUtils.isPhraseEmpty(filter) ) { |
|
67 |
return new FeatureReferenceListToFeatureListAdapter(references); |
|
68 |
} |
|
69 |
// FIXME |
|
70 |
// Esto deberia ser temporal, es una animalada en cuanto a rendimientos. |
|
71 |
List<FeatureReference> r = new ArrayList<>(); |
|
72 |
FeatureSymbolTable st = DALLocator.getDataManager().createFeatureSymbolTable(); |
|
73 |
for (FeatureReference featureReference : r) { |
|
74 |
try { |
|
75 |
Feature f = featureReference.getFeature(); |
|
76 |
st.setFeature(f); |
|
77 |
Object x = filter.execute(st); |
|
78 |
if( DataTypeUtils.isTrue(x, false) ) { |
|
79 |
r.add(featureReference); |
|
80 |
} |
|
81 |
} catch(Exception ex) { |
|
82 |
// Skyp feature |
|
83 |
} |
|
84 |
} |
|
85 |
return new FeatureReferenceListToFeatureListAdapter(r); |
|
86 |
} |
|
87 |
|
|
88 |
|
|
89 |
} |
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/featuretable/SimpleFeaturesTableModelImpl.java | ||
---|---|---|
6 | 6 |
import java.awt.FontMetrics; |
7 | 7 |
import java.awt.Insets; |
8 | 8 |
import org.gvsig.fmap.dal.swing.featuretable.SimpleFeaturesTableModel; |
9 |
import java.math.BigDecimal; |
|
10 | 9 |
import java.util.ArrayList; |
11 | 10 |
import java.util.Collections; |
12 |
import java.util.HashMap; |
|
13 | 11 |
import java.util.Iterator; |
14 | 12 |
import java.util.List; |
15 | 13 |
import java.util.Map; |
... | ... | |
17 | 15 |
import javax.swing.JCheckBox; |
18 | 16 |
import javax.swing.JComponent; |
19 | 17 |
import javax.swing.JLabel; |
20 |
import javax.swing.JScrollPane; |
|
21 | 18 |
import javax.swing.JTable; |
22 | 19 |
import javax.swing.SwingConstants; |
23 | 20 |
import javax.swing.UIManager; |
... | ... | |
26 | 23 |
import javax.swing.table.DefaultTableColumnModel; |
27 | 24 |
import javax.swing.table.TableCellRenderer; |
28 | 25 |
import javax.swing.table.TableColumn; |
29 |
import javax.swing.table.TableColumnModel; |
|
30 | 26 |
import org.apache.commons.lang3.StringUtils; |
27 |
import org.gvsig.expressionevaluator.Expression; |
|
31 | 28 |
import org.gvsig.fmap.dal.complements.Search; |
32 | 29 |
import org.gvsig.fmap.dal.exception.DataException; |
33 | 30 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
... | ... | |
35 | 32 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
36 | 33 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
37 | 34 |
import org.gvsig.fmap.dal.feature.FeatureType; |
38 |
import org.gvsig.fmap.dal.feature.ForeingKey; |
|
39 | 35 |
import org.gvsig.fmap.dal.feature.paging.FacadeOfAFeaturePagingHelper; |
40 | 36 |
import org.gvsig.tools.ToolsLocator; |
41 |
import org.gvsig.tools.dataTypes.Coercion; |
|
42 |
import org.gvsig.tools.dataTypes.CoercionException; |
|
43 | 37 |
import org.gvsig.tools.dataTypes.DataTypeUtils; |
44 | 38 |
import org.gvsig.tools.dataTypes.DataTypes; |
45 | 39 |
import org.gvsig.tools.dispose.DisposeUtils; |
... | ... | |
193 | 187 |
this(store.getDefaultFeatureType(), null, store.getFeatures()); |
194 | 188 |
} |
195 | 189 |
|
190 |
public SimpleFeaturesTableModelImpl(FeatureStore store, Expression filter) throws DataException { |
|
191 |
this(store.getDefaultFeatureType(), null, store.getFeatures(filter)); |
|
192 |
} |
|
193 |
|
|
196 | 194 |
public SimpleFeaturesTableModelImpl(FeatureType featureType) { |
197 | 195 |
this(featureType, null, null); |
198 | 196 |
this.logger = new FilteredLogger(LOGGER, "SimpleFeaturesTableModel", 10); |
... | ... | |
314 | 312 |
} |
315 | 313 |
|
316 | 314 |
@Override |
315 |
public void dispose() { |
|
316 |
if (this.features != null) { |
|
317 |
if( this.features instanceof FacadeOfAFeaturePagingHelper) { |
|
318 |
DisposeUtils.disposeQuietly(((FacadeOfAFeaturePagingHelper) features).getFeaturePagingHelper()); |
|
319 |
} else { |
|
320 |
DisposeUtils.disposeQuietly(features); |
|
321 |
} |
|
322 |
this.features = null; |
|
323 |
} |
|
324 |
this.features = null; |
|
325 |
} |
|
326 |
|
|
327 |
@Override |
|
317 | 328 |
public int getRowCount() { |
318 |
if (this.features == null) {
|
|
329 |
if (this.getFeatures() == null) {
|
|
319 | 330 |
return 0; |
320 | 331 |
} |
321 | 332 |
try { |
322 |
return this.features.size();
|
|
333 |
return this.getFeatures().size();
|
|
323 | 334 |
} catch (Throwable ex) { |
324 | 335 |
this.errors = true; |
325 | 336 |
LOGGER.warn("Can't calculate row count.", ex); |
... | ... | |
407 | 418 |
|
408 | 419 |
@Override |
409 | 420 |
public Feature get(int position) { |
410 |
if (this.features == null) {
|
|
421 |
if (this.getFeatures() == null) {
|
|
411 | 422 |
return null; |
412 | 423 |
} |
413 |
Feature feature = this.features.get(position);
|
|
424 |
Feature feature = this.getFeatures().get(position);
|
|
414 | 425 |
return feature; |
415 | 426 |
} |
416 | 427 |
|
417 | 428 |
@Override |
418 | 429 |
public Feature getFeatureAt(int rowIndex) { |
419 |
if (this.features == null || rowIndex<0 ) {
|
|
430 |
if (this.getFeatures() == null || rowIndex<0 ) {
|
|
420 | 431 |
return null; |
421 | 432 |
} |
422 | 433 |
try { |
423 |
Feature feature = this.features.get(rowIndex);
|
|
434 |
Feature feature = this.getFeatures().get(rowIndex);
|
|
424 | 435 |
return feature; |
425 | 436 |
} catch (Throwable th) { |
426 | 437 |
this.errors = true; |
... | ... | |
431 | 442 |
|
432 | 443 |
@Override |
433 | 444 |
public Object getValueAt(int rowIndex, int columnIndex) { |
434 |
if (this.features == null) {
|
|
445 |
if (this.getFeatures() == null) {
|
|
435 | 446 |
return null; |
436 | 447 |
} |
437 | 448 |
try { |
438 |
Feature feature = this.features.get(rowIndex);
|
|
449 |
Feature feature = this.getFeatures().get(rowIndex);
|
|
439 | 450 |
String attrName = this.columnNames.get(columnIndex); |
440 | 451 |
Object value = null; |
441 | 452 |
value = feature.get(attrName); |
... | ... | |
466 | 477 |
|
467 | 478 |
@Override |
468 | 479 |
public List<Feature> toList() { |
469 |
return this.features;
|
|
480 |
return this.getFeatures();
|
|
470 | 481 |
} |
471 | 482 |
|
472 | 483 |
@Override |
473 | 484 |
public boolean isEmpty() { |
474 |
return this.features.isEmpty();
|
|
485 |
return this.getFeatures().isEmpty();
|
|
475 | 486 |
} |
476 | 487 |
|
477 | 488 |
@Override |
478 | 489 |
public int size() { |
479 |
return this.features.size();
|
|
490 |
return this.getFeatures().size();
|
|
480 | 491 |
} |
481 | 492 |
|
482 | 493 |
@Override |
483 | 494 |
public Iterator<Feature> iterator() { |
484 |
return this.features.iterator();
|
|
495 |
return this.getFeatures().iterator();
|
|
485 | 496 |
} |
486 | 497 |
|
487 |
@Override |
|
488 |
public void dispose() { |
|
489 |
if (this.features != null) { |
|
490 |
DisposeUtils.disposeQuietly(((FacadeOfAFeaturePagingHelper) features).getFeaturePagingHelper()); |
|
491 |
this.features = null; |
|
492 |
} |
|
493 |
this.features = null; |
|
494 |
} |
|
495 |
|
|
496 | 498 |
} |
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/featuretable/SimpleSelectedFeaturesTableModelImpl.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.swing.impl.featuretable; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Collections; |
|
5 |
import java.util.List; |
|
6 |
import org.gvsig.expressionevaluator.Expression; |
|
7 |
import org.gvsig.fmap.dal.exception.DataException; |
|
8 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
9 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
10 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
11 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
12 |
|
|
13 |
/** |
|
14 |
* |
|
15 |
* @author jjdelcerro |
|
16 |
*/ |
|
17 |
@SuppressWarnings("UseSpecificCatch") |
|
18 |
public class SimpleSelectedFeaturesTableModelImpl extends SimpleFeatureReferencesTableModelImpl { |
|
19 |
// |
|
20 |
// FIXME: Esta clase es provisional y habria que rehacerla para que tirase |
|
21 |
// de una version especial del PagingHelper. |
|
22 |
// |
|
23 |
public SimpleSelectedFeaturesTableModelImpl(FeatureStore store, Expression filter) { |
|
24 |
super(store.getDefaultFeatureTypeQuietly(), getFeatureReferences(store), filter); |
|
25 |
} |
|
26 |
|
|
27 |
public SimpleSelectedFeaturesTableModelImpl(FeatureType featureType, FeatureSelection selection, Expression filter) { |
|
28 |
super(featureType, getFeatureReferences(selection), filter); |
|
29 |
} |
|
30 |
|
|
31 |
private static List<FeatureReference> getFeatureReferences(FeatureStore store) { |
|
32 |
try { |
|
33 |
return getFeatureReferences(store.getFeatureSelection()); |
|
34 |
} catch (DataException ex) { |
|
35 |
// FIXME |
|
36 |
return null; |
|
37 |
} |
|
38 |
} |
|
39 |
|
|
40 |
private static List<FeatureReference> getFeatureReferences(FeatureSelection selection) { |
|
41 |
try { |
|
42 |
List<FeatureReference> r = new ArrayList<>(); |
|
43 |
for (FeatureReference featureReference : selection.referenceIterable()) { |
|
44 |
|
|
45 |
r.add(featureReference); |
|
46 |
} |
|
47 |
return r; |
|
48 |
} catch(Exception ex) { |
|
49 |
return Collections.EMPTY_LIST; |
|
50 |
} |
|
51 |
} |
|
52 |
} |
Also available in: Unified diff