Revision 44753
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultDataManager.java | ||
---|---|---|
51 | 51 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureAttributeEmulatorExpression; |
52 | 52 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable; |
53 | 53 |
import org.gvsig.fmap.dal.feature.DataProfile; |
54 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
54 | 55 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
55 | 56 |
import org.gvsig.fmap.dal.feature.Feature; |
56 | 57 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
... | ... | |
60 | 61 |
import org.gvsig.fmap.dal.feature.ForeingKey; |
61 | 62 |
import static org.gvsig.fmap.dal.feature.ForeingKey.MAX_AVAILABLE_VALUES; |
62 | 63 |
import org.gvsig.fmap.dal.feature.impl.DALFile; |
64 |
import org.gvsig.fmap.dal.feature.impl.DefaultEditableFeatureAttributeDescriptor; |
|
63 | 65 |
import org.gvsig.fmap.dal.feature.impl.DefaultEditableFeatureType; |
66 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureAttributeDescriptor; |
|
64 | 67 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureIndex; |
65 | 68 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore; |
66 | 69 |
import org.gvsig.fmap.dal.feature.impl.FeatureStoreFactory; |
... | ... | |
102 | 105 |
import org.gvsig.tools.script.Script; |
103 | 106 |
import org.gvsig.tools.script.ScriptManager; |
104 | 107 |
import org.gvsig.tools.service.spi.Services; |
105 |
import org.gvsig.tools.util.Callable; |
|
106 |
import org.gvsig.tools.util.Invocable; |
|
107 | 108 |
import org.slf4j.Logger; |
108 | 109 |
import org.slf4j.LoggerFactory; |
109 | 110 |
|
... | ... | |
1258 | 1259 |
return s; |
1259 | 1260 |
} |
1260 | 1261 |
|
1262 |
@Override |
|
1263 |
public EditableFeatureAttributeDescriptor createFeatureAttributeDescriptor() { |
|
1264 |
DefaultEditableFeatureAttributeDescriptor edi = new DefaultEditableFeatureAttributeDescriptor(null, false); |
|
1265 |
return edi; |
|
1266 |
} |
|
1267 |
|
|
1261 | 1268 |
@Override |
1262 | 1269 |
public DALExpressionBuilder createDALExpressionBuilder() { |
1263 | 1270 |
return new DefaultDALExpressionBuilder(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureType.java | ||
---|---|---|
44 | 44 |
|
45 | 45 |
import org.gvsig.fmap.dal.DataTypes; |
46 | 46 |
import org.gvsig.fmap.dal.exception.DataException; |
47 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
47 | 48 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
48 | 49 |
import org.gvsig.fmap.dal.feature.Feature; |
49 | 50 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
50 | 51 |
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
52 |
import org.gvsig.fmap.dal.feature.FeatureExtraColumn; |
|
51 | 53 |
import org.gvsig.fmap.dal.feature.FeatureRules; |
52 | 54 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
53 | 55 |
import org.gvsig.fmap.dal.feature.FeatureType; |
... | ... | |
106 | 108 |
private String description; |
107 | 109 |
private String label; |
108 | 110 |
private Tags tags; |
111 |
// private List<FeatureAttributeDescriptor> descriptors; |
|
112 |
private FeatureExtraColumn extraColumn; |
|
109 | 113 |
|
110 | 114 |
public DefaultFeatureType() { |
111 | 115 |
// Usado en la persistencia. |
... | ... | |
120 | 124 |
this.defaultTimeAttributeIndex = -1; |
121 | 125 |
this.allowAtomaticValues = false; |
122 | 126 |
this.tags = new DefaultTags(); |
127 |
this.extraColumn = new DefaultFeatureExtraColumn(); |
|
123 | 128 |
} |
124 | 129 |
|
125 | 130 |
protected DefaultFeatureType(FeatureStore store, String id) { |
... | ... | |
404 | 409 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
405 | 410 |
} |
406 | 411 |
|
412 |
@Override |
|
413 |
public FeatureExtraColumn getExtraColumn() { |
|
414 |
return extraColumn; |
|
415 |
} |
|
416 |
|
|
417 |
public void setExtraColumn(FeatureExtraColumn extraColumn) { //List<FeatureAttributeDescriptor> descriptors) { |
|
418 |
this.extraColumn = extraColumn; |
|
419 |
} |
|
420 |
|
|
407 | 421 |
class SubtypeFeatureType extends DefaultFeatureType { |
408 | 422 |
|
409 | 423 |
/** |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureExtraColumn.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.fmap.dal.feature.impl; |
|
7 |
|
|
8 |
import java.util.ArrayList; |
|
9 |
import java.util.List; |
|
10 |
import org.apache.commons.lang3.StringUtils; |
|
11 |
import org.gvsig.fmap.dal.DALLocator; |
|
12 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
13 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
14 |
import org.gvsig.fmap.dal.feature.FeatureExtraColumn; |
|
15 |
|
|
16 |
/** |
|
17 |
* |
|
18 |
* @author osc |
|
19 |
*/ |
|
20 |
public class DefaultFeatureExtraColumn implements FeatureExtraColumn { |
|
21 |
|
|
22 |
private List<EditableFeatureAttributeDescriptor> extraColumns; |
|
23 |
public DefaultFeatureExtraColumn() { |
|
24 |
this.extraColumns = new ArrayList(); |
|
25 |
} |
|
26 |
@Override |
|
27 |
public EditableFeatureAttributeDescriptor get(String columnName) { |
|
28 |
for (EditableFeatureAttributeDescriptor extraColumn : this.extraColumns) { |
|
29 |
if (StringUtils.equals(extraColumn.getName(), columnName)) { |
|
30 |
return extraColumn; |
|
31 |
} |
|
32 |
} |
|
33 |
return null; |
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
public EditableFeatureAttributeDescriptor add(String name) { |
|
38 |
//TODO que no hayan dos columnas iguales |
|
39 |
// exi.addExtraColumn() |
|
40 |
EditableFeatureAttributeDescriptor newAttr = DALLocator.getDataManager().createFeatureAttributeDescriptor(); |
|
41 |
newAttr.setName(name); |
|
42 |
extraColumns.add(newAttr); |
|
43 |
return newAttr; |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public List<EditableFeatureAttributeDescriptor> getColumns() { |
|
48 |
return this.extraColumns; |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public void merge(FeatureExtraColumn other) { |
|
53 |
this.extraColumns.addAll(other.getColumns()); |
|
54 |
} |
|
55 |
|
|
56 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStoreTransforms.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
import org.gvsig.fmap.dal.exception.DataException; |
33 | 33 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
34 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
34 | 35 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
35 | 36 |
import org.gvsig.fmap.dal.feature.Feature; |
37 |
import org.gvsig.fmap.dal.feature.FeatureExtraColumn; |
|
36 | 38 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
37 | 39 |
import org.gvsig.fmap.dal.feature.FeatureStoreNotification; |
38 | 40 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransform; |
... | ... | |
249 | 251 |
FeatureStoreTransform transform = transforms.get(i); |
250 | 252 |
tmpFType = transform.getSourceFeatureTypeFrom(tmpFType); |
251 | 253 |
} |
254 |
// se mantienen |
|
255 |
List<EditableFeatureAttributeDescriptor> extraCols = targetFeatureType.getExtraColumn().getColumns(); |
|
256 |
if (extraCols!=null & !extraCols.isEmpty()) { |
|
257 |
FeatureExtraColumn tmpExtraCols = tmpFType.getExtraColumn(); |
|
258 |
tmpExtraCols.merge(targetFeatureType.getExtraColumn()); |
|
259 |
((DefaultFeatureType) tmpFType).setExtraColumn(tmpExtraCols); |
|
260 |
} |
|
252 | 261 |
return tmpFType; |
253 | 262 |
} |
254 | 263 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/featureset/DefaultFeatureSet.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
import org.gvsig.fmap.dal.exception.DataException; |
33 | 33 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
34 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
35 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
34 | 36 |
import org.gvsig.fmap.dal.feature.Feature; |
37 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
35 | 38 |
import org.gvsig.fmap.dal.feature.FeatureIndexes; |
36 | 39 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
37 | 40 |
import org.gvsig.fmap.dal.feature.FeatureQueryOrder; |
... | ... | |
44 | 47 |
import org.gvsig.fmap.dal.feature.exception.FeatureSetInitializeException; |
45 | 48 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore; |
46 | 49 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreTransforms; |
50 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureType; |
|
47 | 51 |
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider; |
48 | 52 |
import org.gvsig.tools.dispose.DisposableIterator; |
49 | 53 |
import org.gvsig.tools.dispose.DisposeUtils; |
... | ... | |
76 | 80 |
protected Feature featureToIgnoreNotification; |
77 | 81 |
protected DefaultFeatureStoreTransforms transform; |
78 | 82 |
protected FeatureQuery queryForProvider; |
79 |
protected FeatureType defatulFeatureType;
|
|
83 |
protected FeatureType defaultFeatureType;
|
|
80 | 84 |
protected FeatureType defatulFeatureTypeForProvider; |
81 | 85 |
protected boolean ignoreChanges; |
82 | 86 |
|
... | ... | |
105 | 109 |
this.featureTypes = new ArrayList(); |
106 | 110 |
if (this.query.getFeatureTypeId() == null |
107 | 111 |
&& this.query.getAttributeNames() == null) { |
108 |
this.defatulFeatureType = this.store.getDefaultFeatureType();
|
|
112 |
this.defaultFeatureType = this.store.getDefaultFeatureType();
|
|
109 | 113 |
this.featureTypes.addAll(this.store.getFeatureTypes()); |
110 | 114 |
} else { |
111 |
this.defatulFeatureType = this.store.getFeatureType(this.query); |
|
112 |
this.featureTypes.add(this.defatulFeatureType); |
|
115 |
this.defaultFeatureType = this.store.getFeatureType(this.query); |
|
116 |
List<EditableFeatureAttributeDescriptor> cols = this.query.getExtraColumn().getColumns(); |
|
117 |
if (this.query!=null && cols!=null && !cols.isEmpty()) { |
|
118 |
DefaultFeatureType featureTypeExtraCols = (DefaultFeatureType) this.defaultFeatureType.getCopy(); |
|
119 |
featureTypeExtraCols.setExtraColumn(this.query.getExtraColumn()); |
|
120 |
this.defaultFeatureType = featureTypeExtraCols; |
|
121 |
} |
|
122 |
this.featureTypes.add(this.defaultFeatureType); |
|
113 | 123 |
} |
114 | 124 |
if (this.transform != null && !this.transform.isEmpty()) { |
115 | 125 |
this.fixQueryForProvider(this.queryForProvider, this.transform); |
116 | 126 |
} else { |
117 |
this.defatulFeatureTypeForProvider = this.defatulFeatureType;
|
|
127 |
this.defatulFeatureTypeForProvider = this.defaultFeatureType;
|
|
118 | 128 |
} |
119 | 129 |
|
120 | 130 |
FeatureIndexes indexes = store.getIndexes(); |
... | ... | |
136 | 146 |
DefaultFeatureStoreTransforms transformsToUse) throws DataException { |
137 | 147 |
theQueryForProvider.clearAttributeNames(); |
138 | 148 |
FeatureType ftype = |
139 |
transformsToUse.getSourceFeatureTypeFrom(this.defatulFeatureType);
|
|
149 |
transformsToUse.getSourceFeatureTypeFrom(this.defaultFeatureType);
|
|
140 | 150 |
theQueryForProvider.setFeatureTypeId(ftype.getId()); |
141 | 151 |
this.defatulFeatureTypeForProvider = ftype; |
142 | 152 |
|
... | ... | |
213 | 223 |
} |
214 | 224 |
|
215 | 225 |
public FeatureType getDefaultFeatureType() { |
216 |
return this.defatulFeatureType;
|
|
226 |
return this.defaultFeatureType;
|
|
217 | 227 |
} |
218 | 228 |
|
219 | 229 |
public List getFeatureTypes() { |
... | ... | |
289 | 299 |
this.query = null; |
290 | 300 |
this.queryForProvider = null; |
291 | 301 |
this.featureTypes = null; |
292 |
this.defatulFeatureType = null;
|
|
302 |
this.defaultFeatureType = null;
|
|
293 | 303 |
this.defatulFeatureTypeForProvider = null; |
294 | 304 |
} |
295 | 305 |
|
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/featurequery/DefaultFeatureQueryGroupByPanel.java | ||
---|---|---|
183 | 183 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
184 | 184 |
FilteredListModel model = toolsSwingManager.createFilteredListModel(); |
185 | 185 |
for (FeatureAttributeDescriptor attr : featureType) { |
186 |
model.addElement(attr); |
|
186 |
model.addElement(attr);
|
|
187 | 187 |
} |
188 | 188 |
model.setFilter(this.txtAttributesFilter.getText()); |
189 | 189 |
model.sort(true); |
... | ... | |
191 | 191 |
this.lstAttributes.setSelectedIndex(indexAttributes); |
192 | 192 |
this.txtCurrentAttributeName.setText(""); |
193 | 193 |
this.cboAggretateFunctions.setSelectedIndex(0); |
194 |
|
|
195 |
// |
|
196 |
//groupByPanel.setSelectedNames(query.getGroupByColumns()); |
|
194 | 197 |
} |
195 | 198 |
|
196 | 199 |
@Override |
... | ... | |
213 | 216 |
@Override |
214 | 217 |
public void put(FeatureQuery query) { |
215 | 218 |
this.query.copyFrom(query); |
219 |
groupByPanel.setSelectedNames(query.getGroupByColumns()); |
|
216 | 220 |
this.updateControls(); |
217 | 221 |
} |
218 | 222 |
|
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/featurequery/DefaultFeatureQueryCalculatedColumnsPanel.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.dal.swing.impl.featurequery; |
2 | 2 |
|
3 | 3 |
import java.awt.Dimension; |
4 |
import java.awt.event.ActionEvent; |
|
4 | 5 |
import java.net.URL; |
6 |
import java.util.List; |
|
7 |
import javax.swing.DefaultComboBoxModel; |
|
8 |
import javax.swing.DefaultListModel; |
|
5 | 9 |
import javax.swing.ImageIcon; |
6 | 10 |
import javax.swing.JButton; |
7 | 11 |
import javax.swing.JComboBox; |
8 | 12 |
import javax.swing.JComponent; |
13 |
import javax.swing.JList; |
|
14 |
import javax.swing.ListModel; |
|
9 | 15 |
import javax.swing.event.ListSelectionEvent; |
10 | 16 |
import javax.swing.text.JTextComponent; |
11 | 17 |
import org.apache.commons.io.FilenameUtils; |
18 |
import org.apache.commons.lang.StringUtils; |
|
19 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
|
20 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
|
21 |
import org.gvsig.expressionevaluator.swing.ExpressionPickerController; |
|
12 | 22 |
import org.gvsig.expressionevaluator.swing.JExpressionBuilder; |
23 |
import org.gvsig.fmap.dal.DALLocator; |
|
13 | 24 |
import org.gvsig.fmap.dal.exception.DataException; |
25 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureAttributeEmulatorExpression; |
|
14 | 26 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
15 | 27 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
16 | 28 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
... | ... | |
18 | 30 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
19 | 31 |
import org.gvsig.fmap.dal.swing.featurequery.FeatureQueryCalculatedColumnsPanel; |
20 | 32 |
import org.gvsig.fmap.dal.swing.impl.featuretype.FeatureAttributeListCellRenderer; |
33 |
import org.gvsig.tools.dataTypes.DataType; |
|
34 |
import org.gvsig.tools.swing.api.FilteredListModel; |
|
35 |
import org.gvsig.tools.swing.api.ListElement; |
|
21 | 36 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
22 | 37 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
23 | 38 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
39 |
import org.gvsig.tools.util.LabeledValueImpl; |
|
24 | 40 |
|
25 | 41 |
/** |
26 | 42 |
* |
... | ... | |
30 | 46 |
extends DefaultFeatureQueryCalculatedColumnsPanelView |
31 | 47 |
implements FeatureQueryCalculatedColumnsPanel { |
32 | 48 |
|
33 |
private static class ColumnController { |
|
34 | 49 |
|
35 |
public ColumnController( |
|
36 |
JTextComponent btnName, |
|
37 |
JComboBox cboDataType, |
|
38 |
JButton btnDataType, |
|
39 |
JTextComponent txtExpression, |
|
40 |
JButton btnExpression, |
|
41 |
JButton btnExpressionHistory, |
|
42 |
JButton btnExpressionBookmarks |
|
43 |
) { |
|
44 |
|
|
50 |
private EditableFeatureAttributeDescriptor actualEditableAttribute; |
|
51 |
private DefaultListModel lstAttributesModel; |
|
52 |
|
|
53 |
private static class ColumnController { |
|
54 |
|
|
55 |
private final JTextComponent txtName; |
|
56 |
private final JComboBox cboDataType; |
|
57 |
private final JButton btnDataType; |
|
58 |
private final JButton btnExpressionBookmarks; |
|
59 |
private final JButton btnExpressionHistory; |
|
60 |
private final JButton btnExpression; |
|
61 |
private final JTextComponent txtExpression; |
|
62 |
private ExpressionPickerController expPicker; |
|
63 |
private EditableFeatureAttributeDescriptor attr; |
|
64 |
|
|
65 |
public ColumnController( |
|
66 |
JTextComponent txtName, |
|
67 |
JComboBox cboDataType, |
|
68 |
JButton btnDataType, |
|
69 |
JTextComponent txtExpression, |
|
70 |
JButton btnExpression, |
|
71 |
JButton btnExpressionHistory, |
|
72 |
JButton btnExpressionBookmarks |
|
73 |
) { |
|
74 |
this.txtName = txtName; |
|
75 |
this.cboDataType = cboDataType; |
|
76 |
this.btnDataType = btnDataType; |
|
77 |
this.txtExpression = txtExpression; |
|
78 |
this.btnExpression = btnExpression; |
|
79 |
this.btnExpressionHistory = btnExpressionHistory; |
|
80 |
this.btnExpressionBookmarks = btnExpressionBookmarks; |
|
81 |
this.initComponents(); |
|
82 |
this.setEnabled(false); |
|
83 |
} |
|
84 |
|
|
85 |
public void initComponents() { |
|
86 |
List<DataType> dataTypes = DALLocator.getDataManager().getDataTypes(); |
|
87 |
DefaultComboBoxModel<LabeledValueImpl<DataType>> modelColumn = new DefaultComboBoxModel<LabeledValueImpl<DataType>>(); |
|
88 |
for (DataType dataType : dataTypes) { |
|
89 |
LabeledValueImpl<DataType> labeled = new LabeledValueImpl<DataType>(dataType.getName(), dataType); |
|
90 |
modelColumn.addElement(labeled); |
|
91 |
} |
|
92 |
this.cboDataType.setModel(modelColumn); |
|
93 |
|
|
94 |
ExpressionEvaluatorSwingManager managerExpSwing = ExpressionEvaluatorSwingLocator.getManager(); |
|
95 |
this.expPicker = managerExpSwing.createExpressionPickerController( |
|
96 |
txtExpression, |
|
97 |
btnExpression, |
|
98 |
btnExpressionBookmarks, |
|
99 |
btnExpressionHistory |
|
100 |
); |
|
101 |
|
|
102 |
} |
|
103 |
|
|
104 |
public void setEnabled(boolean enabled) { |
|
105 |
this.txtName.setEnabled(enabled); |
|
106 |
this.expPicker.setEnabled(enabled); |
|
107 |
this.cboDataType.setEnabled(enabled); |
|
108 |
|
|
109 |
} |
|
110 |
|
|
111 |
public void clean() { |
|
112 |
this.txtName.setText(""); |
|
113 |
this.expPicker.set(null); |
|
114 |
this.cboDataType.setSelectedIndex(0); |
|
115 |
|
|
116 |
} |
|
117 |
|
|
118 |
public void put(EditableFeatureAttributeDescriptor attr) { |
|
119 |
this.attr = attr; |
|
120 |
this.txtName.setName(attr.getName()); |
|
121 |
FeatureAttributeEmulatorExpression emu = (FeatureAttributeEmulatorExpression) attr.getFeatureAttributeEmulator(); |
|
122 |
if (emu!=null) { |
|
123 |
this.expPicker.set(emu.getExpression()); |
|
124 |
} |
|
125 |
this.cboDataType.setSelectedItem(attr.getDataType()); |
|
126 |
|
|
127 |
} |
|
128 |
|
|
129 |
public EditableFeatureAttributeDescriptor fetch(EditableFeatureAttributeDescriptor attr) { |
|
130 |
this.attr.setName(this.txtName.getText()); |
|
131 |
this.attr.setFeatureAttributeEmulator(this.expPicker.get()); |
|
132 |
LabeledValueImpl<DataType> dataTypeValue = (LabeledValueImpl<DataType>) this.cboDataType.getSelectedItem(); |
|
133 |
this.attr.setDataType(dataTypeValue.getValue()); |
|
134 |
return null; |
|
135 |
} |
|
45 | 136 |
} |
46 |
|
|
47 |
public void setEnabled(boolean enabled) { |
|
48 |
|
|
137 |
|
|
138 |
private FeatureStore store; |
|
139 |
private FeatureType featureType; |
|
140 |
|
|
141 |
private FeatureQuery query; |
|
142 |
|
|
143 |
private ColumnController colummController; |
|
144 |
private JExpressionBuilder pckExpression; |
|
145 |
private static String COLUMN_DEFAULT_NAME = "Field"; |
|
146 |
|
|
147 |
public DefaultFeatureQueryCalculatedColumnsPanel() { |
|
148 |
this.initComponents(); |
|
49 | 149 |
} |
50 |
|
|
51 |
public void clean() { |
|
52 |
|
|
150 |
|
|
151 |
@Override |
|
152 |
public JComponent asJComponent() { |
|
153 |
return this; |
|
53 | 154 |
} |
54 |
|
|
55 |
public void put(EditableFeatureAttributeDescriptor attr) { |
|
56 |
|
|
155 |
|
|
156 |
@Override |
|
157 |
public ImageIcon loadImage(String imageName) { |
|
158 |
String name = FilenameUtils.getBaseName(imageName); |
|
159 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getDefault(); |
|
160 |
if (theme.exists(name)) { |
|
161 |
return theme.get(name); |
|
162 |
} |
|
163 |
URL url = this.getClass().getResource(name + ".png"); |
|
164 |
if (url == null) { |
|
165 |
return null; |
|
166 |
} |
|
167 |
return new ImageIcon(url); |
|
57 | 168 |
} |
58 |
|
|
59 |
public EditableFeatureAttributeDescriptor fetch(EditableFeatureAttributeDescriptor attr) { |
|
60 |
return null; |
|
169 |
|
|
170 |
@Override |
|
171 |
public void setStore(FeatureStore store) { |
|
172 |
try { |
|
173 |
this.featureType = store.getDefaultFeatureType(); |
|
174 |
this.store = store; |
|
175 |
this.query = store.createFeatureQuery(); |
|
176 |
this.pckExpression = DALSwingLocator.getManager().createQueryFilterExpresion(store); |
|
177 |
} catch (DataException ex) { |
|
178 |
throw new RuntimeException("Can't assign store", ex); |
|
179 |
} |
|
61 | 180 |
} |
62 |
} |
|
63 |
|
|
64 |
private FeatureStore store; |
|
65 |
private FeatureType featureType; |
|
66 | 181 |
|
67 |
private FeatureQuery query; |
|
68 |
|
|
69 |
private ColumnController colummController; |
|
70 |
private JExpressionBuilder pckExpression; |
|
71 |
|
|
72 |
public DefaultFeatureQueryCalculatedColumnsPanel() { |
|
73 |
this.initComponents(); |
|
74 |
} |
|
182 |
private void initComponents() { |
|
183 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
|
75 | 184 |
|
76 |
@Override |
|
77 |
public JComponent asJComponent() { |
|
78 |
return this; |
|
79 |
} |
|
185 |
this.colummController = new ColumnController( |
|
186 |
this.txtColumnName, |
|
187 |
this.cboColumnDataType, |
|
188 |
this.btnColumnDataType, |
|
189 |
this.txtColumnExpression, |
|
190 |
this.btnColumnExpression, |
|
191 |
this.btnColumnExpressionHistory, |
|
192 |
this.btnColumnExpressionBookmarks |
|
193 |
); |
|
194 |
// this.lstAttributes.setCellRenderer(new FeatureAttributeListCellRenderer()); |
|
195 |
this.lstAttributes.addListSelectionListener((ListSelectionEvent e) -> { |
|
196 |
if (e.getValueIsAdjusting()) { |
|
197 |
return; |
|
198 |
} |
|
199 |
doSelectAttribute(); |
|
200 |
}); |
|
80 | 201 |
|
81 |
@Override |
|
82 |
public ImageIcon loadImage(String imageName) { |
|
83 |
String name = FilenameUtils.getBaseName(imageName); |
|
84 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getDefault(); |
|
85 |
if (theme.exists(name)) { |
|
86 |
return theme.get(name); |
|
202 |
Dimension sz = this.getPreferredSize(); |
|
203 |
if (sz.width < DEFAULT_WIDTH) { |
|
204 |
sz.width = DEFAULT_WIDTH; |
|
205 |
} |
|
206 |
if (sz.height < DEFAULT_HEIGHT) { |
|
207 |
sz.height = DEFAULT_HEIGHT; |
|
208 |
} |
|
209 |
this.setPreferredSize(sz); |
|
210 |
|
|
211 |
this.lstAttributesModel = new DefaultListModel<ListElement<EditableFeatureAttributeDescriptor>>(); |
|
212 |
// this.lstAttributesModel = ToolsSwingLocator.getToolsSwingManager().createFilteredListModel(); |
|
213 |
this.lstAttributes.setModel(lstAttributesModel); |
|
214 |
|
|
215 |
this.btnAdd.addActionListener((ActionEvent e) -> { |
|
216 |
doAdd(); |
|
217 |
}); |
|
218 |
|
|
219 |
this.btnRemove.addActionListener((ActionEvent e) -> { |
|
220 |
doRemove(); |
|
221 |
}); |
|
222 |
|
|
223 |
this.btnUp.addActionListener((ActionEvent e) -> { |
|
224 |
doUp(lstAttributes); |
|
225 |
}); |
|
226 |
|
|
227 |
this.btnDown.addActionListener((ActionEvent e) -> { |
|
228 |
doDown(lstAttributes); |
|
229 |
}); |
|
230 |
|
|
231 |
this.btnApplyChanges.addActionListener((ActionEvent e) -> { |
|
232 |
doApplyChanges(); |
|
233 |
}); |
|
234 |
|
|
235 |
this.btnColumnMore.addActionListener((ActionEvent e) -> { |
|
236 |
// |
|
237 |
}); |
|
238 |
|
|
87 | 239 |
} |
88 |
URL url = this.getClass().getResource(name + ".png"); |
|
89 |
if (url == null) { |
|
90 |
return null; |
|
240 |
|
|
241 |
private void doSelectAttribute() { |
|
242 |
EditableFeatureAttributeDescriptor value = ((ListElement<EditableFeatureAttributeDescriptor>) this.lstAttributes.getSelectedValue()).getValue(); |
|
243 |
if (value == null) { |
|
244 |
this.colummController.clean(); |
|
245 |
this.colummController.setEnabled(false); |
|
246 |
this.actualEditableAttribute = null; |
|
247 |
|
|
248 |
} else { |
|
249 |
//EditableFeatureAttributeDescriptor value = node.getValue(); |
|
250 |
this.actualEditableAttribute = value; |
|
251 |
colummController.put(value); |
|
252 |
colummController.setEnabled(true); |
|
253 |
} |
|
91 | 254 |
} |
92 |
return new ImageIcon(url); |
|
93 |
} |
|
94 | 255 |
|
95 |
@Override |
|
96 |
public void setStore(FeatureStore store) { |
|
97 |
try { |
|
98 |
this.featureType = store.getDefaultFeatureType(); |
|
99 |
this.store = store; |
|
100 |
this.query = store.createFeatureQuery(); |
|
101 |
this.pckExpression = DALSwingLocator.getManager().createQueryFilterExpresion(store); |
|
102 |
} catch (DataException ex) { |
|
103 |
throw new RuntimeException("Can't assign store", ex); |
|
256 |
@Override |
|
257 |
public FeatureQuery fetch(FeatureQuery query) { |
|
258 |
if (query == null) { |
|
259 |
return this.query.getCopy(); |
|
260 |
} |
|
261 |
return query; |
|
104 | 262 |
} |
105 |
} |
|
106 | 263 |
|
107 |
private void initComponents() { |
|
108 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
|
109 |
|
|
110 |
this.colummController = new ColumnController( |
|
111 |
this.txtColumnName, |
|
112 |
this.cboColumnDataType, |
|
113 |
this.btnColumnDataType, |
|
114 |
this.txtColumnExpression, |
|
115 |
this.btnColumnExpression, |
|
116 |
this.btnColumnExpressionHistory, |
|
117 |
this.btnColumnExpressionBookmarks |
|
118 |
); |
|
119 |
this.lstAttributes.setCellRenderer(new FeatureAttributeListCellRenderer()); |
|
120 |
this.lstAttributes.addListSelectionListener((ListSelectionEvent e) -> { |
|
121 |
if (e.getValueIsAdjusting()) { |
|
122 |
return; |
|
123 |
} |
|
124 |
doSelectAttribute(); |
|
125 |
}); |
|
264 |
@Override |
|
265 |
public FeatureQuery fetch() { |
|
266 |
return this.fetch(null); |
|
267 |
} |
|
126 | 268 |
|
127 |
Dimension sz = this.getPreferredSize(); |
|
128 |
if (sz.width < DEFAULT_WIDTH) { |
|
129 |
sz.width = DEFAULT_WIDTH; |
|
269 |
@Override |
|
270 |
public void put(FeatureQuery query) { |
|
271 |
this.query.copyFrom(query); |
|
272 |
addExtraColumns(this.query); |
|
130 | 273 |
} |
131 |
if (sz.height < DEFAULT_HEIGHT) { |
|
132 |
sz.height = DEFAULT_HEIGHT; |
|
274 |
|
|
275 |
private void addExtraColumns(FeatureQuery query) { |
|
276 |
List<EditableFeatureAttributeDescriptor> cols = query.getExtraColumn().getColumns(); |
|
277 |
if (cols==null || cols.isEmpty()) { |
|
278 |
return; |
|
279 |
} |
|
280 |
// model = this.lstAttributes.getModel(); |
|
281 |
for (EditableFeatureAttributeDescriptor col : cols) { |
|
282 |
//LabeledValueImpl<EditableFeatureAttributeDescriptor> lf = new LabeledValueImpl<EditableFeatureAttributeDescriptor>(col.getLabel(), col); |
|
283 |
this.lstAttributesModel.addElement(col); |
|
284 |
} |
|
285 |
if (this.lstAttributesModel.getSize() > 0) { |
|
286 |
this.lstAttributes.setSelectedIndex(0); |
|
287 |
} |
|
133 | 288 |
} |
134 |
this.setPreferredSize(sz); |
|
135 |
} |
|
136 | 289 |
|
137 |
private void doSelectAttribute() { |
|
138 |
} |
|
290 |
public static void selfRegister() { |
|
291 |
String[][] iconNames = new String[][]{ |
|
292 |
new String[]{"dalswing", "common-applychanges"}, |
|
293 |
new String[]{"dalswing", "common-more"}, |
|
294 |
new String[]{"dalswing", "featurequery-column-add"}, |
|
295 |
new String[]{"dalswing", "featurequery-column-remove"}, |
|
296 |
new String[]{"dalswing", "featurequery-column-down"}, |
|
297 |
new String[]{"dalswing", "featurequery-column-up"} |
|
298 |
}; |
|
299 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
|
300 |
for (String[] icon : iconNames) { |
|
301 |
URL url = DefaultFeatureQueryOrderPanel.class.getResource(icon[1] + ".png"); |
|
302 |
theme.registerDefault("DALSwing", icon[0], icon[1], null, url); |
|
303 |
} |
|
304 |
} |
|
139 | 305 |
|
140 |
@Override |
|
141 |
public FeatureQuery fetch(FeatureQuery query) { |
|
142 |
if( query == null ) { |
|
143 |
return this.query.getCopy(); |
|
306 |
private void doAdd() { |
|
307 |
EditableFeatureAttributeDescriptor newAttr = DALLocator.getDataManager().createFeatureAttributeDescriptor(); |
|
308 |
newAttr.setName(COLUMN_DEFAULT_NAME); |
|
309 |
int id = 0; |
|
310 |
while (checkIfValueExistInModel(newAttr.getName(), this.lstAttributesModel)) { |
|
311 |
String newName = COLUMN_DEFAULT_NAME + "_" + id; |
|
312 |
id+=1; |
|
313 |
newAttr.setName(newName); |
|
314 |
} |
|
315 |
this.colummController.put(newAttr); |
|
316 |
this.lstAttributesModel.addElement(new ListElement(newAttr.getName(), newAttr)); |
|
144 | 317 |
} |
145 |
return query; |
|
146 |
} |
|
147 | 318 |
|
148 |
@Override |
|
149 |
public FeatureQuery fetch() { |
|
150 |
return this.fetch(null); |
|
151 |
} |
|
319 |
private boolean checkIfValueExistInModel(String name, ListModel<ListElement<EditableFeatureAttributeDescriptor>> model) { |
|
320 |
for (int i = 0; i < model.getSize(); i++) { |
|
321 |
EditableFeatureAttributeDescriptor element = model.getElementAt(i).getValue(); |
|
322 |
if (StringUtils.equals(element.getLabel(), name)) { |
|
323 |
return true; |
|
324 |
} |
|
152 | 325 |
|
153 |
@Override |
|
154 |
public void put(FeatureQuery query) { |
|
155 |
this.query.copyFrom(query); |
|
156 |
} |
|
326 |
} |
|
327 |
return false; |
|
328 |
} |
|
157 | 329 |
|
158 |
public static void selfRegister() { |
|
159 |
String[][] iconNames = new String[][]{ |
|
160 |
new String[]{"dalswing", "common-applychanges"}, |
|
161 |
new String[]{"dalswing", "common-more"}, |
|
162 |
new String[]{"dalswing", "featurequery-column-add"}, |
|
163 |
new String[]{"dalswing", "featurequery-column-remove"}, |
|
164 |
new String[]{"dalswing", "featurequery-column-down"}, |
|
165 |
new String[]{"dalswing", "featurequery-column-up"} |
|
166 |
}; |
|
167 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
|
168 |
for (String[] icon : iconNames) { |
|
169 |
URL url = DefaultFeatureQueryOrderPanel.class.getResource(icon[1] + ".png"); |
|
170 |
theme.registerDefault("DALSwing", icon[0], icon[1], null, url); |
|
330 |
private void doRemove() { |
|
331 |
throw new UnsupportedOperationException("Not supported yet."); |
|
171 | 332 |
} |
172 |
} |
|
173 | 333 |
|
334 |
private void doApplyChanges() { |
|
335 |
this.colummController.fetch(this.actualEditableAttribute); |
|
336 |
} |
|
337 |
|
|
338 |
private void doUp(JList lstColumns) { |
|
339 |
int moveMe = lstColumns.getSelectedIndex(); |
|
340 |
if (moveMe != 0) { |
|
341 |
//not already at top |
|
342 |
swap(lstColumns, moveMe, moveMe - 1); |
|
343 |
lstColumns.setSelectedIndex(moveMe - 1); |
|
344 |
lstColumns.ensureIndexIsVisible(moveMe - 1); |
|
345 |
} |
|
346 |
} |
|
347 |
|
|
348 |
private void doDown(JList lstColumns) { |
|
349 |
int moveMe = lstColumns.getSelectedIndex(); |
|
350 |
if (moveMe != lstColumns.getModel().getSize() - 1) { |
|
351 |
//not already at bottom |
|
352 |
swap(lstColumns, moveMe, moveMe + 1); |
|
353 |
lstColumns.setSelectedIndex(moveMe + 1); |
|
354 |
lstColumns.ensureIndexIsVisible(moveMe + 1); |
|
355 |
} |
|
356 |
} |
|
357 |
|
|
358 |
private void swap(JList lstColumns, int a, int b) { |
|
359 |
DefaultListModel model = (DefaultListModel) lstColumns.getModel(); |
|
360 |
Object aObject = model.getElementAt(a); |
|
361 |
Object bObject = model.getElementAt(b); |
|
362 |
model.set(a, bObject); |
|
363 |
model.set(b, aObject); |
|
364 |
} |
|
174 | 365 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/DataManager.java | ||
---|---|---|
50 | 50 |
import org.gvsig.tools.service.spi.Services; |
51 | 51 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureAttributeEmulatorExpression; |
52 | 52 |
import org.gvsig.fmap.dal.feature.DataProfile; |
53 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
53 | 54 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
54 | 55 |
|
55 | 56 |
/** |
... | ... | |
512 | 513 |
|
513 | 514 |
public FeatureSymbolTable createFeatureSymbolTable(); |
514 | 515 |
|
516 |
public EditableFeatureAttributeDescriptor createFeatureAttributeDescriptor(); |
|
517 |
|
|
515 | 518 |
public FeatureAttributeEmulatorExpression createFeatureAttributeEmulatorExpression(FeatureType type, Expression expression); |
516 | 519 |
|
517 | 520 |
public void registerDataProfile(DataProfile profile); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureType.java | ||
---|---|---|
356 | 356 |
public boolean hasOnlyMetadataChanges(FeatureType other); |
357 | 357 |
|
358 | 358 |
public void writeAsDALFile(File file); |
359 |
|
|
360 |
public FeatureExtraColumn getExtraColumn(); |
|
361 |
|
|
359 | 362 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureExtraColumn.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.feature; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
/** |
|
6 |
* |
|
7 |
* @author osc |
|
8 |
*/ |
|
9 |
public interface FeatureExtraColumn { |
|
10 |
|
|
11 |
public List<EditableFeatureAttributeDescriptor> getColumns(); |
|
12 |
|
|
13 |
public EditableFeatureAttributeDescriptor get(String name); |
|
14 |
|
|
15 |
public EditableFeatureAttributeDescriptor add(String name); |
|
16 |
|
|
17 |
public void merge(FeatureExtraColumn other); |
|
18 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.exportto.app/org.gvsig.exportto.app.mainplugin/src/main/java/org/gvsig/export/app/extension/ExportTable.java | ||
---|---|---|
54 | 54 |
process.setContextProjection(null); |
55 | 55 |
process.setSourceProjection(null); |
56 | 56 |
process.setSourceTransformation(null); |
57 |
process.setFeatureQuery(query); |
|
57 | 58 |
process.setFilterExpression(query==null? null:query.getExpressionFilter()); |
58 | 59 |
|
59 | 60 |
JExportProcessPanel panel = swingManager.createJExportProcessPanel( |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.impl/src/main/java/org/gvsig/export/impl/service/DefaultExportAttributes.java | ||
---|---|---|
16 | 16 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
17 | 17 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
18 | 18 |
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
19 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
19 | 20 |
import org.gvsig.fmap.dal.feature.FeatureType; |
20 | 21 |
import org.gvsig.tools.ToolsLocator; |
22 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
23 |
import org.gvsig.tools.dataTypes.DataTypesManager; |
|
21 | 24 |
import org.gvsig.tools.dynobject.DynStruct; |
22 | 25 |
import org.gvsig.tools.persistence.PersistenceManager; |
23 | 26 |
import org.gvsig.tools.persistence.PersistentState; |
... | ... | |
32 | 35 |
private FeatureType sourceFeatureType; |
33 | 36 |
static final Logger LOGGER = LoggerFactory.getLogger(DefaultExportAttributes.class); |
34 | 37 |
private boolean active; |
38 |
private FeatureQuery query = null; |
|
35 | 39 |
|
36 | 40 |
public DefaultExportAttributes() { |
37 | 41 |
this.namesTranslator = new DummyAttributeNamesTranslator(); |
38 | 42 |
this.active = false; |
39 | 43 |
} |
40 | 44 |
|
41 |
public void fillExportAttributes(FeatureType ftype) { |
|
45 |
public void fillExportAttributes(FeatureType ftype, FeatureQuery query) {
|
|
42 | 46 |
ArrayList attrs = new ArrayList(); |
43 | 47 |
if (ftype != null) { |
44 | 48 |
for (FeatureAttributeDescriptor fad : ftype) { |
... | ... | |
47 | 51 |
exportAttribute.setNewName(newName); |
48 | 52 |
exportAttribute.setNewType(fad.getDataType().getType()); |
49 | 53 |
exportAttribute.setSize(fad.getSize()); |
50 |
exportAttribute.setExported(true); |
|
54 |
if (query == null || (query != null && query.getGroupByColumns().isEmpty())) { |
|
55 |
exportAttribute.setExported(isShowableDataType(fad.getDataType().getType())); |
|
56 |
} else { |
|
57 |
if (query.getAggregate(fad.getName()) != null || query.getGroupByColumns().contains(fad.getName())) { |
|
58 |
exportAttribute.setExported(isShowableDataType(fad.getDataType().getType())); |
|
59 |
} else { |
|
60 |
exportAttribute.setExported(false); |
|
61 |
} |
|
62 |
} |
|
51 | 63 |
attrs.add(exportAttribute); |
52 | 64 |
} |
53 | 65 |
} |
66 |
|
|
67 |
if (query!=null && query.getExtraColumn().getColumns()!=null && !query.getExtraColumn().getColumns().isEmpty() ) { |
|
68 |
for (FeatureAttributeDescriptor fad : query.getExtraColumn().getColumns()) { |
|
69 |
DefaultExportAttribute exportAttribute = new DefaultExportAttribute(fad); |
|
70 |
String newName = this.getNamesTranslator().getNameSuggestion(fad.getName()); |
|
71 |
exportAttribute.setNewName(newName); |
|
72 |
exportAttribute.setNewType(fad.getDataType().getType()); |
|
73 |
exportAttribute.setSize(fad.getSize()); |
|
74 |
exportAttribute.setExported(isShowableDataType(fad.getDataType().getType())); |
|
75 |
attrs.add(exportAttribute); |
|
76 |
} |
|
77 |
} |
|
54 | 78 |
this.setExportAttributes(attrs); |
55 | 79 |
this.fixAttributeNames(); |
56 | 80 |
|
57 | 81 |
} |
82 |
|
|
83 |
protected boolean isShowableDataType(int dataType) { |
|
84 |
DataTypesManager dataTypemanager = ToolsLocator.getDataTypesManager(); |
|
85 |
if (dataTypemanager.isContainer(dataType) |
|
86 |
|| dataTypemanager.isObject(dataType) |
|
87 |
|| dataType == DataTypes.ARRAY) { |
|
88 |
return false; |
|
58 | 89 |
|
90 |
} else { |
|
91 |
return true; |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
59 | 95 |
@Override |
60 | 96 |
public void setNamesTranslator(AttributeNamesTranslator namesTranslator) { |
61 | 97 |
if (this.namesTranslator != namesTranslator) { |
62 | 98 |
this.namesTranslator = namesTranslator; |
63 | 99 |
if (this.sourceFeatureType != null) { |
64 |
this.fillExportAttributes(sourceFeatureType); |
|
100 |
this.fillExportAttributes(sourceFeatureType, this.query);
|
|
65 | 101 |
} |
66 | 102 |
} |
67 | 103 |
} |
... | ... | |
136 | 172 |
int size = exportAttr.getSize(); |
137 | 173 |
eAttr.setSize(size); |
138 | 174 |
} |
175 |
if (this.query!=null && this.query.getExtraColumn().getColumns()!=null && !this.query.getExtraColumn().getColumns().isEmpty()) { |
|
176 |
for (EditableFeatureAttributeDescriptor attrExtra : this.query.getExtraColumn().getColumns()) { |
|
177 |
//FeatureAttributeDescriptor attr = targetFeatureType.getAttributeDescriptor(attrSource.getName()); |
|
178 |
String name = attrExtra.getName(); |
|
179 |
ExportAttribute exportAttr = this.getExportAttribute(name); |
|
180 |
if (!exportAttr.isExported()) { |
|
181 |
//targetFeatureType.remove(name); |
|
182 |
continue; |
|
183 |
} |
|
184 |
//EditableFeatureAttributeDescriptor eAttr = targetFeatureType.getEditableAttributeDescriptor(name); |
|
185 |
// if( eAttr.isComputed() && !exportAttr.isComputed() ) { |
|
186 |
// eAttr.setFeatureAttributeEmulator((FeatureAttributeEmulator)null); |
|
187 |
// } |
|
188 |
if (this.getTargetName(name) == null && name != null && !this.getTargetName(name).equals(name)) { |
|
189 |
attrExtra.setName(this.getTargetName(name)); |
|
190 |
} |
|
191 |
int type = attrExtra.getDataType().getType(); |
|
192 |
if (type != this.getTargetType(name)) { |
|
193 |
attrExtra.setDataType(this.getTargetType(name)); |
|
194 |
attrExtra.setDefaultValue(null); // TODO: delete default value |
|
195 |
} |
|
196 |
int size = exportAttr.getSize(); |
|
197 |
attrExtra.setSize(size); |
|
198 |
} |
|
199 |
} |
|
200 |
|
|
139 | 201 |
return targetFeatureType.getNotEditableCopy(); |
140 | 202 |
} |
141 | 203 |
|
142 | 204 |
@Override |
143 |
public void setSourceFeatureType(FeatureType sourceFeatureType) { |
|
205 |
public void setSourceFeatureType(FeatureType sourceFeatureType, FeatureQuery query) { |
|
206 |
this.query = query; |
|
144 | 207 |
if (!sourceFeatureType.equals(this.sourceFeatureType)) { |
145 | 208 |
this.sourceFeatureType = sourceFeatureType; |
146 |
this.fillExportAttributes(this.sourceFeatureType); |
|
209 |
this.fillExportAttributes(this.sourceFeatureType, query);
|
|
147 | 210 |
} |
148 | 211 |
} |
149 | 212 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.impl/src/main/java/org/gvsig/export/impl/DefaultExportProcess.java | ||
---|---|---|
18 | 18 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
19 | 19 |
import org.gvsig.fmap.dal.OpenDataStoreParameters; |
20 | 20 |
import org.gvsig.fmap.dal.exception.DataException; |
21 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
21 | 22 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
22 | 23 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
23 | 24 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
... | ... | |
46 | 47 |
private Expression filterExpression; |
47 | 48 |
private int featuresToUse; |
48 | 49 |
private SimpleTaskStatus taskStatus; |
50 |
private FeatureQuery featureQuery; |
|
49 | 51 |
|
50 | 52 |
public DefaultExportProcess() { |
51 | 53 |
|
... | ... | |
57 | 59 |
ExportServiceManager serviceManager = ExportLocator.getServiceManager(); |
58 | 60 |
this.factory = serviceManager.getServiceFactory(serviceName); |
59 | 61 |
this.parameters = this.factory.createParameters(); |
62 |
this.parameters.setFeatureQuery(featureQuery); |
|
60 | 63 |
// this.service = this.factory.createService(this.parameters); |
61 | 64 |
this.parameters.setSourceFeatureStore(this.sourceFeatureStore); |
62 | 65 |
this.parameters.setFeaturesToUse(featuresToUse); |
... | ... | |
201 | 204 |
} |
202 | 205 |
try { |
203 | 206 |
FeatureSet featureSet; |
207 |
FeatureQuery exportFeatureQuery; |
|
208 |
if (this.featureQuery!=null) { |
|
209 |
exportFeatureQuery = this.featureQuery.getCopy(); |
|
210 |
exportFeatureQuery.clearFilter(); |
|
211 |
exportFeatureQuery.retrievesAllAttributes(); |
|
212 |
} else { |
|
213 |
exportFeatureQuery = null; |
|
214 |
} |
|
204 | 215 |
switch (this.parameters.getFeaturesToUse()) { |
205 | 216 |
case ExportParameters.USE_ALL_FEATURES: |
206 | 217 |
default: |
207 |
featureSet = this.parameters.getSourceFeatureStore().getFeatureSet(); |
|
218 |
featureSet = this.parameters.getSourceFeatureStore().getFeatureSet(exportFeatureQuery);
|
|
208 | 219 |
break; |
209 | 220 |
case ExportParameters.USE_SELECTED_FEATURES: |
210 | 221 |
featureSet = this.parameters.getSourceFeatureStore().getFeatureSelection(); |
211 | 222 |
break; |
212 | 223 |
case ExportParameters.USE_FILTERED_FEATURES: |
213 |
featureSet = this.parameters.getSourceFeatureStore().getFeatureSet(this.parameters.getFilterExpresion()); |
|
224 |
if (exportFeatureQuery!=null) { |
|
225 |
exportFeatureQuery.setFilter(this.parameters.getFeatureQuery().getExpressionFilter()); |
|
226 |
} else { |
|
227 |
exportFeatureQuery = this.parameters.getFeatureQuery(); |
|
228 |
} |
|
229 |
|
|
230 |
if (exportFeatureQuery!=null) { |
|
231 |
exportFeatureQuery.retrievesAllAttributes(); |
|
232 |
} |
|
233 |
featureSet = this.parameters.getSourceFeatureStore().getFeatureSet(exportFeatureQuery); |
|
214 | 234 |
break; |
215 | 235 |
} |
216 | 236 |
ExportService service = this.factory.createService(this.parameters); |
... | ... | |
262 | 282 |
} |
263 | 283 |
} |
264 | 284 |
|
285 |
@Override |
|
286 |
public void setFeatureQuery(FeatureQuery featureQuery) { |
|
287 |
this.featureQuery = featureQuery; |
|
288 |
} |
|
289 |
|
|
265 | 290 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/ExportProcess.java | ||
---|---|---|
5 | 5 |
import org.cresques.cts.IProjection; |
6 | 6 |
import org.gvsig.expressionevaluator.Expression; |
7 | 7 |
import org.gvsig.fmap.dal.OpenDataStoreParameters; |
8 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
8 | 9 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
9 | 10 |
import org.gvsig.tools.task.TaskStatus; |
10 | 11 |
|
... | ... | |
26 | 27 |
|
27 | 28 |
public void setFilterExpression(Expression expression); |
28 | 29 |
|
30 |
public void setFeatureQuery(FeatureQuery expression); |
|
31 |
|
|
29 | 32 |
public void setFeaturesToUse(int featuresToUse); |
30 | 33 |
|
31 | 34 |
public void setParameters(ExportParameters params); |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/ExportParameters.java | ||
---|---|---|
3 | 3 |
import java.util.Date; |
4 | 4 |
import org.gvsig.export.spi.ExportServiceFactory; |
5 | 5 |
import org.gvsig.expressionevaluator.Expression; |
6 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
6 | 7 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
7 | 8 |
import org.gvsig.fmap.dal.feature.FeatureType; |
8 | 9 |
import org.gvsig.tools.persistence.Persistent; |
... | ... | |
37 | 38 |
public Expression getFilterExpresion(); |
38 | 39 |
|
39 | 40 |
public void setFilterExpresion(Expression expression); |
41 |
|
|
42 |
public FeatureQuery getFeatureQuery(); |
|
43 |
|
|
44 |
public void setFeatureQuery(FeatureQuery query); |
|
40 | 45 |
|
41 | 46 |
public Object getContext(); |
42 | 47 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/spi/AbstractExportParameters.java | ||
---|---|---|
10 | 10 |
import org.gvsig.fmap.dal.feature.FeatureType; |
11 | 11 |
import org.gvsig.export.ExportParameters; |
12 | 12 |
import org.gvsig.expressionevaluator.Expression; |
13 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
13 | 14 |
import org.gvsig.tools.ToolsLocator; |
14 | 15 |
import org.gvsig.tools.dynobject.DynStruct; |
15 | 16 |
import org.gvsig.tools.persistence.PersistenceManager; |
... | ... | |
33 | 34 |
public ExportServiceFactory factory; |
34 | 35 |
|
35 | 36 |
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractExportParameters.class); |
37 |
private FeatureQuery featureQuery; |
|
36 | 38 |
|
37 | 39 |
public AbstractExportParameters(ExportServiceFactory factory) { |
38 | 40 |
this.factory = factory; |
... | ... | |
55 | 57 |
|
56 | 58 |
@Override |
57 | 59 |
public void setSourceFeatureType(FeatureType sourceFeatureType) { |
58 |
this.exportAttributes.setSourceFeatureType(sourceFeatureType); |
|
60 |
this.exportAttributes.setSourceFeatureType(sourceFeatureType, this.featureQuery);
|
|
59 | 61 |
} |
60 | 62 |
|
61 | 63 |
@Override |
... | ... | |
63 | 65 |
this.sourceFeatureStore = sourceFeatureStore; |
64 | 66 |
try { |
65 | 67 |
FeatureType sourceFeatureType = sourceFeatureStore.getDefaultFeatureType(); |
66 |
this.exportAttributes.setSourceFeatureType(sourceFeatureType); |
|
68 |
this.exportAttributes.setSourceFeatureType(sourceFeatureType, this.featureQuery);
|
|
67 | 69 |
} catch (DataException ex) { |
68 | 70 |
throw new RuntimeException("Can't set feature type", ex); |
69 | 71 |
} |
... | ... | |
83 | 85 |
public void setFilterExpresion(Expression expression) { |
84 | 86 |
this.filterExpression = expression; |
85 | 87 |
} |
88 |
|
|
89 |
@Override |
|
90 |
public FeatureQuery getFeatureQuery() { |
|
91 |
return this.featureQuery; |
|
92 |
} |
|
86 | 93 |
|
87 | 94 |
@Override |
95 |
public void setFeatureQuery(FeatureQuery query) { |
|
96 |
this.featureQuery = query; |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
88 | 100 |
public int getFeaturesToUse() { |
89 | 101 |
return featuresToUse; |
90 | 102 |
} |
... | ... | |
121 | 133 |
if (this.filterExpression != null) { |
122 | 134 |
clone.setFilterExpresion(this.filterExpression.clone()); |
123 | 135 |
} |
136 |
if (this.featureQuery!=null) { |
|
137 |
clone.setFeatureQuery(this.featureQuery.getCopy()); |
|
138 |
} |
|
124 | 139 |
if (this.exportAttributes != null) { |
125 | 140 |
clone.setExportAttributes(this.exportAttributes.clone()); |
126 | 141 |
} |
Also available in: Unified diff