From 8fc9f1cacf08e1a4b229cf2709d058a4bcca72a1 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Tue, 14 Apr 2015 14:26:29 +0100 Subject: [PATCH] JAL-1696 disabled editing of PDB Id field from settings --- src/jalview/jbgui/PDBDocFieldPreferences.java | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/jalview/jbgui/PDBDocFieldPreferences.java b/src/jalview/jbgui/PDBDocFieldPreferences.java index 2021d0b..a880c25 100644 --- a/src/jalview/jbgui/PDBDocFieldPreferences.java +++ b/src/jalview/jbgui/PDBDocFieldPreferences.java @@ -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. */ -- 1.7.10.2