Changeset 10696 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2016-08-01T21:17:23+02:00 (8 years ago)
Author:
simon04
Message:

Status report: distinguish +active vs. -inactive style/preset/rule entries

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

    r10463 r10696  
    1919import java.util.Map.Entry;
    2020import java.util.Set;
    21 import java.util.TreeSet;
     21import java.util.stream.Collectors;
    2222
    2323import org.openstreetmap.josm.Main;
     
    2828import org.openstreetmap.josm.gui.ExtendedDialog;
    2929import org.openstreetmap.josm.gui.preferences.SourceEditor;
    30 import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry;
    31 import org.openstreetmap.josm.gui.preferences.SourceEntry;
    3230import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference;
    3331import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference;
     
    3735import org.openstreetmap.josm.tools.PlatformHookUnixoid;
    3836import org.openstreetmap.josm.tools.Shortcut;
     37import org.openstreetmap.josm.tools.Utils;
    3938import org.openstreetmap.josm.tools.bugreport.BugReportSender;
    4039import org.openstreetmap.josm.tools.bugreport.DebugTextDisplay;
     
    153152            }
    154153        }
    155         text.append('\n').append(PluginHandler.getBugReportText()).append('\n');
    156 
     154        text.append("\n");
     155        appendCollection(text, "Plugins", Utils.transform(PluginHandler.getBugReportInformation(), i -> "+ " + i));
    157156        appendCollection(text, "Tagging presets", getCustomUrls(TaggingPresetPreference.PresetPrefHelper.INSTANCE));
    158157        appendCollection(text, "Map paint styles", getCustomUrls(MapPaintPreference.MapPaintPrefHelper.INSTANCE));
    159158        appendCollection(text, "Validator rules", getCustomUrls(ValidatorTagCheckerRulesPreference.RulePrefHelper.INSTANCE));
    160         appendCollection(text, "Last errors/warnings", Main.getLastErrorAndWarnings());
     159        appendCollection(text, "Last errors/warnings", Utils.transform(Main.getLastErrorAndWarnings(), i -> "- " + i));
    161160
    162161        String osmApi = OsmApi.getOsmApi().getServerUrl();
     
    169168
    170169    private static Collection<String> getCustomUrls(SourceEditor.SourcePrefHelper helper) {
    171         Set<String> set = new TreeSet<>();
    172         for (SourceEntry entry : helper.get()) {
    173             set.add(entry.url);
    174         }
    175         for (ExtendedSourceEntry def : helper.getDefault()) {
    176             set.remove(def.url);
    177         }
    178         return set;
     170        final Set<String> defaultUrls = helper.getDefault().stream()
     171                .map(i -> i.url)
     172                .collect(Collectors.toSet());
     173        return helper.get().stream()
     174                .filter(i -> !defaultUrls.contains(i.url))
     175                .map(i -> (i.active ? "+ " : "- ") + i.url)
     176                .collect(Collectors.toList());
    179177    }
    180178
     
    224222    }
    225223
    226     private static <T> void appendCollection(StringBuilder text, String label, Collection<T> col) {
     224    private static void appendCollection(StringBuilder text, String label, Collection<String> col) {
    227225        if (!col.isEmpty()) {
    228             text.append(label+":\n");
    229             for (T o : col) {
    230                 text.append("- ").append(paramCleanup(o.toString())).append('\n');
     226            text.append(label).append(":\n");
     227            for (String o : col) {
     228                text.append(paramCleanup(o)).append('\n');
    231229            }
    232230            text.append('\n');
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r10647 r10696  
    13771377    /**
    13781378     * Returns the list of loaded plugins as a {@code String} to be displayed in status report. Useful for bug reports.
    1379      * @return The list of loaded plugins (one plugin per line)
    1380      */
    1381     public static String getBugReportText() {
    1382         StringBuilder text = new StringBuilder();
    1383         List<String> pl = new LinkedList<>(Main.pref.getCollection("plugins", new LinkedList<String>()));
     1379     * @return The list of loaded plugins
     1380     */
     1381    public static Collection<String> getBugReportInformation() {
     1382        final Collection<String> pl = new TreeSet<>(Main.pref.getCollection("plugins", new LinkedList<>()));
    13841383        for (final PluginProxy pp : pluginList) {
    13851384            PluginInformation pi = pp.getPluginInformation();
     
    13881387                    ? pi.localversion : "unknown") + ')');
    13891388        }
    1390         Collections.sort(pl);
    1391         if (!pl.isEmpty()) {
    1392             text.append("Plugins:\n");
    1393         }
    1394         for (String s : pl) {
    1395             text.append("- ").append(s).append('\n');
    1396         }
    1397         return text.toString();
     1389        return pl;
    13981390    }
    13991391
Note: See TracChangeset for help on using the changeset viewer.