Ignore:
Timestamp:
2011-06-24T23:13:02+02:00 (13 years ago)
Author:
stoecker
Message:

fix #4140 - make colors in conflict dialog configurable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r3938 r4162  
    3030import java.util.Map.Entry;
    3131import java.util.concurrent.CopyOnWriteArrayList;
     32import java.util.regex.Matcher;
     33import java.util.regex.Pattern;
    3234
    3335import javax.swing.JOptionPane;
     
    7274    protected final SortedMap<String, String> properties = new TreeMap<String, String>();
    7375    protected final SortedMap<String, String> defaults = new TreeMap<String, String>();
     76    protected final SortedMap<String, String> colornames = new TreeMap<String, String>();
    7477
    7578    public interface PreferenceChangeEvent{
     
    526529    }
    527530
     531    /* only for preferences */
     532    synchronized public String getColorName(String o) {
     533        try
     534        {
     535            Matcher m = Pattern.compile("mappaint\\.(.+?)\\.(.+)").matcher(o);
     536            m.matches();
     537            return tr("Paint style {0}: {1}", tr(m.group(1)), tr(m.group(2)));
     538        }
     539        catch (Exception e) {}
     540        try
     541        {
     542            Matcher m = Pattern.compile("layer (.+)").matcher(o);
     543            m.matches();
     544            return tr("Layer: {0}", tr(m.group(1)));
     545        }
     546        catch (Exception e) {}
     547        return tr(colornames.containsKey(o) ? colornames.get(o) : o);
     548    }
     549
    528550    public Color getColor(ColorKey key) {
    529551        return getColor(key.getColorName(), key.getSpecialName(), key.getDefault());
     
    539561     */
    540562    synchronized public Color getColor(String colName, String specName, Color def) {
    541         putDefault("color."+colName, ColorHelper.color2html(def));
     563        String colKey = colName.toLowerCase().replaceAll("[^a-z0-9]+",".");
     564        if(!colKey.equals(colName))
     565            colornames.put(colKey, colName);
     566        putDefault("color."+colKey, ColorHelper.color2html(def));
    542567        String colStr = specName != null ? get("color."+specName) : "";
    543568        if(colStr.equals("")) {
    544             colStr = get("color."+colName);
     569            colStr = get("color."+colKey);
    545570        }
    546571        return colStr.equals("") ? def : ColorHelper.html2color(colStr);
Note: See TracChangeset for help on using the changeset viewer.