Revision 44572
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/ExportAttributes.java | ||
---|---|---|
38 | 38 |
public int getNewDataType(); |
39 | 39 |
|
40 | 40 |
public boolean isExported(); |
41 |
|
|
42 |
public boolean isComputed(); |
|
41 | 43 |
|
42 | 44 |
public int getSize(); |
43 | 45 |
|
... | ... | |
49 | 51 |
|
50 | 52 |
public void setExported(boolean exported); |
51 | 53 |
|
54 |
public void setComputed(boolean computed); |
|
55 |
|
|
52 | 56 |
public ExportAttribute clone() throws CloneNotSupportedException; |
53 | 57 |
} |
54 | 58 |
|
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/DefaultExportAttribute.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import org.gvsig.export.ExportAttributes; |
9 | 9 |
import org.gvsig.export.ExportAttributes.ExportAttribute; |
10 |
import org.gvsig.export.spi.AbstractExportParameters; |
|
11 |
import org.gvsig.export.spi.AttributeNamesTranslator; |
|
12 |
import org.gvsig.export.spi.ExportServiceFactory; |
|
13 |
import org.gvsig.expressionevaluator.Expression; |
|
14 | 10 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
15 | 11 |
import org.gvsig.tools.ToolsLocator; |
16 | 12 |
import org.gvsig.tools.dynobject.DynStruct; |
... | ... | |
25 | 21 |
private int newDataType; |
26 | 22 |
private int size; |
27 | 23 |
private boolean exported; |
28 |
// private AttributeNamesTranslator translator = null;
|
|
24 |
private boolean computed;
|
|
29 | 25 |
|
30 | 26 |
public DefaultExportAttribute(FeatureAttributeDescriptor fad) { |
31 | 27 |
this.fad = fad; |
28 |
this.computed = this.fad.isComputed(); |
|
32 | 29 |
} |
33 | 30 |
|
34 | 31 |
public DefaultExportAttribute() { |
... | ... | |
58 | 55 |
return this.newName; |
59 | 56 |
} |
60 | 57 |
|
58 |
@Override |
|
61 | 59 |
public int getNewDataType() { |
62 | 60 |
|
63 | 61 |
return this.newDataType; |
... | ... | |
69 | 67 |
} |
70 | 68 |
|
71 | 69 |
@Override |
70 |
public boolean isComputed() { |
|
71 |
return this.computed; |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
|
72 | 75 |
public void setNewName(String name) { |
73 | 76 |
this.newName = name; |
74 | 77 |
} |
... | ... | |
79 | 82 |
} |
80 | 83 |
|
81 | 84 |
@Override |
85 |
public void setComputed(boolean computed) { |
|
86 |
this.computed = computed; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
82 | 90 |
public void setNewType(int dataType) { |
83 | 91 |
this.newDataType = dataType; |
84 | 92 |
} |
... | ... | |
95 | 103 |
|
96 | 104 |
@Override |
97 | 105 |
public ExportAttribute clone() throws CloneNotSupportedException { |
98 |
DefaultExportAttribute clone = new DefaultExportAttribute((FeatureAttributeDescriptor) fad.clone()); |
|
99 |
clone.setExported(this.exported); |
|
100 |
clone.setNewName(this.newName); |
|
101 |
clone.setNewType(this.newDataType); |
|
102 |
clone.setSize(this.size); |
|
106 |
DefaultExportAttribute clone = (DefaultExportAttribute) super.clone(); |
|
107 |
clone.fad = (FeatureAttributeDescriptor) fad.clone(); |
|
103 | 108 |
return clone; |
104 | 109 |
} |
105 | 110 |
|
... | ... | |
113 | 118 |
definition.addDynFieldInt("newDataType").setMandatory(false); |
114 | 119 |
definition.addDynFieldInt("size").setMandatory(false); |
115 | 120 |
definition.addDynFieldBoolean("exported").setMandatory(false); |
121 |
definition.addDynFieldBoolean("calculated").setMandatory(false); |
|
116 | 122 |
} |
117 | 123 |
} |
118 | 124 |
|
125 |
@Override |
|
119 | 126 |
public void saveToState(PersistentState state) throws PersistenceException { |
120 | 127 |
state.set("fad", this.fad); |
121 | 128 |
state.set("newName", this.newName); |
122 | 129 |
state.set("newDataType", this.newDataType); |
123 | 130 |
state.set("size", this.size); |
124 | 131 |
state.set("exported", this.exported); |
125 |
|
|
132 |
state.set("calculated", this.computed); |
|
126 | 133 |
} |
127 | 134 |
|
135 |
@Override |
|
128 | 136 |
public void loadFromState(PersistentState state) throws PersistenceException { |
129 | 137 |
FeatureAttributeDescriptor stateFad = (FeatureAttributeDescriptor) state.get("fad"); |
130 | 138 |
this.fad = stateFad; |
... | ... | |
132 | 140 |
this.newDataType = state.getInt("newDataType"); |
133 | 141 |
this.size = state.getInt("size"); |
134 | 142 |
this.exported = state.getBoolean("exported"); |
143 |
this.computed = state.getBoolean("calculated"); |
|
135 | 144 |
} |
136 | 145 |
|
137 | 146 |
} |
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 | ||
---|---|---|
15 | 15 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
16 | 16 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
17 | 17 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
18 |
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
|
18 | 19 |
import org.gvsig.fmap.dal.feature.FeatureType; |
19 | 20 |
import org.gvsig.tools.ToolsLocator; |
20 | 21 |
import org.gvsig.tools.dynobject.DynStruct; |
... | ... | |
120 | 121 |
targetFeatureType.remove(name); |
121 | 122 |
continue; |
122 | 123 |
} |
123 |
|
|
124 | 124 |
EditableFeatureAttributeDescriptor eAttr = targetFeatureType.getEditableAttributeDescriptor(name); |
125 |
if (this.getTargetName(name) == null ? name != null : !this.getTargetName(name).equals(name)) { |
|
125 |
if( eAttr.isComputed() && !exportAttr.isComputed() ) { |
|
126 |
eAttr.setFeatureAttributeEmulator((FeatureAttributeEmulator)null); |
|
127 |
} |
|
128 |
if (this.getTargetName(name) == null && name != null && !this.getTargetName(name).equals(name)) { |
|
126 | 129 |
eAttr.setName(this.getTargetName(name)); |
127 | 130 |
} |
128 | 131 |
int type = attr.getDataType().getType(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.impl/src/main/java/org/gvsig/export/swing/impl/panels/SelectAttributesPanel.java | ||
---|---|---|
67 | 67 |
private static final int COLUMN_FIELD_EXPORT = 0; |
68 | 68 |
private static final int COLUMN_FIELD_TYPE = 1; |
69 | 69 |
private static final int COLUMN_FIELD_SIZE = 2; |
70 |
private static final int COLUMN_FIELD_NAME = 3; |
|
71 |
private static final int COLUMN_FIELD_NEW_NAME = 4; |
|
70 |
private static final int COLUMN_FIELD_CALCULATED = 3; |
|
71 |
private static final int COLUMN_FIELD_NAME = 4; |
|
72 |
private static final int COLUMN_FIELD_NEW_NAME = 5; |
|
72 | 73 |
|
73 |
private static final int COLUMN_FIELD_COUNT = 5;
|
|
74 |
private static final int COLUMN_FIELD_COUNT = 6;
|
|
74 | 75 |
|
75 | 76 |
private static class AttributesTableModel |
76 | 77 |
extends AbstractTableModel |
... | ... | |
89 | 90 |
columnNames[COLUMN_FIELD_NEW_NAME] = i18nManager.getTranslation("_new_name"); |
90 | 91 |
columnNames[COLUMN_FIELD_TYPE] = i18nManager.getTranslation("_type"); |
91 | 92 |
columnNames[COLUMN_FIELD_SIZE] = i18nManager.getTranslation("_size"); |
93 |
columnNames[COLUMN_FIELD_CALCULATED] = i18nManager.getTranslation("_virtual"); |
|
92 | 94 |
columnNames[COLUMN_FIELD_EXPORT] = ""; |
93 | 95 |
|
94 | 96 |
columnClases[COLUMN_FIELD_NAME] = String.class; |
... | ... | |
96 | 98 |
columnClases[COLUMN_FIELD_TYPE] = String.class; |
97 | 99 |
columnClases[COLUMN_FIELD_SIZE] = Integer.class; |
98 | 100 |
columnClases[COLUMN_FIELD_EXPORT] = Boolean.class; |
101 |
columnClases[COLUMN_FIELD_CALCULATED] = Boolean.class; |
|
99 | 102 |
} |
100 | 103 |
|
101 | 104 |
@Override |
... | ... | |
123 | 126 |
switch (columnIndex) { |
124 | 127 |
case COLUMN_FIELD_NAME: |
125 | 128 |
return false; |
129 |
case COLUMN_FIELD_CALCULATED: { |
|
130 |
ExportAttribute attr = this.attributes.get(rowIndex); |
|
131 |
DataType dataType = attr.getDescriptor().getDataType(); |
|
132 |
if( dataType.isContainer() || |
|
133 |
dataType.isObject() || |
|
134 |
dataType.isDynObject() ) { |
|
135 |
return false; |
|
136 |
} |
|
137 |
return true; |
|
138 |
} |
|
126 | 139 |
default: |
127 | 140 |
return true; |
128 | 141 |
} |
... | ... | |
142 | 155 |
return attr.getSize(); |
143 | 156 |
case COLUMN_FIELD_EXPORT: |
144 | 157 |
return attr.isExported(); |
158 |
case COLUMN_FIELD_CALCULATED: |
|
159 |
return attr.isComputed(); |
|
145 | 160 |
default: |
146 | 161 |
return null; |
147 | 162 |
} |
... | ... | |
173 | 188 |
LOGGER.warn("Not been able to set exported value of attribute " + attr.getName() + " (" + Objects.toString(aValue) + ").", ex); |
174 | 189 |
} |
175 | 190 |
break; |
191 |
case COLUMN_FIELD_CALCULATED: |
|
192 |
try { |
|
193 |
attr.setComputed((boolean) dataManager.get(DataTypes.BOOLEAN).coerce(aValue)); |
|
194 |
} catch (Exception ex) { |
|
195 |
LOGGER.warn("Not been able to set calculated value of attribute " + attr.getName() + " (" + Objects.toString(aValue) + ").", ex); |
|
196 |
} |
|
197 |
break; |
|
176 | 198 |
default: |
177 | 199 |
break; |
178 | 200 |
} |
Also available in: Unified diff