Revision 44860 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
DefaultExportAttribute.java | ||
---|---|---|
10 | 10 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
11 | 11 |
import org.gvsig.tools.ToolsLocator; |
12 | 12 |
import org.gvsig.tools.dynobject.DynStruct; |
13 |
import org.gvsig.tools.namestranslator.NamesTranslator; |
|
13 | 14 |
import org.gvsig.tools.persistence.PersistenceManager; |
14 | 15 |
import org.gvsig.tools.persistence.PersistentState; |
15 | 16 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
... | ... | |
17 | 18 |
public class DefaultExportAttribute implements ExportAttributes.ExportAttribute { |
18 | 19 |
|
19 | 20 |
private FeatureAttributeDescriptor fad; |
20 |
private String newName = null; |
|
21 | 21 |
private int newDataType; |
22 | 22 |
private int size; |
23 | 23 |
private boolean exported; |
24 | 24 |
private boolean computed; |
25 |
private NamesTranslator translator; |
|
25 | 26 |
|
26 |
public DefaultExportAttribute(FeatureAttributeDescriptor fad) { |
|
27 |
public DefaultExportAttribute(FeatureAttributeDescriptor fad, NamesTranslator namesTranslator) {
|
|
27 | 28 |
this.fad = fad; |
29 |
this.translator = namesTranslator; |
|
28 | 30 |
this.computed = this.fad.isComputed(); |
29 | 31 |
} |
30 | 32 |
|
... | ... | |
49 | 51 |
|
50 | 52 |
@Override |
51 | 53 |
public String getNewName() { |
52 |
if (this.newName == null) {
|
|
54 |
if (translator==null) {
|
|
53 | 55 |
return this.getName(); |
54 | 56 |
} |
55 |
return this.newName;
|
|
57 |
return translator.getTranslation(this.getName());
|
|
56 | 58 |
} |
57 | 59 |
|
58 | 60 |
@Override |
... | ... | |
72 | 74 |
} |
73 | 75 |
|
74 | 76 |
@Override |
75 |
public void setNewName(String name) { |
|
76 |
this.newName = name; |
|
77 |
public int setNewName(String newName) { |
|
78 |
if (translator==null) { |
|
79 |
return -1; |
|
80 |
} |
|
81 |
int indexChanged = this.translator.setTranslation(this.getName(), newName); |
|
82 |
return indexChanged; |
|
77 | 83 |
} |
78 | 84 |
|
79 | 85 |
@Override |
... | ... | |
114 | 120 |
DynStruct definition = manager.addDefinition(DefaultExportAttribute.class, |
115 | 121 |
"ExportAttribute", "ExportAttribute persistence definition", null, null); |
116 | 122 |
definition.addDynFieldObject("fad").setClassOfValue(FeatureAttributeDescriptor.class); |
117 |
definition.addDynFieldString("newName").setMandatory(false); |
|
123 |
// definition.addDynFieldString("newName").setMandatory(false);
|
|
118 | 124 |
definition.addDynFieldInt("newDataType").setMandatory(false); |
119 | 125 |
definition.addDynFieldInt("size").setMandatory(false); |
120 | 126 |
definition.addDynFieldBoolean("exported").setMandatory(false); |
... | ... | |
125 | 131 |
@Override |
126 | 132 |
public void saveToState(PersistentState state) throws PersistenceException { |
127 | 133 |
state.set("fad", this.fad); |
128 |
state.set("newName", this.newName); |
|
129 | 134 |
state.set("newDataType", this.newDataType); |
130 | 135 |
state.set("size", this.size); |
131 | 136 |
state.set("exported", this.exported); |
... | ... | |
136 | 141 |
public void loadFromState(PersistentState state) throws PersistenceException { |
137 | 142 |
FeatureAttributeDescriptor stateFad = (FeatureAttributeDescriptor) state.get("fad"); |
138 | 143 |
this.fad = stateFad; |
139 |
this.newName = state.getString("newName"); |
|
140 | 144 |
this.newDataType = state.getInt("newDataType"); |
141 | 145 |
this.size = state.getInt("size"); |
142 | 146 |
this.exported = state.getBoolean("exported"); |
Also available in: Unified diff