Revision 12132
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/BeforeRowEditEvent.java | ||
---|---|---|
4 | 4 |
|
5 | 5 |
public class BeforeRowEditEvent extends EditionEvent { |
6 | 6 |
|
7 |
long numRow;
|
|
7 |
String newFID;
|
|
8 | 8 |
int changeType; |
9 | 9 |
Cancellable cancel; |
10 |
public BeforeRowEditEvent(IEditableSource source, long numRow, int changeType, Cancellable cancel,int sourceType)
|
|
10 |
public BeforeRowEditEvent(IEditableSource source, String newFID, int changeType, Cancellable cancel,int sourceType)
|
|
11 | 11 |
{ |
12 | 12 |
super(source, EditionEvent.ROW_EDITION, sourceType); |
13 |
this.numRow = numRow;
|
|
13 |
this.newFID = newFID;
|
|
14 | 14 |
this.changeType = changeType; |
15 | 15 |
this.cancel = cancel; |
16 | 16 |
} |
... | ... | |
29 | 29 |
/** |
30 | 30 |
* @return Returns the numRow. |
31 | 31 |
*/ |
32 |
public long getNumRow() {
|
|
33 |
return numRow;
|
|
32 |
public String getFID() {
|
|
33 |
return newFID;
|
|
34 | 34 |
} |
35 | 35 |
|
36 | 36 |
} |
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/AnnotationEditableAdapter.java | ||
---|---|---|
168 | 168 |
|
169 | 169 |
|
170 | 170 |
public int doAddRow(IRow feat, int sourceType) throws DriverIOException, IOException { |
171 |
boolean cancel = fireBeforeRowAdded(sourceType); |
|
171 |
boolean cancel = fireBeforeRowAdded(sourceType,feat.getID());
|
|
172 | 172 |
if (cancel) |
173 | 173 |
return -1; |
174 | 174 |
Value[] values=feat.getAttributes(); |
... | ... | |
187 | 187 |
|
188 | 188 |
int calculatedIndex = -1; |
189 | 189 |
try { |
190 |
calculatedIndex = (int) getNewIndex() ;
|
|
190 |
calculatedIndex = (int) getOriginalRecordset().getRowCount() + numAdd;
|
|
191 | 191 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
192 | 192 |
throw new DriverIOException(e); |
193 | 193 |
} |
... | ... | |
406 | 406 |
} |
407 | 407 |
|
408 | 408 |
public void undoRemoveRow(int index, int sourceType) throws IOException, DriverIOException { |
409 |
boolean cancel = fireBeforeRowAdded(sourceType); |
|
410 |
if (cancel) |
|
409 |
|
|
410 |
delRows.set(index, false); |
|
411 |
String fid=getRow(index).getID(); |
|
412 |
boolean cancel = fireBeforeRowAdded(sourceType,fid); |
|
413 |
if (cancel){ |
|
414 |
delRows.set(index,true); |
|
411 | 415 |
return; |
412 |
delRows.set(index, false);
|
|
416 |
}
|
|
413 | 417 |
Rectangle2D r = getLabel(index,true).getBoundBox(); |
414 | 418 |
this.index.insert(new Envelope(r.getX(), r.getX() + r.getWidth(), |
415 | 419 |
r.getY(), r.getY() + r.getHeight()), new Integer(index)); |
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/VectorialEditableDBAdapter.java | ||
---|---|---|
30 | 30 |
*/ |
31 | 31 |
public class VectorialEditableDBAdapter extends VectorialEditableAdapter |
32 | 32 |
implements ISpatialDB { |
33 |
private int maxIndex=0; |
|
34 | 33 |
private class MyIterator implements IFeatureIterator { |
35 | 34 |
private Rectangle2D extent = null; |
36 | 35 |
|
... | ... | |
226 | 225 |
|
227 | 226 |
|
228 | 227 |
private Hashtable mapFID2index = new Hashtable(); |
229 |
private Hashtable mapIndex2FID = new Hashtable(); |
|
228 |
// private Hashtable mapIndex2FID = new Hashtable();
|
|
230 | 229 |
/** |
231 | 230 |
* |
232 | 231 |
*/ |
... | ... | |
293 | 292 |
IFeature feat = ova.getFeature(i); |
294 | 293 |
Integer calculatedIndex = new Integer(i); |
295 | 294 |
mapFID2index.put(feat.getID(), calculatedIndex); |
296 |
int featInt=Integer.parseInt(feat.getID()); |
|
297 |
if (maxIndex<featInt){ |
|
298 |
maxIndex=featInt; |
|
299 |
} |
|
300 |
mapIndex2FID.put(calculatedIndex, feat.getID()); |
|
295 |
// mapIndex2FID.put(calculatedIndex, feat.getID()); |
|
301 | 296 |
} |
302 | 297 |
|
303 | 298 |
/* |
... | ... | |
356 | 351 |
// es decir, virtual es el calculatedIndex (no tiene en cuenta los borrados) |
357 | 352 |
// calculatedIndex = indiceExterno + borrados hasta ese punto. |
358 | 353 |
mapFID2index.put(feat.getID(), virtual); |
359 |
mapIndex2FID.put(virtual, feat.getID()); |
|
354 |
// mapIndex2FID.put(virtual, feat.getID());
|
|
360 | 355 |
return calculatedIndex; |
361 | 356 |
|
362 | 357 |
} |
... | ... | |
369 | 364 |
// No hacemos nada con las modificaciones sobre los ?ndices. |
370 | 365 |
// Suponiendo que feat tenga la misma ID que la que hab?a antes. |
371 | 366 |
Integer virtual = new Integer(calculatedIndex); |
372 |
String theIDoriginal = (String) mapIndex2FID.get(virtual); |
|
373 |
if (!theIDoriginal.equals(feat.getID())) |
|
374 |
{ |
|
375 |
AssertionError err = new AssertionError("Fallo al modificar la fila. ID viejo=" + theIDoriginal + " ID nuevo = " + feat.getID()); |
|
376 |
err.printStackTrace(); |
|
377 |
} |
|
367 |
// String theIDoriginal = (String) mapIndex2FID.get(virtual);
|
|
368 |
// if (!theIDoriginal.equals(feat.getID()))
|
|
369 |
// {
|
|
370 |
// AssertionError err = new AssertionError("Fallo al modificar la fila. ID viejo=" + theIDoriginal + " ID nuevo = " + feat.getID());
|
|
371 |
// err.printStackTrace();
|
|
372 |
// }
|
|
378 | 373 |
// hashFIDtoExpansionFile.put(feat.getID(), new Integer(posInExpansionFile)); |
379 | 374 |
mapFID2index.put(feat.getID(), virtual); |
380 |
mapIndex2FID.put(virtual, feat.getID()); |
|
375 |
// mapIndex2FID.put(virtual, feat.getID());
|
|
381 | 376 |
return posAnteriorInExpansionFile; |
382 | 377 |
} |
383 | 378 |
|
... | ... | |
400 | 395 |
// TODO Auto-generated method stub |
401 | 396 |
super.undoAddRow(calculatedIndex,sourceType); |
402 | 397 |
Integer calculated = new Integer(calculatedIndex); |
403 |
String theID = (String) mapIndex2FID.get(calculated); |
|
398 |
// String theID = (String) mapIndex2FID.get(calculated);
|
|
404 | 399 |
mapFID2index.remove(calculated); |
405 |
mapIndex2FID.remove(theID); |
|
400 |
// mapIndex2FID.remove(theID);
|
|
406 | 401 |
|
407 | 402 |
} |
408 | 403 |
|
409 | 404 |
public void cancelEdition(int sourceType) throws IOException { |
410 | 405 |
super.cancelEdition(sourceType); |
411 | 406 |
mapFID2index.clear(); |
412 |
mapIndex2FID.clear(); |
|
407 |
// mapIndex2FID.clear();
|
|
413 | 408 |
} |
414 | 409 |
|
415 | 410 |
public void stopEdition(IWriter writer, int sourceType) throws EditionException { |
416 | 411 |
super.stopEdition(writer, sourceType); |
417 | 412 |
mapFID2index.clear(); |
418 |
mapIndex2FID.clear(); |
|
413 |
// mapIndex2FID.clear();
|
|
419 | 414 |
} |
420 | 415 |
|
421 |
public int getNewIndex() throws com.hardcode.gdbms.engine.data.driver.DriverException { |
|
422 |
int index = maxIndex+1;
|
|
423 |
while(mapFID2index.containsKey(String.valueOf(index))){ |
|
424 |
index++; |
|
425 |
} |
|
426 |
return index; |
|
427 |
} |
|
416 |
// public int getNewIndex() throws com.hardcode.gdbms.engine.data.driver.DriverException {
|
|
417 |
// int index = maxIndex;
|
|
418 |
// while(mapFID2index.containsKey(String.valueOf(index))){
|
|
419 |
// index++;
|
|
420 |
// }
|
|
421 |
// return index;
|
|
422 |
// }
|
|
428 | 423 |
|
429 | 424 |
|
430 | 425 |
} |
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/EditableAdapter.java | ||
---|---|---|
1 | 1 |
package com.iver.cit.gvsig.fmap.edition; |
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 |
import java.rmi.server.UID; |
|
4 | 5 |
import java.util.ArrayList; |
5 | 6 |
import java.util.Collection; |
6 | 7 |
import java.util.HashMap; |
... | ... | |
487 | 488 |
} |
488 | 489 |
|
489 | 490 |
} |
490 |
public int getNewIndex() throws com.hardcode.gdbms.engine.data.driver.DriverException { |
|
491 |
int index=(int)ods.getRowCount() + numAdd; |
|
492 |
return index; |
|
491 |
public String getNewFID() { |
|
492 |
return "fid-" + (new UID()).toString(); |
|
493 | 493 |
} |
494 | 494 |
/* |
495 | 495 |
* (non-Javadoc) |
... | ... | |
793 | 793 |
*/ |
794 | 794 |
public int doAddRow(IRow feat, int sourceType) throws DriverIOException, |
795 | 795 |
IOException { |
796 |
boolean cancel = fireBeforeRowAdded(sourceType); |
|
796 |
|
|
797 |
boolean cancel = fireBeforeRowAdded(sourceType,feat.getID()); |
|
797 | 798 |
if (cancel) |
798 | 799 |
return -1; |
799 | 800 |
// A?ade la geometr?a |
... | ... | |
829 | 830 |
*/ |
830 | 831 |
public void undoRemoveRow(int index, int sourceType) throws IOException, |
831 | 832 |
DriverIOException { |
832 |
boolean cancel = fireBeforeRowAdded(sourceType); |
|
833 |
if (cancel) |
|
833 |
delRows.set(index, false); |
|
834 |
String fid=getRow(index).getID(); |
|
835 |
boolean cancel = fireBeforeRowAdded(sourceType,fid); |
|
836 |
if (cancel){ |
|
837 |
delRows.set(index,true); |
|
834 | 838 |
return; |
835 |
delRows.set(index, false); |
|
839 |
} |
|
840 |
|
|
836 | 841 |
fireAfterRowAdded(null,index, sourceType); |
837 | 842 |
} |
838 | 843 |
|
... | ... | |
1210 | 1215 |
|
1211 | 1216 |
protected boolean fireBeforeRemoveRow(int index, int sourceType) { |
1212 | 1217 |
Cancel cancel = new Cancel(); |
1213 |
BeforeRowEditEvent event = new BeforeRowEditEvent(this, index, |
|
1218 |
String fid=null; |
|
1219 |
try { |
|
1220 |
fid = getRow(index).getID(); |
|
1221 |
} catch (DriverIOException e) { |
|
1222 |
e.printStackTrace(); |
|
1223 |
} catch (IOException e) { |
|
1224 |
e.printStackTrace(); |
|
1225 |
} |
|
1226 |
BeforeRowEditEvent event = new BeforeRowEditEvent(this, fid, |
|
1214 | 1227 |
EditionEvent.CHANGE_TYPE_DELETE, cancel, sourceType); |
1215 | 1228 |
for (int i = 0; i < editionListeners.size(); i++) { |
1216 | 1229 |
IEditionListener listener = (IEditionListener) editionListeners |
... | ... | |
1280 | 1293 |
} |
1281 | 1294 |
|
1282 | 1295 |
|
1283 |
protected boolean fireBeforeRowAdded(int sourceType) |
|
1296 |
protected boolean fireBeforeRowAdded(int sourceType,String newFID)
|
|
1284 | 1297 |
throws DriverIOException, IOException { |
1285 | 1298 |
Cancel cancel = new Cancel(); |
1286 | 1299 |
BeforeRowEditEvent event; |
1287 |
try { |
|
1288 |
event = new BeforeRowEditEvent(this, getNewIndex(), |
|
1289 |
EditionEvent.CHANGE_TYPE_ADD, cancel, sourceType); |
|
1290 |
} catch (DriverException e) { |
|
1291 |
throw new DriverIOException(e); |
|
1292 |
} |
|
1300 |
event = new BeforeRowEditEvent(this, newFID, |
|
1301 |
EditionEvent.CHANGE_TYPE_ADD, cancel, sourceType); |
|
1293 | 1302 |
for (int i = 0; i < editionListeners.size(); i++) { |
1294 | 1303 |
IEditionListener listener = (IEditionListener) editionListeners |
1295 | 1304 |
.get(i); |
... | ... | |
1333 | 1342 |
|
1334 | 1343 |
protected boolean fireBeforeModifyRow(IRow feat, int index, int sourceType) { |
1335 | 1344 |
Cancel cancel = new Cancel(); |
1336 |
BeforeRowEditEvent event = new BeforeRowEditEvent(this, index, |
|
1345 |
String fid=null; |
|
1346 |
try { |
|
1347 |
fid = getRow(index).getID(); |
|
1348 |
} catch (DriverIOException e) { |
|
1349 |
e.printStackTrace(); |
|
1350 |
} catch (IOException e) { |
|
1351 |
e.printStackTrace(); |
|
1352 |
} |
|
1353 |
BeforeRowEditEvent event = new BeforeRowEditEvent(this, fid, |
|
1337 | 1354 |
EditionEvent.CHANGE_TYPE_MODIFY, cancel, sourceType); |
1338 | 1355 |
for (int i = 0; i < editionListeners.size(); i++) { |
1339 | 1356 |
IEditionListener listener = (IEditionListener) editionListeners |
branches/v10/extensions/extAddEventTheme/src/com/iver/gvsig/addeventtheme/AddEventThemListener.java | ||
---|---|---|
52 | 52 |
if (EditionEvent.CHANGE_TYPE_MODIFY == e.getChangeType()) { |
53 | 53 |
VectorialEditableAdapter vea = (VectorialEditableAdapter) e |
54 | 54 |
.getSource(); |
55 |
int numRow = (int) e.getNumRow(); |
|
55 |
//int numRow = (int) e.getNumRow();
|
|
56 | 56 |
//DefaultFeature df = null; |
57 | 57 |
try { |
58 | 58 |
//df = (DefaultFeature) vea.getFeature(numRow); |
Also available in: Unified diff