X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fjbgui%2FPDBDocFieldPreferences.java;h=8c3aab62f4a31fee2c4e972aa8b8515166fef6f6;hb=17e77c3f2949a0729322b4a8d907f3f34b6a9914;hp=2021d0b6a27db5cbca15bcfcd41e0e464e514e0a;hpb=5dc62d509b6d0f90f3545bf40b272390410eda45;p=jalview.git
diff --git a/src/jalview/jbgui/PDBDocFieldPreferences.java b/src/jalview/jbgui/PDBDocFieldPreferences.java
index 2021d0b..8c3aab6 100644
--- a/src/jalview/jbgui/PDBDocFieldPreferences.java
+++ b/src/jalview/jbgui/PDBDocFieldPreferences.java
@@ -1,10 +1,30 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
+ * Copyright (C) 2015 The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.jbgui;
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 +40,9 @@ public class PDBDocFieldPreferences extends JScrollPane
private HashMap map = new HashMap();
- private static Collection searchSummaryFields = new HashSet();
+ private static Collection searchSummaryFields = new LinkedHashSet();
- private static Collection structureSummaryFields = new HashSet();
+ private static Collection structureSummaryFields = new LinkedHashSet();
public enum PreferenceSource
{
@@ -50,16 +70,14 @@ public class PDBDocFieldPreferences extends JScrollPane
switch (source)
{
case SEARCH_SUMMARY:
- columnNames = new String[]
- { "PDB Feild", "Show in search summary" };
+ columnNames = new String[] { "PDB Field", "Show in search summary" };
break;
case STRUCTURE_CHOOSER:
- columnNames = new String[]
- { "PDB Feild", "Show in structure summary" };
+ columnNames = new String[] { "PDB Field", "Show in structure summary" };
break;
case PREFERENCES:
- columnNames = new String[]
- { "PDB Feild", "Show in search summary", "Show in structure summary" };
+ columnNames = new String[] { "PDB Field", "Show in search summary",
+ "Show in structure summary" };
break;
default:
break;
@@ -77,16 +95,16 @@ public class PDBDocFieldPreferences extends JScrollPane
switch (source)
{
case SEARCH_SUMMARY:
- data[x++] = new Object[]
- { field.getName(), searchSummaryFields.contains(field) };
+ data[x++] = new Object[] { field.getName(),
+ searchSummaryFields.contains(field) };
break;
case STRUCTURE_CHOOSER:
- data[x++] = new Object[]
- { field.getName(), structureSummaryFields.contains(field) };
+ data[x++] = new Object[] { field.getName(),
+ structureSummaryFields.contains(field) };
break;
case PREFERENCES:
- data[x++] = new Object[]
- { field.getName(), searchSummaryFields.contains(field),
+ data[x++] = new Object[] { field.getName(),
+ searchSummaryFields.contains(field),
structureSummaryFields.contains(field) };
break;
default:
@@ -171,8 +189,30 @@ 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;
}
/*
@@ -210,8 +250,7 @@ public class PDBDocFieldPreferences extends JScrollPane
}
private void updatePrefs(Collection prefConfig,
- PDBDocField pdbField,
- boolean selected)
+ PDBDocField pdbField, boolean selected)
{
if (prefConfig.contains(pdbField) && !selected)
{