Merge branch 'bug/Jal-1696_disable-pdb_id-field-settings' into Release_2_8_3_Branch
[jalview.git] / src / jalview / jbgui / PDBDocFieldPreferences.java
index 90abbfb..96e27e6 100644 (file)
@@ -171,10 +171,32 @@ public class PDBDocFieldPreferences extends JScrollPane
     {
       // Note that the data/cell address is constant,
       // no matter where the cell appears onscreen.
-      return col == 1 || col == 2;
+      // !isPDBID(row, col) ensures the PDB_Id cell is never editable as it
+      // serves as a unique id for each row.
+      return (col == 1 || col == 2) && !isPDBID(row, col);
 
     }
 
+    /**
+     * Determines whether the data in a given cell is a PDB ID.
+     * 
+     * @param row
+     * @param col
+     * @return
+     */
+
+    public boolean isPDBID(int row, int col)
+    {
+      boolean matched = false;
+      String name = getValueAt(row, 0).toString();
+      PDBDocField pdbField = map.get(name);
+      if (pdbField == PDBDocField.PDB_ID)
+      {
+        matched = true;
+      }
+      return matched;
+    }
+
     /*
      * Don't need to implement this method unless your table's data can change.
      */