JAL-2069 fix minor bugs in variable setting
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 16 Nov 2017 14:23:00 +0000 (14:23 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 16 Nov 2017 14:23:00 +0000 (14:23 +0000)
src/jalview/gui/FeatureColourChooser.java

index da3819c..d3d9e1a 100644 (file)
@@ -263,7 +263,7 @@ public class FeatureColourChooser extends JalviewDialog
         textAttributeCombo.setEnabled(true);
         String[] attributeName = cs.getAttributeName();
         textAttributeCombo
-                .setSelectedItem(String.join(COLON, attributeName));
+                .setSelectedItem(toAttributeDisplayName(attributeName));
       }
       else
       {
@@ -278,7 +278,7 @@ public class FeatureColourChooser extends JalviewDialog
         byAttributeValue.setSelected(true);
         String[] attributeName = cs.getAttributeName();
         valueAttributeCombo
-                .setSelectedItem(String.join(COLON, attributeName));
+                .setSelectedItem(toAttributeDisplayName(attributeName));
         valueAttributeCombo.setEnabled(true);
         updateMinMax();
       }
@@ -393,7 +393,7 @@ public class FeatureColourChooser extends JalviewDialog
     else if (byAttributeValue.isSelected())
     {
       String attName = (String) valueAttributeCombo.getSelectedItem();
-      String[] attNames = attName.split(COLON);
+      String[] attNames = fromAttributeDisplayName(attName);
       minMax = FeatureAttributes.getInstance().getMinMax(type, attNames);
     }
     if (minMax != null)
@@ -740,17 +740,17 @@ public class FeatureColourChooser extends JalviewDialog
     {
       attribute = (String) textAttributeCombo.getSelectedItem();
       textAttributeCombo.setEnabled(true);
-      acg.setAttributeName(attribute.split(COLON));
+      acg.setAttributeName(fromAttributeDisplayName(attribute));
     }
     else if (byAttributeValue.isSelected())
     {
       attribute = (String) valueAttributeCombo.getSelectedItem();
       valueAttributeCombo.setEnabled(true);
-      acg.setAttributeName(attribute.split(COLON));
+      acg.setAttributeName(fromAttributeDisplayName(attribute));
     }
     else
     {
-      acg.setAttributeName((String) null);
+      acg.setAttributeName((String[]) null);
     }
 
     if (!hasThreshold)
@@ -839,6 +839,11 @@ public class FeatureColourChooser extends JalviewDialog
     ap.paintAlignment(updateStructsAndOverview, updateStructsAndOverview);
   }
 
+  private String[] fromAttributeDisplayName(String attribute)
+  {
+    return attribute == null ? null : attribute.split(COLON);
+  }
+
   @Override
   protected void raiseClosed()
   {
@@ -972,7 +977,7 @@ public class FeatureColourChooser extends JalviewDialog
           continue;
         }
       }
-      validAtts.add(String.join(COLON, attName));
+      validAtts.add(toAttributeDisplayName(attName));
       String desc = fa.getDescription(featureType, attName);
       if (desc != null && desc.length() > MAX_TOOLTIP_LENGTH)
       {
@@ -1003,4 +1008,9 @@ public class FeatureColourChooser extends JalviewDialog
     return attCombo;
   }
 
+  private String toAttributeDisplayName(String[] attName)
+  {
+    return attName == null ? "" : String.join(COLON, attName);
+  }
+
 }