Resolved diffs from 2.8.3
[jalview.git] / src / jalview / jbgui / PDBDocFieldPreferences.java
index 2021d0b..96e27e6 100644 (file)
@@ -4,7 +4,7 @@ import jalview.ws.dbsources.PDBRestClient.PDBDocField;
 
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
 
 import javax.swing.JScrollPane;
 import javax.swing.JTable;
@@ -20,9 +20,9 @@ public class PDBDocFieldPreferences extends JScrollPane
 
   private HashMap<String, PDBDocField> map = new HashMap<String, PDBDocField>();
 
-  private static Collection<PDBDocField> searchSummaryFields = new HashSet<PDBDocField>();
+  private static Collection<PDBDocField> searchSummaryFields = new LinkedHashSet<PDBDocField>();
 
-  private static Collection<PDBDocField> structureSummaryFields = new HashSet<PDBDocField>();
+  private static Collection<PDBDocField> structureSummaryFields = new LinkedHashSet<PDBDocField>();
 
   public enum PreferenceSource
   {
@@ -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.
      */