Changeset 4635 in josm


Ignore:
Timestamp:
2011-12-04T20:00:58+01:00 (13 years ago)
Author:
bastiK
Message:

status report should use new xml preference file (see #7027)

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

Legend:

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

    r4380 r4635  
    88import java.awt.event.ActionEvent;
    99import java.awt.event.KeyEvent;
    10 import java.io.BufferedReader;
    11 import java.io.File;
    12 import java.io.FileReader;
     10import java.util.HashSet;
     11import java.util.Map;
     12import java.util.Map.Entry;
     13import java.util.Set;
    1314
    1415import javax.swing.JScrollPane;
     
    1617
    1718import org.openstreetmap.josm.Main;
     19import org.openstreetmap.josm.data.Preferences.Setting;
    1820import org.openstreetmap.josm.data.Version;
    1921import org.openstreetmap.josm.data.osm.DataSet;
     
    2325import org.openstreetmap.josm.tools.Shortcut;
    2426import org.openstreetmap.josm.tools.Utils;
     27
    2528
    2629/**
     
    8386        text.append(getReportHeader());
    8487        try {
    85             BufferedReader input = new BufferedReader(new FileReader(Main.pref
    86                     .getPreferencesDirFile()
    87                     + File.separator + "preferences"));
    88             try {
    89                 String line = null;
    90 
    91                 while ((line = input.readLine()) != null) {
    92                     String toCheck = line.trim().toLowerCase();
    93                     if (toCheck.startsWith("osm-server.username")
    94                             || toCheck.startsWith("osm-server.password")
    95                             || toCheck.startsWith("marker.show")
    96                             || toCheck.startsWith("oauth.access-token.key")
    97                             || toCheck.startsWith("oauth.access-token.secret")) {
    98                         continue;
    99                     }
    100                     text.append(line);
    101                     text.append("\n");
     88            Map<String, Setting> settings = Main.pref.getAllSettings();
     89            settings.remove("osm-server.username");
     90            settings.remove("osm-server.password");
     91            settings.remove("oauth.access-token.key");
     92            settings.remove("oauth.access-token.secret");
     93            Set<String> keys = new HashSet<String>(settings.keySet());
     94            for (String key : keys) {
     95                if (key.startsWith("marker.show")) {
     96                    settings.remove(key);
    10297                }
    103             } finally {
    104                 input.close();
     98            }
     99            for (Entry<String, Setting> entry : settings.entrySet()) {
     100                text.append(entry.getKey()).append("=").append(entry.getValue().getValue().toString()).append("\n");
    105101            }
    106102        } catch (Exception x) {
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r4634 r4635  
    6161 * saved upon set-access.
    6262 *
    63  * Each property is a simple key=value pair of Strings.
     63 * Each property is a key=setting pair, where key is a String and setting can be one of
     64 * 4 types:
     65 *     string, list, list of lists and list of maps.
    6466 * In addition, each key has a unique default value that is set when the value is first
    6567 * accessed using one of the get...() methods. You can use the same preference
     
    6971 * off all possible settings.
    7072 *
    71  * At the moment, there is no such thing as an empty value.
    72  * If you put "" or null as value, the property is removed.
     73 * At the moment, you cannot put the empty string for string properties.
     74 * put(key, "") means, the property is removed.
    7375 *
    7476 * @author imi
     
    8385
    8486    /**
    85      * Map the property name to the property object. Does not contain null or "" values.
     87     * Map the property name to strings. Does not contain null or "" values.
    8688     */
    8789    protected final SortedMap<String, String> properties = new TreeMap<String, String>();
     90    /** Map of defaults, can contain null values */
    8891    protected final SortedMap<String, String> defaults = new TreeMap<String, String>();
    8992    protected final SortedMap<String, String> colornames = new TreeMap<String, String>();
    9093
     94    /** Mapping for list settings. Must not conatin null values */
    9195    protected final SortedMap<String, List<String>> collectionProperties = new TreeMap<String, List<String>>();
     96    /** Defaults, can contain null values */
    9297    protected final SortedMap<String, List<String>> collectionDefaults = new TreeMap<String, List<String>>();
    9398
Note: See TracChangeset for help on using the changeset viewer.