Check if groups have already been added or not
authoramwaterhouse <Andrew Waterhouse>
Wed, 9 Aug 2006 15:56:32 +0000 (15:56 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 9 Aug 2006 15:56:32 +0000 (15:56 +0000)
src/jalview/gui/FeatureSettings.java

index b83a004..314c357 100755 (executable)
@@ -74,7 +74,6 @@ public class FeatureSettings extends JPanel
     if (af.getViewport().featuresDisplayed == null || fr.renderOrder==null)\r
        fr.findAllFeatures();\r
 \r
-\r
     setTableData();\r
 \r
     frame = new JInternalFrame();\r
@@ -83,7 +82,7 @@ public class FeatureSettings extends JPanel
     frame.setLayer(JLayeredPane.PALETTE_LAYER);\r
   }\r
 \r
-  public void setTableData()\r
+  synchronized public void setTableData()\r
   {\r
     alignmentHasFeatures = false;\r
 \r
@@ -125,14 +124,28 @@ public class FeatureSettings extends JPanel
              {\r
                visible = ( (Boolean) fr.featureGroups.get(group)).booleanValue();\r
              }\r
-             else\r
-             {\r
-               fr.featureGroups.put(group, new Boolean(visible));\r
+\r
                if (groupPanel == null)\r
                {\r
                  groupPanel = new JPanel();\r
                }\r
 \r
+               boolean alreadyAdded = false;\r
+               for(int g=0; g<groupPanel.getComponentCount(); g++)\r
+               {\r
+                 if(((JCheckBox)groupPanel.getComponent(g))\r
+                    .getText().equals(group))\r
+                 {\r
+                   alreadyAdded = true;\r
+                   break;\r
+                 }\r
+               }\r
+\r
+               if(alreadyAdded)\r
+                 continue;\r
+\r
+               fr.featureGroups.put(group, new Boolean(visible));\r
+\r
                final JCheckBox check = new JCheckBox(group, visible);\r
                check.setFont(new Font("Serif", Font.BOLD, 12));\r
                check.addItemListener(new ItemListener()\r
@@ -150,8 +163,6 @@ public class FeatureSettings extends JPanel
                });\r
                groupPanel.add(check);\r
              }\r
-           }\r
-\r
        }\r
 \r
        if (!allFeatures.contains(tmpfeatures[index].getType()))\r