Revision 20500 trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/Feature.java

View differences:

Feature.java
10 10
	protected Object object;
11 11
	private boolean editing = false;
12 12
	private boolean loading = false;
13
	private IFeature oldFeature;
13
	private IFeature newFeature;
14 14

  
15 15
	protected IFeature cloneFeature() throws IsNotFeatureSettingException {
16 16
		MemoryFeature mfeature=new MemoryFeature(featureType,false);
......
182 182
	public void set(String name, Object value) throws IsNotFeatureSettingException {
183 183
		int i=featureType.getFieldIndex(name);
184 184
		canSetValue(i);
185
		super.set(i,value);
185
		if (newFeature!=null){
186
			((Feature)newFeature).loading();
187
			newFeature.set(i,value);
188
			((Feature)newFeature).stopLoading();
189
		}else
190
			super.set(i,value);
191

  
186 192
	}
187 193

  
188 194
	public void set(String name, int value) throws IsNotFeatureSettingException {
189 195
		int i=featureType.getFieldIndex(name);
190 196
		canSetValue(i);
191
		super.set(i,new Integer(value));
197
		if (newFeature!=null){
198
			((Feature)newFeature).loading();
199
			newFeature.set(i,value);
200
			((Feature)newFeature).stopLoading();
201
		}else
202
			super.set(i,new Integer(value));
192 203
	}
193 204

  
194 205
	public void set(String name, boolean value) throws IsNotFeatureSettingException {
195 206
		int i=featureType.getFieldIndex(name);
196 207
		canSetValue(i);
197
		super.set(i,new Boolean(value));
208
		if (newFeature!=null){
209
			((Feature)newFeature).loading();
210
			newFeature.set(i,value);
211
			((Feature)newFeature).stopLoading();
212
		}else
213
			super.set(i,new Boolean(value));
198 214
	}
199 215

  
200 216
	public void set(String name, long value) throws IsNotFeatureSettingException {
201 217
		int i=featureType.getFieldIndex(name);
202 218
		canSetValue(i);
203
		super.set(i,new Long(value));
219
		if (newFeature!=null){
220
			((Feature)newFeature).loading();
221
			newFeature.set(i,value);
222
			((Feature)newFeature).stopLoading();
223
		}else
224
			super.set(i,new Long(value));
204 225
	}
205 226

  
206 227
	public void set(String name, float value) throws IsNotFeatureSettingException {
207 228
		int i=featureType.getFieldIndex(name);
208 229
		canSetValue(i);
209
		super.set(i,new Float(value));
230
		if (newFeature!=null){
231
			((Feature)newFeature).loading();
232
			newFeature.set(i,value);
233
			((Feature)newFeature).stopLoading();
234
		}else
235
			super.set(i,new Float(value));
210 236
	}
211 237

  
212 238
	public void set(String name, double value) throws IsNotFeatureSettingException {
213 239
		int i=featureType.getFieldIndex(name);
214 240
		canSetValue(i);
215
		super.set(i,new Double(value));
241
		if (newFeature!=null){
242
			((Feature)newFeature).loading();
243
			newFeature.set(i,value);
244
			((Feature)newFeature).stopLoading();
245
		}else
246
			super.set(i,new Double(value));
216 247
	}
217 248

  
218 249
	public void setObject(int index, Object value) throws IsNotFeatureSettingException {
219 250
		canSetValue(index);
220
		super.set(index,value);
251
		if (newFeature!=null){
252
			((Feature)newFeature).loading();
253
			newFeature.set(index,value);
254
			((Feature)newFeature).stopLoading();
255
		}else
256
			super.set(index,value);
221 257
	}
222 258

  
223 259
	public void set(int index, int value) throws IsNotFeatureSettingException {
224 260
		canSetValue(index);
225
		super.set(index,new Integer(value));
261
		if (newFeature!=null){
262
			((Feature)newFeature).loading();
263
			newFeature.set(index,value);
264
			((Feature)newFeature).stopLoading();
265
		}else
266
			super.set(index,new Integer(value));
226 267
	}
227 268

  
228 269
	public void set(int index, boolean value) throws IsNotFeatureSettingException {
229 270
		canSetValue(index);
230
		super.set(index,new Boolean(value));
271
		if (newFeature!=null){
272
			((Feature)newFeature).loading();
273
			newFeature.set(index,value);
274
			((Feature)newFeature).stopLoading();
275
		}else
276
			super.set(index,new Boolean(value));
231 277
	}
232 278

  
233 279
	public void set(int index, long value) throws IsNotFeatureSettingException {
234 280
		canSetValue(index);
235
		super.set(index,new Long(value));
281
		if (newFeature!=null){
282
			((Feature)newFeature).loading();
283
			newFeature.set(index,value);
284
			((Feature)newFeature).stopLoading();
285
		}else
286
			super.set(index,new Long(value));
236 287
	}
237 288

  
238 289
	public void set(int index, float value) throws IsNotFeatureSettingException {
239 290
		canSetValue(index);
240
		super.set(index,new Float(value));
291
		if (newFeature!=null){
292
			((Feature)newFeature).loading();
293
			newFeature.set(index,value);
294
			((Feature)newFeature).stopLoading();
295
		}else
296
			super.set(index,new Float(value));
241 297
	}
242 298

  
243 299
	public void set(int index, double value) throws IsNotFeatureSettingException {
244 300
		canSetValue(index);
245
		super.set(index,new Double(value));
301
		if (newFeature!=null){
302
			((Feature)newFeature).loading();
303
			newFeature.set(index,value);
304
			((Feature)newFeature).stopLoading();
305
		}else
306
			super.set(index,new Double(value));
246 307
	}
247 308

  
248 309
	public void validateEnd(IFeatureStore featureStore) {
......
283 344
	}
284 345
	public void set(int index, byte value) throws IsNotFeatureSettingException {
285 346
		canSetValue(index);
286
		super.set(index,new Byte(value));
347
		if (newFeature!=null){
348
			((Feature)newFeature).loading();
349
			newFeature.set(index,value);
350
			((Feature)newFeature).stopLoading();
351
		}else
352
			super.set(index,new Byte(value));
287 353
	}
288 354
	public void set(int index, String value) throws IsNotFeatureSettingException {
289 355
		canSetValue(index);
290
		super.set(index,value);
356
		if (newFeature!=null){
357
			((Feature)newFeature).loading();
358
			newFeature.set(index,value);
359
			((Feature)newFeature).stopLoading();
360
		}else
361
			super.set(index,value);
291 362
	}
292 363
	public void set(String name, byte value) throws IsNotFeatureSettingException {
293 364
		int i=featureType.getFieldIndex(name);
294 365
		canSetValue(i);
295
		set(i,new Byte(value));
366
		if (newFeature!=null){
367
			((Feature)newFeature).loading();
368
			newFeature.set(i,value);
369
			((Feature)newFeature).stopLoading();
370
		}else
371
			set(i,new Byte(value));
296 372
	}
297 373
	public void setGeometry(String name,Object geometry) throws IsNotFeatureSettingException {
298 374
		int i=featureType.getFieldIndex(name);
299 375
		canSetValue(i);
300
		set(i,geometry);
301
		if (featureType.getDefaultGeometry().equals(name)){
302
			defaultGeometry=geometry;
376
		if (newFeature!=null){
377
			((Feature)newFeature).loading();
378
			newFeature.set(i,geometry);
379
			((Feature)newFeature).stopLoading();
380
		}else{
381
			set(i,geometry);
382
			if (featureType.getDefaultGeometry().equals(name)){
383
				defaultGeometry=geometry;
384
			}
303 385
		}
304 386
	}
305 387
	public void setGeometry(int index,Object geometry) throws IsNotFeatureSettingException {
306 388
		canSetValue(index);
307
		super.set(index,geometry);
308
		Iterator iterator=featureType.iterator();
309
		while (iterator.hasNext()) {
310
			IFeatureAttributeDescriptor fad = (IFeatureAttributeDescriptor) iterator.next();
311
			if (fad.ordinal()==index && fad.getName().equals(featureType.getDefaultGeometry())){
312
				defaultGeometry=geometry;
389
		if (newFeature!=null){
390
			((Feature)newFeature).loading();
391
			newFeature.set(index,geometry);
392
			((Feature)newFeature).stopLoading();
393
		}else{
394
			super.set(index,geometry);
395
			Iterator iterator=featureType.iterator();
396
			while (iterator.hasNext()) {
397
				IFeatureAttributeDescriptor fad = (IFeatureAttributeDescriptor) iterator.next();
398
				if (fad.ordinal()==index && fad.getName().equals(featureType.getDefaultGeometry())){
399
					defaultGeometry=geometry;
400
				}
313 401
			}
314 402
		}
315 403
	}
......
325 413
	}
326 414
	public void cancelEditing() {
327 415
		editing=false;
328
		oldFeature=null;
416
		newFeature=null;
329 417
	}
330 418
	public void editing() throws IsNotFeatureSettingException {
331 419
		editing=true;
332
		oldFeature=this.cloneFeature();
420
		newFeature=this.cloneFeature();
333 421
	}
334
	public IFeature getOldFeature() {
335
		return oldFeature;
422
	public IFeature getNewFeature() {
423
		return newFeature;
336 424
	}
337 425
	protected void loading(){
338 426
		loading=true;
......
342 430
	}
343 431
	protected void stopEditing(){
344 432
		editing=false;
433
		newFeature=null;
345 434
	}
346 435
	protected void refreshEvaluatedFields(IFeatureStore store){
347 436
		Iterator iter = this.featureType.iterator();

Also available in: Unified diff