Revision 29042

View differences:

trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/SplitGeometryCADTool.java
201 201
				new PrecisionModel(10000)).createLineString(digitizedCoords);
202 202

  
203 203
		ArrayList selectedRows = getSelectedRows();
204
//		ArrayList<IRowEdited> splitSelectionGeoms = new
205
//			ArrayList<IRowEdited>();
206 204
		IRowEdited editedRow = null;
207 205
		VectorialLayerEdited vle = getVLE();
208 206
		VectorialEditableAdapter vea = vle.getVEA();
209 207
		getCadToolAdapter().getMapControl().getMapContext().beginAtomicEvent();
210 208
		vea.startComplexRow();
211 209
		List<Integer> indices = new ArrayList<Integer>();
212
		for (int i = 0; i < selectedRows.size(); i++) {
213
			editedRow = (IRowEdited) selectedRows.get(i);
210
		ArrayList auxSelectedRows=new ArrayList(selectedRows);
211
		try {
212
			vle.clearSelection(false);
213
		} catch (ReadDriverException e1) {
214
			e1.printStackTrace();
215
		}
216
		for (int i = 0; i < auxSelectedRows.size(); i++) {
217
			editedRow = (IRowEdited) auxSelectedRows.get(i);
214 218
			IFeature feat = (IFeature) editedRow.getLinkedRow().cloneRow();
215 219
			IGeometry ig = feat.getGeometry();
216 220
			Geometry jtsGeo = FConverter.java2d_to_jts((FShape)ig.getInternalShape());
......
223 227

  
224 228
				//Saving originals polygons index
225 229
				indices.add(new Integer(editedRow.getIndex()));
226
//				try {
227
//					vle.clearSelection(false);
228
//				} catch (ReadDriverException e) {
229
//					PluginServices.getLogger().error("Error clearing selection", e);
230
//				}
231 230
				//and then, we add new features for each split geometry
232 231
				GeometryCollection gc = (GeometryCollection)splitGeo;
233 232
				for(int j = 0; j < gc.getNumGeometries(); j++){
......
238 237
					if (j==0){
239 238
						newIdx=editedRow.getIndex();
240 239
						try {
241
							String newFID = vea.getNewFID();
242 240
							df = new DefaultFeature(fmapGeo, feat.getAttributes(),feat.getID());
243 241
							vea.modifyRow(newIdx, df, getName(),
244 242
									EditionEvent.GRAPHIC);
......
249 247
						} catch (ReadDriverException e) {
250 248
							NotificationManager.addError(e.getMessage(),e);
251 249
						}
252
//						CADUtil.modifyFeature(vle, newIdx ,getName(), df);
253 250
					}else{
254 251

  
255 252
						try {
......
268 265
						} catch (ReadDriverException e) {
269 266
							NotificationManager.addError(e);
270 267
						}
271

  
272

  
273

  
274
//						newIdx = CADUtil.addFeature(vle, df, getName());
275 268
					}
276 269
					DefaultRowEdited newRowEdited = new DefaultRowEdited(df,
277 270
								IRowEdited.STATUS_ADDED,
278 271
									newIdx);
279
//					splitSelectionGeoms.add(newRowEdited);
280 272
					vle.addSelectionCache(newRowEdited);
281 273
				}//for j
282 274
			}//if splitGeo
......
284 276
				PluginServices.getLogger().error("Error splitting geom "+editedRow.getIndex(), ex);
285 277
			}
286 278
		}
287

  
288
		// Vector index ordered highest to lowest
289
//		Collections.sort(indices, Collections.reverseOrder());
290
//		// Clear polygon erasing their lines in the table
291
//		for(int i = 0; i< indices.size();i++) {
292
//
293
//			try {
294
//				vea.removeRow(((Integer)indices.get(i)).intValue(),
295
//						PluginServices.getText(this,"deleted_feature"),
296
//						EditionEvent.GRAPHIC);
297
//			} catch (ExpansionFileReadException e) {
298
//				logger.error("Error ExpansionFileReadException en la funcion split");
299
//			} catch (ReadDriverException e) {
300
//				logger.error("Error ReadDriverException en la funcion split");
301
//			}
302
//		}
303 279
		vea.endComplexRow(getName());
304 280

  
305 281
		getCadToolAdapter().getMapControl().getMapContext().endAtomicEvent();

Also available in: Unified diff