Revision 44439
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/AbstractStoresRepository.java | ||
---|---|---|
109 | 109 |
} |
110 | 110 |
|
111 | 111 |
@Override |
112 |
public StoresRepository getSubrepository(String Id) { |
|
113 |
for (StoresRepository repo : this.subrepositories) { |
|
114 |
if( repo!=null && StringUtils.equalsIgnoreCase(Id, repo.getID()) ) { |
|
115 |
return repo; |
|
116 |
} |
|
117 |
} |
|
118 |
return null; |
|
119 |
} |
|
120 |
|
|
121 |
@Override |
|
112 | 122 |
public boolean addRepository(StoresRepository repository) { |
113 | 123 |
if( this.notifyObservers(NOTIFICATION_ADDREPOSITORY, repository).isCanceled() ) { |
114 | 124 |
return false; |
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 | ||
---|---|---|
332 | 332 |
|
333 | 333 |
public List<FeatureAttributeDescriptor> getRecentUseds(); |
334 | 334 |
|
335 |
FeatureStore getAsFeatureStore(); |
|
335 | 336 |
} |
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/StoresRepository.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
public Collection<StoresRepository> getSubrepositories(); |
28 | 28 |
|
29 |
public StoresRepository getSubrepository(String Id); |
|
30 |
|
|
29 | 31 |
public boolean addRepository(StoresRepository repository); |
30 | 32 |
|
31 | 33 |
public boolean removeRepository(String name); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/test/java/org/gvsig/fmap/dal/feature/DummyFeatureType.java | ||
---|---|---|
456 | 456 |
|
457 | 457 |
} |
458 | 458 |
|
459 |
@Override |
|
460 |
public FeatureStore getAsFeatureStore() { |
|
461 |
return null; |
|
462 |
} |
|
463 |
|
|
459 | 464 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/AbstractFeatureStoreProvider.java | ||
---|---|---|
491 | 491 |
|
492 | 492 |
@Override |
493 | 493 |
public ResourcesStorage getResourcesStorage() { |
494 |
return null;
|
|
494 |
return ResourcesStorage.EMPTY_RESOURCESSTORAGE;
|
|
495 | 495 |
} |
496 | 496 |
|
497 | 497 |
/** |
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/store/memory/MemoryStoreProvider.java | ||
---|---|---|
105 | 105 |
new Object[] { memoryStoreParameters.getName() }); |
106 | 106 |
} |
107 | 107 |
|
108 |
@Override |
|
108 | 109 |
public FeatureProvider createFeatureProvider(FeatureType featureType)throws DataException { |
109 | 110 |
this.open(); |
110 | 111 |
return new DefaultFeatureProvider(featureType, this.createNewOID()); |
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/FeatureTypeToStoreProviderAdapter.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.feature.impl; |
|
2 |
|
|
3 |
import java.util.AbstractList; |
|
4 |
import java.util.Collections; |
|
5 |
import java.util.HashMap; |
|
6 |
import java.util.List; |
|
7 |
import java.util.Map; |
|
8 |
import org.gvsig.expressionevaluator.Expression; |
|
9 |
import org.gvsig.fmap.dal.DALLocator; |
|
10 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
11 |
import org.gvsig.fmap.dal.DataTypes; |
|
12 |
import org.gvsig.fmap.dal.exception.DataException; |
|
13 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
14 |
import org.gvsig.fmap.dal.exception.OpenException; |
|
15 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureAttributeEmulatorExpression; |
|
16 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
17 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
18 |
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
|
19 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
20 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
21 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
|
22 |
import org.gvsig.fmap.dal.feature.spi.memory.AbstractMemoryStoreProvider; |
|
23 |
import org.gvsig.fmap.dal.feature.spi.memory.MemoryResource; |
|
24 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
|
25 |
import org.gvsig.fmap.dal.spi.DataStoreInitializer2; |
|
26 |
import org.gvsig.fmap.dal.spi.DataStoreProvider; |
|
27 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
28 |
import org.gvsig.fmap.dal.store.memory.MemoryStoreParameters; |
|
29 |
import org.gvsig.fmap.geom.Geometry; |
|
30 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
31 |
import org.gvsig.timesupport.Time; |
|
32 |
|
|
33 |
/** |
|
34 |
* |
|
35 |
* @author jjdelcerro |
|
36 |
*/ |
|
37 |
public class FeatureTypeToStoreProviderAdapter extends AbstractMemoryStoreProvider { |
|
38 |
|
|
39 |
private static final String NAME = "FeatureType"; |
|
40 |
|
|
41 |
private static final int ATTR_NAME = 0; |
|
42 |
private static final int ATTR_TYPE = 1; |
|
43 |
private static final int ATTR_TYPENAME = 2; |
|
44 |
private static final int ATTR_SIZE = 3; |
|
45 |
private static final int ATTR_PRECISION = 4; |
|
46 |
private static final int ATTR_LABEL = 5; |
|
47 |
private static final int ATTR_SHORTLABEL = 6; |
|
48 |
private static final int ATTR_DESCRIPTION = 7; |
|
49 |
private static final int ATTR_PROFILE = 8; |
|
50 |
private static final int ATTR_GROUP = 9; |
|
51 |
private static final int ATTR_ORDER = 10; |
|
52 |
private static final int ATTR_ISPK = 11; |
|
53 |
private static final int ATTR_ISFK = 12; |
|
54 |
private static final int ATTR_ISCLOSEDLIST = 13; |
|
55 |
private static final int ATTR_ISREADONLY = 14; |
|
56 |
private static final int ATTR_ISCOMPUTED = 15; |
|
57 |
private static final int ATTR_ISCAUTOMATIC = 16; |
|
58 |
private static final int ATTR_ISHIDDEN = 17; |
|
59 |
private static final int ATTR_ALLOWNULLS = 18; |
|
60 |
private static final int ATTR_EXPRESSION = 19; |
|
61 |
private static final int ATTR_FKTABLE = 20; |
|
62 |
private static final int ATTR_FKCODE = 21; |
|
63 |
private static final int ATTR_FKLABEL = 22; |
|
64 |
|
|
65 |
private static Map<String,Integer> attrName2Index; |
|
66 |
private static FeatureType featureTypeOfFeatureType; |
|
67 |
|
|
68 |
|
|
69 |
private static class Features |
|
70 |
extends AbstractList<FeatureProvider> |
|
71 |
implements List<FeatureProvider> |
|
72 |
{ |
|
73 |
|
|
74 |
private static class MyFeatureProvider implements FeatureProvider { |
|
75 |
|
|
76 |
private FeatureAttributeDescriptor descriptor; |
|
77 |
|
|
78 |
public MyFeatureProvider(FeatureAttributeDescriptor descriptor) { |
|
79 |
this.descriptor = descriptor; |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public boolean isReadOnly(int i) { |
|
84 |
return true; |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
88 |
public void set(int i, Object value) { |
|
89 |
} |
|
90 |
|
|
91 |
@Override |
|
92 |
public Object get(int i) { |
|
93 |
switch(i) { |
|
94 |
case ATTR_NAME: |
|
95 |
return this.descriptor.getName(); |
|
96 |
case ATTR_SIZE: |
|
97 |
return this.descriptor.getSize(); |
|
98 |
case ATTR_TYPE: |
|
99 |
return this.descriptor.getType(); |
|
100 |
case ATTR_TYPENAME: |
|
101 |
return this.descriptor.getDataTypeName(); |
|
102 |
case ATTR_PRECISION: |
|
103 |
return this.descriptor.getPrecision(); |
|
104 |
case ATTR_SHORTLABEL: |
|
105 |
return this.descriptor.getShortLabel(); |
|
106 |
case ATTR_LABEL: |
|
107 |
return this.descriptor.getLabel(); |
|
108 |
case ATTR_DESCRIPTION: |
|
109 |
return this.descriptor.getDescription(); |
|
110 |
case ATTR_PROFILE: |
|
111 |
return this.descriptor.getDataProfileName(); |
|
112 |
case ATTR_GROUP: |
|
113 |
return this.descriptor.getGroup(); |
|
114 |
case ATTR_ORDER: |
|
115 |
return this.descriptor.getOder(); |
|
116 |
case ATTR_ISPK: |
|
117 |
return this.descriptor.isPrimaryKey(); |
|
118 |
case ATTR_ISFK: |
|
119 |
return this.descriptor.isForeingKey(); |
|
120 |
case ATTR_ISCLOSEDLIST: |
|
121 |
if( this.descriptor.isForeingKey() ) { |
|
122 |
return this.descriptor.getForeingKey().isClosedList(); |
|
123 |
} |
|
124 |
return false; |
|
125 |
case ATTR_ISREADONLY: |
|
126 |
return this.descriptor.isReadOnly(); |
|
127 |
case ATTR_ISCOMPUTED: |
|
128 |
return this.descriptor.isComputed(); |
|
129 |
case ATTR_ISCAUTOMATIC: |
|
130 |
return this.descriptor.isAutomatic(); |
|
131 |
case ATTR_ISHIDDEN: |
|
132 |
return this.descriptor.isHidden(); |
|
133 |
case ATTR_ALLOWNULLS: |
|
134 |
return this.descriptor.allowNull(); |
|
135 |
case ATTR_EXPRESSION: { |
|
136 |
FeatureAttributeEmulator x = this.descriptor.getFeatureAttributeEmulator(); |
|
137 |
if( x instanceof FeatureAttributeEmulatorExpression ) { |
|
138 |
Expression exp = ((FeatureAttributeEmulatorExpression) x).getExpression(); |
|
139 |
if( exp != null ) { |
|
140 |
return exp.getPhrase(); |
|
141 |
} |
|
142 |
} |
|
143 |
return null; |
|
144 |
} |
|
145 |
case ATTR_FKTABLE: |
|
146 |
if( this.descriptor.isForeingKey() ) { |
|
147 |
return this.descriptor.getForeingKey().getTableName(); |
|
148 |
} |
|
149 |
return null; |
|
150 |
case ATTR_FKCODE: |
|
151 |
if( this.descriptor.isForeingKey() ) { |
|
152 |
return this.descriptor.getForeingKey().getCodeName(); |
|
153 |
} |
|
154 |
return null; |
|
155 |
case ATTR_FKLABEL: |
|
156 |
if( this.descriptor.isForeingKey() ) { |
|
157 |
return this.descriptor.getForeingKey().getLabelFormula(); |
|
158 |
} |
|
159 |
return null; |
|
160 |
|
|
161 |
|
|
162 |
default: |
|
163 |
return null; |
|
164 |
} |
|
165 |
} |
|
166 |
|
|
167 |
@Override |
|
168 |
public void set(String name, Object value) { |
|
169 |
} |
|
170 |
|
|
171 |
@Override |
|
172 |
public Object get(String name) { |
|
173 |
int n = attrName2Index.get(name); |
|
174 |
return this.get(n); |
|
175 |
} |
|
176 |
|
|
177 |
@Override |
|
178 |
public void setOID(Object oid) { |
|
179 |
} |
|
180 |
|
|
181 |
@Override |
|
182 |
public Object getOID() { |
|
183 |
return this.descriptor.getIndex(); |
|
184 |
} |
|
185 |
|
|
186 |
@Override |
|
187 |
public FeatureType getType() { |
|
188 |
return featureTypeOfFeatureType; |
|
189 |
} |
|
190 |
|
|
191 |
@Override |
|
192 |
public FeatureProvider getCopy() { |
|
193 |
return this; |
|
194 |
} |
|
195 |
|
|
196 |
@Override |
|
197 |
public Envelope getDefaultEnvelope() { |
|
198 |
return null; |
|
199 |
} |
|
200 |
|
|
201 |
@Override |
|
202 |
public Geometry getDefaultGeometry() { |
|
203 |
return null; |
|
204 |
} |
|
205 |
|
|
206 |
@Override |
|
207 |
public Time getDefaultTime() { |
|
208 |
return null; |
|
209 |
} |
|
210 |
|
|
211 |
@Override |
|
212 |
public void setDefaultEnvelope(Envelope extent) { |
|
213 |
} |
|
214 |
|
|
215 |
@Override |
|
216 |
public void setDefaultGeometry(Geometry geom) { |
|
217 |
} |
|
218 |
|
|
219 |
@Override |
|
220 |
public void setDefaultTime(Time time) { |
|
221 |
} |
|
222 |
|
|
223 |
@Override |
|
224 |
public boolean isNull(int i) { |
|
225 |
return false; |
|
226 |
} |
|
227 |
|
|
228 |
@Override |
|
229 |
public boolean isNull(String name) { |
|
230 |
return false; |
|
231 |
} |
|
232 |
|
|
233 |
@Override |
|
234 |
public boolean isNew() { |
|
235 |
return false; |
|
236 |
} |
|
237 |
|
|
238 |
@Override |
|
239 |
public void setNew(boolean isNew) { |
|
240 |
} |
|
241 |
|
|
242 |
@Override |
|
243 |
public void setExtraValue(int index, Object value) { |
|
244 |
} |
|
245 |
|
|
246 |
@Override |
|
247 |
public Object getExtraValue(int index) { |
|
248 |
return null; |
|
249 |
} |
|
250 |
|
|
251 |
@Override |
|
252 |
public Object getExtraValue(String name) { |
|
253 |
return null; |
|
254 |
} |
|
255 |
|
|
256 |
@Override |
|
257 |
public void setExtraValueNames(String[] extraValueNames) { |
|
258 |
} |
|
259 |
|
|
260 |
} |
|
261 |
|
|
262 |
private final FeatureType featureType; |
|
263 |
|
|
264 |
public Features(FeatureType featureType) { |
|
265 |
this.featureType = featureType; |
|
266 |
} |
|
267 |
|
|
268 |
@Override |
|
269 |
public FeatureProvider get(int index) { |
|
270 |
return new MyFeatureProvider(this.featureType.get(index)); |
|
271 |
} |
|
272 |
|
|
273 |
@Override |
|
274 |
public int size() { |
|
275 |
return this.featureType.size(); |
|
276 |
} |
|
277 |
|
|
278 |
} |
|
279 |
|
|
280 |
private final FeatureType featureType; |
|
281 |
private final ResourceProvider resource; |
|
282 |
private final Double sourceID; |
|
283 |
|
|
284 |
private FeatureTypeToStoreProviderAdapter( |
|
285 |
DataStoreParameters parameters, |
|
286 |
DataStoreProviderServices storeServices, |
|
287 |
FeatureType featureType |
|
288 |
) throws InitializeException { |
|
289 |
super(parameters, storeServices); |
|
290 |
this.featureType = featureType; |
|
291 |
this.data = new Features(featureType); |
|
292 |
this.sourceID = Math.random(); |
|
293 |
this.resource = createResource( |
|
294 |
MemoryResource.NAME, |
|
295 |
new Object[] { NAME } |
|
296 |
); |
|
297 |
|
|
298 |
if( featureTypeOfFeatureType==null ) { |
|
299 |
this.initFeatureType(); |
|
300 |
} |
|
301 |
|
|
302 |
this.getStoreServices().setFeatureTypes( |
|
303 |
Collections.singletonList(featureTypeOfFeatureType), |
|
304 |
featureTypeOfFeatureType |
|
305 |
); |
|
306 |
} |
|
307 |
|
|
308 |
public static FeatureStore createFeatureStore(FeatureType featureType) { |
|
309 |
try { |
|
310 |
DataStoreParameters parameters = FeatureTypeToStoreProviderAdapter.getParameters(featureType); |
|
311 |
DefaultFeatureStore store = new DefaultFeatureStore(); |
|
312 |
DataStoreProvider provider = new FeatureTypeToStoreProviderAdapter( |
|
313 |
parameters, |
|
314 |
store, |
|
315 |
featureType |
|
316 |
); |
|
317 |
store.intialize(DALLocator.getDataManager(), parameters); |
|
318 |
((DataStoreInitializer2)store).setProvider(provider); |
|
319 |
return store; |
|
320 |
} catch (Exception ex) { |
|
321 |
return null; |
|
322 |
} |
|
323 |
|
|
324 |
} |
|
325 |
|
|
326 |
private void initFeatureType() { |
|
327 |
if( featureTypeOfFeatureType!=null ) { |
|
328 |
return; |
|
329 |
} |
|
330 |
EditableFeatureType ft = this.getStoreServices().createFeatureType( |
|
331 |
getName() |
|
332 |
); |
|
333 |
ft.setHasOID(true); |
|
334 |
|
|
335 |
ft.add("name", DataTypes.STRING, 100); |
|
336 |
ft.add("type", DataTypes.INT, 0); |
|
337 |
ft.add("typeName", DataTypes.STRING, 100); |
|
338 |
ft.add("size", DataTypes.INT, 0); |
|
339 |
ft.add("precision", DataTypes.INT, 0); |
|
340 |
ft.add("label", DataTypes.STRING, 100); |
|
341 |
ft.add("shortlabel", DataTypes.STRING, 100); |
|
342 |
ft.add("description", DataTypes.STRING, 1024); |
|
343 |
ft.add("profile", DataTypes.STRING, 100); |
|
344 |
ft.add("group", DataTypes.STRING, 100); |
|
345 |
ft.add("order", DataTypes.INT, 0); |
|
346 |
ft.add("isPk", DataTypes.BOOLEAN, 0); |
|
347 |
ft.add("isFk", DataTypes.BOOLEAN, 0); |
|
348 |
ft.add("isClosedList", DataTypes.BOOLEAN, 0); |
|
349 |
ft.add("isReadOnly", DataTypes.BOOLEAN, 0); |
|
350 |
ft.add("isComputed", DataTypes.BOOLEAN, 0); |
|
351 |
ft.add("isAutomatic", DataTypes.BOOLEAN, 0); |
|
352 |
ft.add("isHidden", DataTypes.BOOLEAN, 0); |
|
353 |
ft.add("allowNulls", DataTypes.BOOLEAN, 0); |
|
354 |
ft.add("expression", DataTypes.STRING, 1024); |
|
355 |
ft.add("fkTable", DataTypes.STRING, 100); |
|
356 |
ft.add("fkCode", DataTypes.STRING, 100); |
|
357 |
ft.add("fkLabel", DataTypes.STRING, 1024); |
|
358 |
|
|
359 |
featureTypeOfFeatureType = ft; |
|
360 |
attrName2Index = new HashMap<>(); |
|
361 |
for (FeatureAttributeDescriptor attr : ft) { |
|
362 |
attrName2Index.put(attr.getName(), attr.getIndex()); |
|
363 |
} |
|
364 |
} |
|
365 |
|
|
366 |
private static MemoryStoreParameters getParameters(FeatureType featureType) { |
|
367 |
MemoryStoreParameters params = new MemoryStoreParameters(NAME); |
|
368 |
params.setDynValue(MemoryStoreParameters.ORDER_PARAMETER_NAME, "name"); |
|
369 |
return params; |
|
370 |
} |
|
371 |
|
|
372 |
@Override |
|
373 |
public void open() throws OpenException { |
|
374 |
} |
|
375 |
|
|
376 |
@Override |
|
377 |
public FeatureProvider createFeatureProvider(FeatureType featureType)throws DataException { |
|
378 |
return null; |
|
379 |
} |
|
380 |
|
|
381 |
@Override |
|
382 |
public ResourceProvider getResource() { |
|
383 |
return this.resource; |
|
384 |
} |
|
385 |
|
|
386 |
@Override |
|
387 |
public final Object getSourceId() { |
|
388 |
return this.sourceID; |
|
389 |
} |
|
390 |
|
|
391 |
@Override |
|
392 |
public final String getProviderName() { |
|
393 |
return NAME; |
|
394 |
} |
|
395 |
|
|
396 |
@Override |
|
397 |
public final String getName() { |
|
398 |
return this.featureType.getStore().getName() + "!" + this.featureType.getId(); |
|
399 |
} |
|
400 |
|
|
401 |
@Override |
|
402 |
public final String getFullName() { |
|
403 |
return this.featureType.getStore().getFullName()+ "!" + this.featureType.getId(); |
|
404 |
} |
|
405 |
|
|
406 |
@Override |
|
407 |
public Object createNewOID() { |
|
408 |
return null; |
|
409 |
} |
|
410 |
|
|
411 |
@Override |
|
412 |
public int getOIDType() { |
|
413 |
return DataTypes.LONG; |
|
414 |
} |
|
415 |
|
|
416 |
} |
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 | ||
---|---|---|
49 | 49 |
import org.gvsig.fmap.dal.feature.FeatureRules; |
50 | 50 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
51 | 51 |
import org.gvsig.fmap.dal.feature.FeatureType; |
52 |
import org.gvsig.fmap.dal.feature.impl.editing.memory.FeatureTypeManager; |
|
52 | 53 |
import org.gvsig.tools.ToolsLocator; |
53 | 54 |
import org.gvsig.tools.dynobject.DynClass; |
54 | 55 |
import org.gvsig.tools.dynobject.DynField; |
... | ... | |
1095 | 1096 |
} |
1096 | 1097 |
} |
1097 | 1098 |
|
1099 |
@Override |
|
1100 |
public FeatureStore getAsFeatureStore() { |
|
1101 |
FeatureStore store = FeatureTypeToStoreProviderAdapter.createFeatureStore(this); |
|
1102 |
return store; |
|
1103 |
} |
|
1104 |
|
|
1098 | 1105 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCServerExplorerBase.java | ||
---|---|---|
446 | 446 |
JDBCStoreParameters params; |
447 | 447 |
try { |
448 | 448 |
params = this.getOpenParameters(); |
449 |
params.setTable(DatabaseWorkspaceManager.TABLE_RESOURCES_NAME); |
|
449 | 450 |
JDBCResourcesStorage theResourcesStorage = new JDBCResourcesStorage( |
450 | 451 |
null, |
451 | 452 |
params, |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/TableManager.java | ||
---|---|---|
85 | 85 |
|
86 | 86 |
private static class TableDocumentStoresRepository extends AbstractStoresRepository { |
87 | 87 |
|
88 |
public TableDocumentStoresRepository(String name) { |
|
89 |
super(name); |
|
88 |
public TableDocumentStoresRepository(String name, String label) {
|
|
89 |
super(name, label);
|
|
90 | 90 |
} |
91 | 91 |
|
92 | 92 |
@Override |
... | ... | |
254 | 254 |
* |
255 | 255 |
*/ |
256 | 256 |
public static void register() { |
257 |
|
|
257 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
258 |
|
|
258 | 259 |
TableManager factory = new TableManager(); |
259 | 260 |
// A?adimos nuestra extension para el tratamiento de la apertura de |
260 | 261 |
// ficheros |
... | ... | |
322 | 323 |
ProjectManager.getInstance().registerDocumentAction(TYPENAME,new PasteDocumentAction()); |
323 | 324 |
|
324 | 325 |
DataManager dataManager = DALLocator.getDataManager(); |
325 |
dataManager.getStoresRepository().addRepository(new TableDocumentStoresRepository("Project tables")); |
|
326 |
dataManager.getStoresRepository().addRepository( |
|
327 |
new TableDocumentStoresRepository( |
|
328 |
"PROJECT_TABLES", |
|
329 |
i18n.getTranslation("_Project_tables") |
|
330 |
) |
|
331 |
); |
|
326 | 332 |
} |
327 | 333 |
|
328 | 334 |
/** |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/TableEditAttributes.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import java.awt.event.ActionEvent; |
27 | 27 |
import java.awt.event.ActionListener; |
28 |
import org.apache.commons.lang3.StringUtils; |
|
28 | 29 |
import org.gvsig.andami.IconThemeHelper; |
29 | 30 |
import org.gvsig.andami.plugins.Extension; |
30 | 31 |
import org.gvsig.app.ApplicationLocator; |
31 | 32 |
import org.gvsig.app.ApplicationManager; |
33 |
import org.gvsig.app.project.Project; |
|
34 |
import org.gvsig.app.project.ProjectManager; |
|
35 |
import org.gvsig.app.project.documents.Document; |
|
32 | 36 |
import org.gvsig.app.project.documents.table.TableDocument; |
33 | 37 |
import org.gvsig.app.project.documents.table.TableManager; |
34 | 38 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
39 |
import org.gvsig.fmap.dal.DALLocator; |
|
40 |
import org.gvsig.fmap.dal.DataManager; |
|
41 |
import org.gvsig.fmap.dal.DataStore; |
|
35 | 42 |
import org.gvsig.fmap.dal.DataTypes; |
43 |
import org.gvsig.fmap.dal.StoresRepository; |
|
36 | 44 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
37 | 45 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
38 | 46 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
... | ... | |
67 | 75 |
} |
68 | 76 |
|
69 | 77 |
public void execute(String s) { |
70 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
71 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
72 |
DataSwingManager dataSwingManager = DALSwingLocator.getSwingManager(); |
|
73 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
78 |
final I18nManager i18n = ToolsLocator.getI18nManager();
|
|
79 |
final WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
|
|
80 |
final DataSwingManager dataSwingManager = DALSwingLocator.getSwingManager();
|
|
81 |
final ApplicationManager application = ApplicationLocator.getManager();
|
|
74 | 82 |
|
75 | 83 |
TableDocument tabledoc = (TableDocument) application.getActiveDocument(TableManager.TYPENAME); |
76 | 84 |
if( tabledoc == null ) { |
... | ... | |
91 | 99 |
panel.asJComponent(), |
92 | 100 |
i18n.getTranslation("_Column_manager") + " - " + tabledoc.getName(), |
93 | 101 |
null, |
94 |
featureStore.isEditing()? WindowManager_v2.BUTTONS_OK_CANCEL:WindowManager_v2.BUTTONS_OK |
|
102 |
featureStore.isEditing()? |
|
103 |
WindowManager_v2.BUTTONS_APPLY_OK_CANCEL: |
|
104 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
95 | 105 |
); |
106 |
if( featureStore.isEditing() ) { |
|
107 |
dialog.setButtonLabel( |
|
108 |
WindowManager_v2.BUTTON_APPLY, |
|
109 |
i18n.getTranslation("_Show_as_table") |
|
110 |
); |
|
111 |
} else { |
|
112 |
dialog.setButtonLabel( |
|
113 |
WindowManager_v2.BUTTON_CANCEL, |
|
114 |
i18n.getTranslation("_Show_as_table") |
|
115 |
); |
|
116 |
} |
|
96 | 117 |
dialog.addActionListener(new ActionListener() { |
97 | 118 |
@Override |
98 | 119 |
public void actionPerformed(ActionEvent e) { |
99 |
if( dialog.getAction()!=WindowManager_v2.BUTTONS_OK ) { |
|
100 |
return; |
|
120 |
if( featureStore.isEditing() ) { |
|
121 |
switch(dialog.getAction()) { |
|
122 |
case WindowManager_v2.BUTTON_OK: |
|
123 |
break; |
|
124 |
case WindowManager_v2.BUTTON_APPLY: |
|
125 |
showAsTable(featureType); |
|
126 |
return; |
|
127 |
case WindowManager_v2.BUTTON_CANCEL: |
|
128 |
return; |
|
129 |
} |
|
130 |
} else { |
|
131 |
switch(dialog.getAction()) { |
|
132 |
case WindowManager_v2.BUTTON_OK: |
|
133 |
return; |
|
134 |
case WindowManager_v2.BUTTON_APPLY: |
|
135 |
case WindowManager_v2.BUTTON_CANCEL: |
|
136 |
showAsTable(featureType); |
|
137 |
return; |
|
138 |
} |
|
101 | 139 |
} |
102 |
if( !featureStore.isEditing() ) { |
|
103 |
return; |
|
104 |
} |
|
105 | 140 |
try { |
106 | 141 |
panel.fetch(editableFeatureType); |
107 | 142 |
featureStore.update(editableFeatureType); |
... | ... | |
157 | 192 |
} |
158 | 193 |
} |
159 | 194 |
|
195 |
private void showAsTable(FeatureType featureType) { |
|
196 |
FeatureStore store = featureType.getAsFeatureStore(); |
|
197 |
|
|
198 |
ProjectManager projectManager = ApplicationLocator.getManager().getProjectManager(); |
|
199 |
Project project = projectManager.getCurrentProject(); |
|
200 |
TableDocument tableDoc = (TableDocument) project.getDocument(store.getName(),TableManager.TYPENAME); |
|
201 |
if( tableDoc == null ) { |
|
202 |
tableDoc = (TableDocument) projectManager.createDocument(TableManager.TYPENAME); |
|
203 |
tableDoc.setStore(store); |
|
204 |
tableDoc.setName(store.getName()); |
|
205 |
project.addDocument(tableDoc); |
|
206 |
} |
|
207 |
ApplicationLocator.getManager().getUIManager().addWindow(tableDoc.getMainWindow()); |
|
208 |
} |
|
209 |
|
|
210 |
|
|
160 | 211 |
public boolean isEnabled() { |
161 | 212 |
ApplicationManager application = ApplicationLocator.getManager(); |
162 | 213 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
59 | 59 |
_Select_table_duplicates=Select table duplicates |
60 | 60 |
_Select_all_duplicates=Select all duplicates |
61 | 61 |
_Select_all_duplicates_in_the_table=Select all duplicates in the table |
62 |
_Project_tables=Project tables |
|
63 |
_Show_as_table=Show as table |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
59 | 59 |
_Select_table_duplicates=Seleccionar duplicados tabla |
60 | 60 |
_Select_all_duplicates=Seleccionar todos los duplicados |
61 | 61 |
_Select_all_duplicates_in_the_table=Seleccionar todos los duplicados de la tabla |
62 |
_Project_tables=Tablas del proyecto |
|
63 |
_Show_as_table=Mostrar como tabla |
Also available in: Unified diff