diff --git a/vassal-app/src/main/java/VASSAL/build/module/properties/ChangePropertyButton.java b/vassal-app/src/main/java/VASSAL/build/module/properties/ChangePropertyButton.java index 9e4ca9aeb7..a21855a952 100644 --- a/vassal-app/src/main/java/VASSAL/build/module/properties/ChangePropertyButton.java +++ b/vassal-app/src/main/java/VASSAL/build/module/properties/ChangePropertyButton.java @@ -36,9 +36,9 @@ import java.awt.Component; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; - -import org.apache.commons.lang3.ArrayUtils; +import java.util.stream.Stream; /** * Adds a toolbar button that changes the value of a global property @@ -51,6 +51,7 @@ public class ChangePropertyButton extends AbstractToolbarItem implements Propert public static final String BUTTON_TOOLTIP = "tooltip"; //NON-NLS public static final String BUTTON_ICON = "icon"; //NON-NLS public static final String HOTKEY = "hotkey"; //NON-NLS + public static final String DESCRIPTION = "desc"; //NON-NLS public static final String PROPERTY_CHANGER = "propChanger"; //NON-NLS @@ -67,6 +68,7 @@ public class ChangePropertyButton extends AbstractToolbarItem implements Propert protected GlobalProperty property; protected PropertyChangerConfigurer propChangeConfig = new PropertyChangerConfigurer(null, null, this); protected FormattedString format = new FormattedString(); + protected String desc = ""; public ChangePropertyButton() { setNameKey(""); @@ -111,29 +113,27 @@ public PropertyChanger getPropertyChanger() { @Override public String[] getAttributeDescriptions() { - return ArrayUtils.addAll( - super.getAttributeDescriptions(), - Resources.getString("Editor.report_format"), - Resources.getString("Editor.ChangePropertyButton.options") - ); + final Stream.Builder b = Stream.builder().add(Resources.getString("Editor.description_label")); + Arrays.stream(super.getAttributeDescriptions()).forEach(b::add); + b.add(Resources.getString("Editor.report_format")) + .add(Resources.getString("Editor.ChangePropertyButton.options")); + return b.build().toArray(String[]::new); } @Override public Class[] getAttributeTypes() { - return ArrayUtils.addAll( - super.getAttributeTypes(), - ReportFormatConfig.class, - PropChangerOptions.class - ); + final Stream.Builder b = Stream.builder().add(String.class); + Arrays.stream(super.getAttributeTypes()).forEach(b::add); + b.add(ReportFormatConfig.class).add(PropChangerOptions.class); + return b.build().toArray(Class[]::new); } @Override public String[] getAttributeNames() { - return ArrayUtils.addAll( - super.getAttributeNames(), - REPORT_FORMAT, - PROPERTY_CHANGER - ); + final Stream.Builder b = Stream.builder().add(DESCRIPTION); + Arrays.stream(super.getAttributeNames()).forEach(b::add); + b.add(REPORT_FORMAT).add(PROPERTY_CHANGER); + return b.build().toArray(String[]::new); } @Override @@ -157,7 +157,10 @@ public Configurer getConfigurer(AutoConfigurable c, String key, String name) { @Override public void setAttribute(String key, Object value) { - if (PROPERTY_CHANGER.equals(key)) { + if (DESCRIPTION.equals(key)) { + desc = (String) value; + } + else if (PROPERTY_CHANGER.equals(key)) { if (value instanceof String) { propChangeConfig.setValue((String)value); } @@ -178,7 +181,10 @@ else if (REPORT_FORMAT.equals(key)) { @Override public String getAttributeValueString(String key) { - if (PROPERTY_CHANGER.equals(key)) { + if (DESCRIPTION.equals(key)) { + return desc; + } + else if (PROPERTY_CHANGER.equals(key)) { return propChangeConfig.getValueString(); } else if (REPORT_FORMAT.equals(key)) { diff --git a/vassal-app/src/main/java/VASSAL/configure/ConfigureTree.java b/vassal-app/src/main/java/VASSAL/configure/ConfigureTree.java index 59d56744e7..a3c5e2bde5 100644 --- a/vassal-app/src/main/java/VASSAL/configure/ConfigureTree.java +++ b/vassal-app/src/main/java/VASSAL/configure/ConfigureTree.java @@ -41,6 +41,7 @@ import VASSAL.build.module.map.MassKeyCommand; import VASSAL.build.module.map.SetupStack; import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; +import VASSAL.build.module.properties.ChangePropertyButton; import VASSAL.build.module.properties.GlobalProperties; import VASSAL.build.module.properties.GlobalProperty; import VASSAL.build.module.properties.GlobalTranslatableMessage; @@ -2654,6 +2655,14 @@ public String toString() { } } } + + if (c instanceof ChangePropertyButton) { + final ChangePropertyButton cpb = (ChangePropertyButton)c; + final String desc = cpb.getAttributeValueString(ChangePropertyButton.DESCRIPTION); + if ((desc != null) && !desc.isEmpty()) { + description += " - " + desc; + } + } } return description; }