diff --git a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java index c6c6147f230..c4dd5ed1b55 100644 --- a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java +++ b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java @@ -55,7 +55,7 @@ public class AdvancedSearch { return FModel.getFormats().getAllFormatsOfCard(input); } }), - CARD_COLOR("Color", PaperCard.class, FilterOperator.MULTI_LIST_OPS, new CustomListEvaluator(Arrays.asList(MagicColor.Color.values()), MagicColor.FN_GET_SYMBOL) { + CARD_COLOR("Color", PaperCard.class, FilterOperator.MULTI_LIST_OPS, new ColorEvaluator() { @Override protected MagicColor.Color getItemValue(PaperCard input) { throw new RuntimeException("getItemValues should be called instead"); @@ -65,7 +65,7 @@ public class AdvancedSearch { return input.getRules().getColor().toEnumSet(); } }), - CARD_COLOR_IDENTITY("Color Identity", PaperCard.class, FilterOperator.MULTI_LIST_OPS, new CustomListEvaluator(Arrays.asList(MagicColor.Color.values()), MagicColor.FN_GET_SYMBOL) { + CARD_COLOR_IDENTITY("Color Identity", PaperCard.class, FilterOperator.MULTI_LIST_OPS, new ColorEvaluator() { @Override protected MagicColor.Color getItemValue(PaperCard input) { throw new RuntimeException("getItemValues should be called instead"); @@ -568,7 +568,7 @@ public class AdvancedSearch { return String.format(operator.formatStr, option.name, valuesStr); } - private String formatValues(List values, String delim, String finalDelim) { + protected String formatValues(List values, String delim, String finalDelim) { int valueCount = values.size(); switch (valueCount) { case 1: @@ -586,7 +586,7 @@ public class AdvancedSearch { } } - private String formatValue(V value) { + protected String formatValue(V value) { if (toShortString == null) { return value.toString(); } @@ -594,6 +594,21 @@ public class AdvancedSearch { } } + private static abstract class ColorEvaluator extends CustomListEvaluator { + public ColorEvaluator() { + super(Arrays.asList(MagicColor.Color.values()), MagicColor.FN_GET_SYMBOL); + } + + @Override + protected String getCaption(List values, FilterOption option, FilterOperator operator) { + if (operator == FilterOperator.IS_EXACTLY) { + //handle special case for formatting colors with no spaces in between for is exactly operator + return String.format(operator.formatStr, option.name, formatValues(values, "", "")); + } + return super.getCaption(values, option, operator); + } + } + @SuppressWarnings("unchecked") public static Filter getFilter(Class type, Filter editFilter) { //build list of filter options based on ItemManager type