From 548577891458e7e9d8afaf30322c93b20de43310 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 10 Aug 2017 10:10:51 +0100 Subject: [PATCH] JAL-2658 ensure features dropdown entries are unique --- src/jalview/gui/FeatureRenderer.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index 6f6bc02..4d82d7e 100644 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -41,6 +41,7 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; @@ -234,8 +235,9 @@ public class FeatureRenderer extends if (!create && features.size() > 1) { /* - * more than one feature at selected position - add a drop-down - * to choose the feature to amend + * more than one feature at selected position - + * add a drop-down to choose the feature to amend + * space pad text if necessary to make entries distinct */ gridPanel = new JPanel(new GridLayout(4, 1)); JPanel choosePanel = new JPanel(); @@ -243,11 +245,17 @@ public class FeatureRenderer extends .getString("label.select_feature") + ":")); final JComboBox overlaps = new JComboBox(); + List added = new ArrayList<>(); for (SequenceFeature sf : features) { - String text = sf.getType() + "/" + sf.getBegin() + "-" - + sf.getEnd() + " (" + sf.getFeatureGroup() + ")"; + String text = String.format("%s/%d-%d (%s)", sf.getType(), + sf.getBegin(), sf.getEnd(), sf.getFeatureGroup()); + while (added.contains(text)) + { + text += " "; + } overlaps.addItem(text); + added.add(text); } choosePanel.add(overlaps); -- 1.7.10.2