svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dalfile / src / org / gvsig / fmap / dal / store / dxf / DXFStoreParameters.java @ 30754
History | View | Annotate | Download (4.16 KB)
1 |
package org.gvsig.fmap.dal.store.dxf; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
|
5 |
import org.cresques.cts.IProjection; |
6 |
import org.gvsig.fmap.crs.CRSFactory; |
7 |
import org.gvsig.fmap.dal.DataStoreParameters; |
8 |
import org.gvsig.fmap.dal.DataTypes; |
9 |
import org.gvsig.fmap.dal.feature.FeatureType; |
10 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
11 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
12 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
13 |
import org.gvsig.tools.ToolsLocator; |
14 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
15 |
import org.gvsig.tools.dynobject.DynClass; |
16 |
import org.gvsig.tools.dynobject.DynField; |
17 |
import org.gvsig.tools.dynobject.DynObjectManager; |
18 |
|
19 |
public class DXFStoreParameters extends AbstractDataParameters implements |
20 |
DataStoreParameters, FilesystemStoreParameters, |
21 |
NewFeatureStoreParameters { |
22 |
|
23 |
public static final String DYNCLASS_NAME = "DXFStoreParameters"; |
24 |
|
25 |
private static final String FIELD_FILEPATH = "filepath"; |
26 |
private static final String FIELD_SRS = "srsid"; |
27 |
|
28 |
private static DynClass DYNCLASS = null; |
29 |
|
30 |
public DXFStoreParameters() {
|
31 |
this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
|
32 |
.getDynObjectManager() |
33 |
.createDynObject(DYNCLASS); |
34 |
} |
35 |
|
36 |
public String getDataStoreName() { |
37 |
return DXFStoreProvider.NAME;
|
38 |
} |
39 |
|
40 |
public String getDescription() { |
41 |
return DXFStoreProvider.DESCRIPTION;
|
42 |
} |
43 |
|
44 |
public String getSRSID() { |
45 |
IProjection srs = (IProjection) getDynValue(FIELD_SRS); |
46 |
if (srs == null) { |
47 |
return null; |
48 |
} |
49 |
return srs.getAbrev();
|
50 |
} |
51 |
|
52 |
public void setSRSID(String srsid) { |
53 |
if (srsid == null) { |
54 |
setDynValue(FIELD_SRS, null);
|
55 |
} else {
|
56 |
setDynValue(FIELD_SRS, CRSFactory.getCRS(srsid)); |
57 |
} |
58 |
} |
59 |
|
60 |
public void setSRS(IProjection srs) { |
61 |
setDynValue(FIELD_SRS, srs); |
62 |
} |
63 |
|
64 |
public IProjection getSRS() {
|
65 |
if (this.getSRSID() == null) { |
66 |
return null; |
67 |
} |
68 |
return (IProjection) getDynValue(FIELD_SRS);
|
69 |
} |
70 |
|
71 |
public String getFileName() { |
72 |
return (String) getDynValue(FIELD_FILEPATH); |
73 |
} |
74 |
|
75 |
public void setFileName(String file) { |
76 |
setDynValue(FIELD_FILEPATH, file); |
77 |
} |
78 |
|
79 |
public boolean isValid() { |
80 |
if (getSRSID() == null || getSRSID().equals("")) { |
81 |
return false; |
82 |
} |
83 |
if (getFileName() == null) { |
84 |
return false; |
85 |
} |
86 |
return true; |
87 |
} |
88 |
|
89 |
public File getFile() { |
90 |
return new File(this.getFileName()); |
91 |
} |
92 |
|
93 |
public void setFile(File file) { |
94 |
this.setFileName(file.getPath());
|
95 |
} |
96 |
|
97 |
public FeatureType getDefaultFeatureType() {
|
98 |
return null; //TODO ???? |
99 |
} |
100 |
|
101 |
public void setDefaultFeatureType(FeatureType defaultFeatureType) { |
102 |
throw new UnsupportedOperationException(); |
103 |
} |
104 |
|
105 |
protected static void registerDynClass() { |
106 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
107 |
DynClass dynClass; |
108 |
DynField field; |
109 |
if (DYNCLASS == null) { |
110 |
dynClass = dynman.add(DYNCLASS_NAME); |
111 |
|
112 |
field = dynClass.addDynField(FIELD_SRS); |
113 |
field.setType(DataTypes.SRS); |
114 |
field.setDescription("The SRS identifier");
|
115 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
116 |
field.setMandatory(true);
|
117 |
|
118 |
field = dynClass.addDynField(FIELD_FILEPATH); |
119 |
field.setType(DataTypes.STRING); |
120 |
field.setDescription("The DXF file path");
|
121 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
122 |
field.setMandatory(true);
|
123 |
DYNCLASS = dynClass; |
124 |
|
125 |
// Register the DynClass in the PersistenceManager
|
126 |
ToolsLocator.getPersistenceManager().registerClass( |
127 |
DXFStoreParameters.class, dynClass); |
128 |
} |
129 |
} |
130 |
|
131 |
// public XMLEntity getXMLEntity() {
|
132 |
// XMLEntity xmlEntity = super.getXMLEntity();
|
133 |
// xmlEntity.putProperty("srsid", this.getSRSID());
|
134 |
// xmlEntity.putProperty("file", this.getFileName());
|
135 |
// return xmlEntity;
|
136 |
// }
|
137 |
//
|
138 |
// public void loadFromXMLEntity(XMLEntity xmlEntity)
|
139 |
// throws InitializeException {
|
140 |
// try {
|
141 |
// this.setSRSID(xmlEntity.getStringProperty("srsid"));
|
142 |
// this.setFileName(xmlEntity.getStringProperty("file"));
|
143 |
// } catch (NotExistInXMLEntity e) {
|
144 |
// throw new InitializeException(e);
|
145 |
// }
|
146 |
// }
|
147 |
|
148 |
|
149 |
// public DataParameters getCopy() throws DataException {
|
150 |
// DXFStoreParameters copy = new DXFStoreParameters();
|
151 |
// this.copyValuesTo(copy);
|
152 |
// return copy;
|
153 |
// }
|
154 |
|
155 |
} |