Revision 39409 branches/v2_0_0_prep/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/TableOperations.java

View differences:

TableOperations.java
285 285
            renameAttribute(featureStore, selecteds[i].getName(), newName);
286 286
        }
287 287
        
288
        featureStore.finishEditing();
288
        // featureStore.finishEditing();
289 289
        // featureStore.edit(FeatureStore.MODE_FULLEDIT);
290 290
    }
291 291

  
......
303 303
     */
304 304
    private static boolean renameAttribute(FeatureStore fs, String name, String newName) {
305 305

  
306
        Component root_comp =
307
            ApplicationLocator.getManager().getRootComponent();
308

  
309 306
        EditableFeatureType eft = null;
310
        
307
        FeatureType dft = null;
311 308
        try {
309
            dft = fs.getDefaultFeatureType();
310
            
311
            if (dft instanceof EditableFeatureType) {
312
                eft = (EditableFeatureType) dft;
313
            } else {
314
                eft = dft.getEditable();
315
            }
316
            
317
            EditableFeatureAttributeDescriptor efad =
318
                (EditableFeatureAttributeDescriptor) eft.getAttributeDescriptor(name);
319
            efad.setName(newName);
320
            fs.update(eft);
321
            
322
        } catch (DataException de) {
323
            
324
            Component root_comp =
325
                ApplicationLocator.getManager().getRootComponent();
326

  
327
            JOptionPane.showMessageDialog(
328
                root_comp,
329
                Messages.getText("_Unable_to_rename_attribute") +
330
                ": " + de.getMessage(),
331
                Messages.getText("_Unable_to_rename_attribute"),
332
                JOptionPane.ERROR_MESSAGE);
333
            return false;
334
        }
335
        return true;
336

  
337
        /*
338
        try {
312 339
            // ========== add new field
313 340
            eft = fs.getDefaultFeatureType().getEditable();
314 341
            FeatureAttributeDescriptor fad = eft.getAttributeDescriptor(name);
......
319 346
            ApplicationLocator.getManager().message(
320 347
                Messages.getText("_Unable_to_rename_attribute"),
321 348
                JOptionPane.ERROR_MESSAGE);
322
            /*
323
             * did not even add new field
324
             */
349
            // did not even add new field
325 350
            return false;
326 351
        }
327 352
        
......
359 384
        
360 385
        if (error_when_inserting) {
361 386
            try {
362
                /*
363
                 * Trying to remove new field and leave
364
                 * table as it was
365
                 */
387
                // Trying to remove new field and leave table as it was
366 388
                eft.remove(newName);
367 389
                fs.update(eft);
368 390
            } catch (DataException ex) {
369
                /*
370
                 * Unable to remove added field but user was
371
                 * already notified that something went wrong
372
                 */
391
                // Unable to remove added field but user was
392
                // already notified that something went wrong
373 393
            }
374
            /*
375
             * not changed
376
             */
394
            // Not changed
377 395
            return false;
378 396
        }
379 397
            
......
393 411
            return false;
394 412
        }
395 413
        return true;
414
        */
396 415

  
397 416
    }
398 417
    
......
428 447
                fs.getName());
429 448
        }
430 449
        renameAttribute(fs, oldname, newname);
431
        fs.finishEditing();
450
        // fs.finishEditing();
432 451
    }
433 452

  
434 453
}

Also available in: Unified diff