Revision 3304
org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.lib/org.gvsig.vcsgis.lib.impl/src/main/java/org/gvsig/vcsgis/lib/workspace/tables/AbstractTable.java | ||
---|---|---|
29 | 29 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
30 | 30 |
import org.gvsig.fmap.dal.feature.Feature; |
31 | 31 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
32 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
32 | 33 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
33 | 34 |
import org.gvsig.fmap.dal.feature.FeatureType; |
34 | 35 |
import org.gvsig.tools.dispose.DisposeUtils; |
... | ... | |
214 | 215 |
} |
215 | 216 |
} |
216 | 217 |
|
218 |
public void update(FeatureStore store, FeatureSet fSet) { |
|
219 |
try { |
|
220 |
EditableFeature feature = this.createFeature(store); |
|
221 |
feature.setUpdatable(true); |
|
222 |
fSet.update(feature); |
|
223 |
} catch (Exception ex) { |
|
224 |
throw new RuntimeException("Can't update feature on '"+this.tableName+"'.", ex); |
|
225 |
} |
|
226 |
} |
|
227 |
|
|
217 | 228 |
public void delete(FeatureStore store) { |
218 | 229 |
try { |
219 | 230 |
EditableFeature feat = this.createFeature(store); |
org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.lib/org.gvsig.vcsgis.lib.impl/src/main/java/org/gvsig/vcsgis/lib/workspace/VCSGisWorkspaceImpl.java | ||
---|---|---|
2470 | 2470 |
status.push(); |
2471 | 2471 |
isMyStatus = true; |
2472 | 2472 |
} |
2473 |
FeatureStore store = null; |
|
2474 |
FeatureSet fset = null; |
|
2473 | 2475 |
try { |
2474 | 2476 |
status.message("Getting repository table metadata"); |
2475 | 2477 |
VCSGisEntitiesRequest request = this.getRepository().createEntitiesRequest(); |
... | ... | |
2486 | 2488 |
tmp.put(entity.getEntityCode(), entity); |
2487 | 2489 |
}); |
2488 | 2490 |
this.repositoryEntitiesByCode = tmp; |
2491 |
|
|
2492 |
Map<String, EntityRow> theEntitiesByName = new HashMap<>(); |
|
2493 |
Map<String, EntityRow> theEntitiesByCode = new HashMap<>(); |
|
2489 | 2494 |
|
2495 |
store = openFeatureStore(EntitiesTable.TABLE_NAME); |
|
2496 |
store.edit(); |
|
2497 |
fset = store.getFeatureSet(); |
|
2498 |
for (Feature feature : fset.iterable()) { |
|
2499 |
EntityRow entity = new EntityRow(this, feature); |
|
2500 |
VCSGisEntity repositoryEntity = this.repositoryEntitiesByCode.get(entity.getEntityCode()); |
|
2501 |
if(repositoryEntity != null && !StringUtils.equalsIgnoreCase(entity.getRepositoryRevisionCode(),repositoryEntity.getRepositoryRevisionCode())){ |
|
2502 |
entity.setRepositoryRevisionCode(repositoryEntity.getRepositoryRevisionCode()); |
|
2503 |
entity.setTopologyPlanCode(repositoryEntity.getTopologyPlanCode()); |
|
2504 |
entity.update(store, fset); |
|
2505 |
} |
|
2506 |
theEntitiesByName.put(entity.getEntityName(), entity); |
|
2507 |
theEntitiesByCode.put(entity.getCode(), entity); |
|
2508 |
} |
|
2509 |
store.finishEditing(); |
|
2510 |
this.workspaceEntitiesByName = theEntitiesByName; |
|
2511 |
this.workspaceEntitiesByCode = theEntitiesByCode; |
|
2512 |
|
|
2490 | 2513 |
status.message("Repository tables metadata update completed"); |
2491 | 2514 |
if (isMyStatus) { |
2492 | 2515 |
status.terminate(); |
2493 | 2516 |
} |
2494 | 2517 |
this.repositoryEntitiesChangeListeners.fireEvent(); |
2518 |
this.workspaceEntitiesChangeListeners.fireEvent(); |
|
2495 | 2519 |
} catch (VCSGisRuntimeException ex) { |
2520 |
FeatureStore.cancelEditingQuietly(store); |
|
2496 | 2521 |
status.message("Can't get repository tables metadata"); |
2497 | 2522 |
if (isMyStatus) { |
2498 | 2523 |
status.abort(); |
2499 | 2524 |
} |
2500 | 2525 |
throw ex; |
2501 | 2526 |
} catch (Exception ex) { |
2527 |
FeatureStore.cancelEditingQuietly(store); |
|
2502 | 2528 |
status.message("Can't get repository tables metadata"); |
2503 | 2529 |
if (isMyStatus) { |
2504 | 2530 |
status.abort(); |
2505 | 2531 |
} |
2506 |
throw new VCSGisRuntimeException(ERR_CANT_RETRIEVE_ENTITIES, VCSGisUtils.getErrorMessage(ERR_CANT_RETRIEVE_ENTITIES)); |
|
2532 |
throw new VCSGisRuntimeException(ERR_CANT_RETRIEVE_ENTITIES, VCSGisUtils.getErrorMessage(ERR_CANT_RETRIEVE_ENTITIES), ex); |
|
2533 |
} finally { |
|
2534 |
DisposeUtils.disposeQuietly(fset); |
|
2535 |
DisposeUtils.disposeQuietly(store); |
|
2507 | 2536 |
} |
2508 | 2537 |
} |
2509 | 2538 |
|
org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.swing/org.gvsig.vcsgis.swing.impl/src/main/java/org/gvsig/vcsgis/swing/impl/changes/LocalChangesController.java | ||
---|---|---|
111 | 111 |
|
112 | 112 |
private VCSGisWorkspaceChanges<VCSGisWorkspaceChange> changes; |
113 | 113 |
private ChangesTableModel localChangesTableModel; |
114 |
|
|
114 |
private List<VCSGisWorkspaceEntity> entitiesWithChanges = null; |
|
115 |
|
|
115 | 116 |
private DatePickerController effectiveDatePicker; |
116 | 117 |
|
117 | 118 |
private final Set<String> entitiesToUnCheckAll; |
... | ... | |
184 | 185 |
|
185 | 186 |
this.workspacePicker.addChangeListener((ChangeEvent e) -> { |
186 | 187 |
doUpdateTableLocalChanges(); |
188 |
doReloadRepositoryEntities(); |
|
187 | 189 |
}); |
188 | 190 |
|
189 | 191 |
this.tblLocalChanges.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
... | ... | |
443 | 445 |
this.btnLocalCheckAll.setEnabled(!context.processing && changes!=null && changes.size64()>0); |
444 | 446 |
this.btnLocalUnCheckAll.setEnabled(!context.processing && changes!=null && changes.size64()>0); |
445 | 447 |
this.btnLocalRefresh.setEnabled(!context.processing && changes!=null); |
446 |
this.btnLocalRevert.setEnabled(ws!=null && !context.processing && changes!=null && changes.size64()>0 && !ws.getEntitiesWithChanges().isEmpty()); |
|
448 |
this.btnLocalRevert.setEnabled(ws!=null && |
|
449 |
!context.processing && |
|
450 |
changes!=null && |
|
451 |
changes.size64()>0 && |
|
452 |
entitiesWithChanges != null && |
|
453 |
!entitiesWithChanges.isEmpty() |
|
454 |
); |
|
447 | 455 |
this.btnLocalRevert.setVisible(true); |
448 |
this.btnLocalCommit.setEnabled(ws!=null && !context.processing && changes!=null && !this.changes.isSelectionEmpty() && ws.canCommit()); |
|
456 |
this.btnLocalCommit.setEnabled(ws!=null && |
|
457 |
!context.processing && |
|
458 |
changes!=null && |
|
459 |
!this.changes.isSelectionEmpty() && |
|
460 |
ws.canCommit() |
|
461 |
); |
|
449 | 462 |
//Show form |
450 | 463 |
boolean enableShowForm = false; |
451 | 464 |
|
... | ... | |
479 | 492 |
VCSGisWorkspace ws = this.getWorkspace(); |
480 | 493 |
|
481 | 494 |
if(ws != null){ |
495 |
|
|
496 |
entitiesWithChanges = ws.getEntitiesWithChanges(); |
|
497 |
|
|
482 | 498 |
changes = ws.getLocalChanges(); |
483 | 499 |
localChangesTableModel = new ChangesTableModel(changes, ws); |
484 | 500 |
this.tblLocalChanges.setModel(localChangesTableModel); |
... | ... | |
507 | 523 |
} |
508 | 524 |
context.doUpdateComponents(); |
509 | 525 |
} |
526 |
|
|
527 |
private void doReloadRepositoryEntities() { |
|
528 |
VCSGisWorkspace ws = this.getWorkspace(); |
|
529 |
if (ws != null) { |
|
530 |
Thread task = new Thread(() -> { |
|
531 |
try { |
|
532 |
context.processing = true; |
|
533 |
context.doUpdateComponents(); |
|
534 |
ws.reloadRepositoryEntities(null); |
|
535 |
} finally { |
|
536 |
context.processing = false; |
|
537 |
context.doUpdateComponents(); |
|
538 |
} |
|
539 |
}, "VCSGisReloadRepositoryEntities"); |
|
510 | 540 |
|
541 |
context.processing = true; |
|
542 |
context.doUpdateComponents(); |
|
543 |
task.start(); |
|
544 |
} |
|
545 |
} |
|
546 |
|
|
511 | 547 |
private TableModelListener getTableModelListener() { |
512 | 548 |
if(tableModelListener == null){ |
513 | 549 |
tableModelListener = (TableModelEvent e) -> { |
Also available in: Unified diff