Index: DefaultFeatureTypePanel.java
===================================================================
--- DefaultFeatureTypePanel.java	(revision 44148)
+++ DefaultFeatureTypePanel.java	(revision 44149)
@@ -8,10 +8,13 @@
 import java.util.Date;
 import java.util.Objects;
 import javax.swing.JComponent;
+import javax.swing.JOptionPane;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
 import javax.swing.event.TableModelEvent;
 import javax.swing.table.AbstractTableModel;
+import org.apache.commons.lang3.StringUtils;
+import org.gvsig.fmap.dal.expressionevaluator.FeatureAttributeEmulatorExpression;
 import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.EditableFeatureType;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
@@ -22,6 +25,8 @@
 import org.gvsig.tools.i18n.I18nManager;
 import org.gvsig.tools.swing.api.ToolsSwingLocator;
 import org.gvsig.tools.swing.api.ToolsSwingManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  *
@@ -32,6 +37,8 @@
         implements FeatureTypePanel
     {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(DefaultFeatureTypePanel.class);
+    
     private class FeatureTypeTableModel extends AbstractTableModel {
 
         private final FeatureType featureType;
@@ -135,9 +142,13 @@
     private boolean editable;
     private FeatureTypeTableModel tableModel;
     private FeatureStore store;
+    private int currentRow;
+    private boolean fieldSelectionAllowed;
         
     public DefaultFeatureTypePanel() {
         this.editable = true;
+        this.currentRow = -1;
+        this.fieldSelectionAllowed = true;
         this.initComponents();
     }
 
@@ -158,9 +169,7 @@
                 if( e.getValueIsAdjusting() ) {
                     return;
                 }
-                if( !btnFormFieldAccept.isEnabled() ) {
-                    doFormFieldPut();
-                }
+                doChangeFieldSelection();
             }
         });
         this.descriptorPanel = new DefaultFeatureTypeAttributePanel();
@@ -177,13 +186,13 @@
         this.btnFormFieldDiscard.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
-                doFormFieldPut();
+                doFormFieldDiscard();
             }
         });
         this.btnFormFieldAccept.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
-                doFormFieldFetch();
+                doFormFieldAccept();
             }
         });
         this.btnNew.addActionListener(new ActionListener() {
@@ -224,11 +233,9 @@
             return;
         }
         FeatureAttributeDescriptor descriptor = this.featureType.getAttributeDescriptor(row);
+        this.currentRow = row;
         this.descriptorPanel.put(descriptor);
-        this.descriptorPanel.setEnabled(true);
-        this.descriptorPanel.setEditable(false);
-        this.btnFormFieldAccept.setEnabled(false);
-        this.btnFormFieldDiscard.setEnabled(false);
+        updateButtonState();
         if( descriptor instanceof EditableFeatureAttributeDescriptor ) {
             this.btnFormFieldModify.setEnabled(this.editable);
         } else {
@@ -236,6 +243,14 @@
         }
     }
     
+    private void updateButtonState() {
+        this.descriptorPanel.setEnabled(true);
+        this.descriptorPanel.setEditable(false);
+        this.btnFormFieldAccept.setEnabled(false);
+        this.btnFormFieldDiscard.setEnabled(false);
+        this.btnFormFieldModify.setEnabled(this.editable);
+    }
+    
     private void doFormFieldModify() {
         int row = this.tblFields.getSelectedRow();
         if( row<0 ) {
@@ -252,8 +267,45 @@
         } else {
             this.descriptorPanel.setEditable(false);
         }
+        this.fieldSelectionAllowed = false;
     }
     
+    private void doFormFieldAccept() {
+        doFormFieldFetch();
+        this.updateButtonState();
+        this.fieldSelectionAllowed = true;
+    }
+    
+    private void doFormFieldDiscard() {
+        doFormFieldPut();
+        this.updateButtonState();
+        this.fieldSelectionAllowed = true;
+    }
+
+    private void doChangeFieldSelection() {
+        int row = this.tblFields.getSelectedRow();
+        if( row<0 ) {
+            return;
+        }
+        if( !this.fieldSelectionAllowed ) {
+            if( row !=this.currentRow ) {
+                I18nManager i18n = ToolsLocator.getI18nManager();
+                JOptionPane.showMessageDialog(
+                    this, 
+                    i18n.getTranslation("_Before_changing_field_accept_or_discard_the_changes"), 
+                    i18n.getTranslation("_Warning"), 
+                    JOptionPane.WARNING_MESSAGE
+                );
+                this.tblFields.getSelectionModel().setSelectionInterval(
+                        this.currentRow, 
+                        this.currentRow
+                );
+            }
+            return;
+        }
+        doFormFieldPut();   
+    }
+    
     @Override
     public JComponent asJComponent() {
         return this;
@@ -261,12 +313,9 @@
 
     public void setEditable(boolean editable) {
         this.editable = editable;
-        this.btnFormFieldModify.setEnabled(editable);
-        this.btnFormFieldAccept.setEnabled(editable);
-        this.btnFormFieldDiscard.setEnabled(editable);
         this.btnNew.setEnabled(editable);
         this.btnDelete.setEnabled(editable);
-        this.descriptorPanel.setEnabled(editable);
+        updateButtonState();
     }
 
     @Override
@@ -281,7 +330,7 @@
             this.store = null;
         } else {
             // Nos quedamos una referencia para evitar que se destruya, ya que
-            // el featureTyper se guarda solo una WeakReference.
+            // el featureType se guarda solo una WeakReference.
             this.store = type.getStore(); 
         }
         if( !(type instanceof EditableFeatureType) ) {
@@ -289,9 +338,11 @@
         }
         this.tableModel = new FeatureTypeTableModel(type);
         this.tblFields.setModel(this.tableModel);
-        if( type.size()>0 ) {
+        if( type!=null && !type.isEmpty() ) {
             this.tblFields.getSelectionModel().setSelectionInterval(0, 0);
         }
+        updateButtonState();
+        doFormFieldPut();       
     }
 
     private void doNewField() {
@@ -303,6 +354,8 @@
         this.tableModel.fireUpdateEvent();
         int row = descriptor.getIndex();
         this.tblFields.getSelectionModel().addSelectionInterval(row,row);
+        updateButtonState();
+        doFormFieldPut();       
     }
     
     private void doDeleteField() {
@@ -310,13 +363,15 @@
         if( row<0 ) {
             return;
         }
-        FeatureAttributeDescriptor descriptor = this.featureType.getAttributeDescriptor(row);
+//        FeatureAttributeDescriptor descriptor = this.featureType.getAttributeDescriptor(row);
         ((EditableFeatureType)this.featureType).remove(row);
         this.tableModel.fireUpdateEvent();
         if( row >= this.tblFields.getRowCount()) {
             row = this.tblFields.getRowCount()-1;
         }
         this.tblFields.getSelectionModel().addSelectionInterval(row,row);
+        updateButtonState();
+        doFormFieldPut();       
     }
             
     public static String getNewFieldName(FeatureType featureType) {
