Changeset 1743 in josm


Ignore:
Timestamp:
2009-07-07T19:54:54+02:00 (15 years ago)
Author:
stoecker
Message:

added much improved preferences for external styles and presets

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

Legend:

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

    r1724 r1743  
    9191    {
    9292        return Math.toRadians(-183.0 + (zone * 6.0));
     93    }
     94    private double UTMCentralMeridianDeg(int zone)
     95    {
     96        return -183.0 + (zone * 6.0);
    9397    }
    9498
     
    324328
    325329    public EastNorth latlon2eastNorth(LatLon p) {
    326         EastNorth a = MapLatLonToXY(Math.toRadians(p.lat()), Math.toRadians(p.lon()), UTMCentralMeridian(33));
     330        EastNorth a = MapLatLonToXY(Math.toRadians(p.lat()), Math.toRadians(p.lon()), UTMCentralMeridian(getzone()));
    327331        return new EastNorth(a.east() * UTMScaleFactor + 3500000.0, a.north() * UTMScaleFactor);
    328332    }
    329333
    330334    public LatLon eastNorth2latlon(EastNorth p) {
    331         return MapXYToLatLon((p.east()-3500000.0)/UTMScaleFactor, p.north()/UTMScaleFactor, UTMCentralMeridian(33));
     335        return MapXYToLatLon((p.east()-3500000.0)/UTMScaleFactor, p.north()/UTMScaleFactor, UTMCentralMeridian(getzone()));
     336    }
     337
     338    @Override public String toString() {
     339        return tr("UTM Zone {0}", getzone());
    332340    }
    333341
    334342    /* TODO - support all UTM's not only zone 33 */
    335     @Override public String toString() {
    336         return tr("UTM Zone {0}", 33);
     343    public int getzone()
     344    {
     345      return 33;
    337346    }
    338347
     
    354363    {
    355364        return new Bounds(
    356         new LatLon(-90.0, 14.0),
    357         new LatLon(90.0, 22.0));
     365        new LatLon(-85.0, UTMCentralMeridianDeg(getzone())-5.0),
     366        new LatLon(85.0, UTMCentralMeridianDeg(getzone())+5.0));
    358367    }
    359368}
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyle.java

    r1190 r1743  
    11package org.openstreetmap.josm.gui.mappaint;
     2
     3import java.util.Collection;
     4import java.util.Map;
     5
     6import org.openstreetmap.josm.data.osm.OsmPrimitive;
     7import org.openstreetmap.josm.data.osm.OsmUtils;
    28
    39abstract public class ElemStyle
     
    915    public int priority;
    1016    public String code;
     17    Collection<Rule> rules = null;
    1118
    1219    public Boolean equals(ElemStyle s)
     
    1421        return s != null && s.code.equals(code);
    1522    }
     23    public boolean check(Map<String, String> keys)
     24    {
     25        if(rules == null)
     26            return true;
     27        for(Rule r : rules)
     28        {
     29            String k = keys.get(r.key);
     30            String bv = OsmUtils.getNamedOsmBoolean(r.boolValue);
     31            if(k == null || (r.value != null && !k.equals(r.value))
     32            || (bv != null && !bv.equals(OsmUtils.getNamedOsmBoolean(k))))
     33                return false;
     34        }
     35        return true;
     36    }
    1637}
    1738
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java

    r1635 r1743  
    22
    33import java.awt.Color;
     4import java.util.Collection;
     5import java.util.LinkedList;
    46
    57import javax.swing.ImageIcon;
     
    2022
    2123    class RuleElem {
    22         String key;
    23         String value;
    24         String boolValue;
     24        Rule rule = new Rule();
     25        Collection<Rule> rules;
    2526        long scaleMax;
    2627        long scaleMin;
     
    3132        public void init()
    3233        {
    33             key = value = boolValue = null;
     34            rules = null;
    3435            scaleMax = 1000000000;
    3536            scaleMin = 0;
    3637            line.init();
     38            rule.init();
    3739            linemod.init();
    3840            area.init();
     
    7173
    7274    private void error(String message) {
    73         System.out.println(styleName + " (" + rule.key + "=" + rule.value + "): " + message);
     75        System.out.println(styleName + " (" + rule.rule.key + "=" + rule.rule.value + "): " + message);
    7476    }
    7577
     
    148150            {
    149151                inCondition=true;
     152                Rule r = rule.rule;
     153                if(r.key != null)
     154                {
     155                    if(rule.rules == null)
     156                        rule.rules = new LinkedList<Rule>();
     157                    r = new Rule();
     158                    r.init();
     159                    rule.rules.add(r);
     160                }
    150161                for (int count=0; count<atts.getLength(); count++)
    151162                {
    152163                    if(atts.getQName(count).equals("k"))
    153                         rule.key = atts.getValue(count);
     164                        r.key = atts.getValue(count);
    154165                    else if(atts.getQName(count).equals("v"))
    155                         rule.value = atts.getValue(count);
     166                        r.value = atts.getValue(count);
    156167                    else if(atts.getQName(count).equals("b"))
    157                         rule.boolValue = atts.getValue(count);
     168                        r.boolValue = atts.getValue(count);
    158169                    else
    159170                        error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!");
    160171                }
     172                if(r.key == null)
     173                    error("The condition has no key!");
    161174            }
    162175            else if (qName.equals("line"))
     
    216229        {
    217230            if(hadLine)
    218                 styles.add(styleName, rule.key, rule.value, rule.boolValue,
     231            {
     232                rule.line.rules = rule.rules;
     233                styles.add(styleName, rule.rule,
    219234                new LineElemStyle(rule.line, rule.scaleMax, rule.scaleMin));
     235            }
    220236            if(hadLineMod)
    221                 styles.addModifier(styleName, rule.key, rule.value, rule.boolValue,
     237            {
     238                rule.linemod.rules = rule.rules;
     239                styles.addModifier(styleName, rule.rule,
    222240                new LineElemStyle(rule.linemod, rule.scaleMax, rule.scaleMin));
     241            }
    223242            if(hadIcon)
    224                 styles.add(styleName, rule.key, rule.value, rule.boolValue,
     243            {
     244                rule.icon.rules = rule.rules;
     245                styles.add(styleName, rule.rule,
    225246                new IconElemStyle(rule.icon, rule.scaleMax, rule.scaleMin));
     247            }
    226248            if(hadArea)
    227                 styles.add(styleName, rule.key, rule.value, rule.boolValue,
     249            {
     250                rule.area.rules = rule.rules;
     251                styles.add(styleName, rule.rule,
    228252                new AreaElemStyle(rule.area, rule.scaleMax, rule.scaleMin));
     253            }
    229254            inRule = false;
    230255            hadLine = hadLineMod = hadIcon = hadArea = false;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java

    r1696 r1743  
    3939                if((style = icons.get("n" + key + "=" + val)) != null)
    4040                {
    41                     if(ret == null || style.priority > ret.priority)
     41                    if((ret == null || style.priority > ret.priority) && style.check(keys))
    4242                        ret = style;
    4343                }
    4444                if((style = icons.get("b" + key + "=" + OsmUtils.getNamedOsmBoolean(val))) != null)
    4545                {
    46                     if(ret == null || style.priority > ret.priority)
     46                    if((ret == null || style.priority > ret.priority) && style.check(keys))
    4747                        ret = style;
    4848                }
    4949                if((style = icons.get("x" + key)) != null)
    5050                {
    51                     if(ret == null || style.priority > ret.priority)
     51                    if((ret == null || style.priority > ret.priority) && style.check(keys))
    5252                        ret = style;
    5353                }
     
    7070                String idx = "n" + key + "=" + val;
    7171                if((styleArea = areas.get(idx)) != null && (retArea == null
    72                 || styleArea.priority > retArea.priority) && (!noclosed || !styleArea.closed))
     72                || styleArea.priority > retArea.priority) && (!noclosed
     73                || !styleArea.closed) && styleArea.check(keys))
    7374                    retArea = styleArea;
    74                 if((styleLine = lines.get(idx)) != null && (retLine == null || styleLine.priority > retLine.priority))
     75                if((styleLine = lines.get(idx)) != null && (retLine == null
     76                || styleLine.priority > retLine.priority) && styleLine.check(keys))
    7577                {
    7678                    retLine = styleLine;
    7779                    linestring = idx;
    7880                }
    79                 if((styleLine = modifiers.get(idx)) != null)
     81                if((styleLine = modifiers.get(idx)) != null && styleLine.check(keys))
    8082                    over.put(idx, styleLine);
    8183                idx = "b" + key + "=" + OsmUtils.getNamedOsmBoolean(val);
    8284                if((styleArea = areas.get(idx)) != null && (retArea == null
    83                 || styleArea.priority > retArea.priority) && (!noclosed || !styleArea.closed))
     85                || styleArea.priority > retArea.priority) && (!noclosed
     86                || !styleArea.closed) && styleArea.check(keys))
    8487                    retArea = styleArea;
    85                 if((styleLine = lines.get(idx)) != null && (retLine == null || styleLine.priority > retLine.priority))
     88                if((styleLine = lines.get(idx)) != null && (retLine == null
     89                || styleLine.priority > retLine.priority) && styleLine.check(keys))
    8690                {
    8791                    retLine = styleLine;
    8892                    linestring = idx;
    8993                }
    90                 if((styleLine = modifiers.get(idx)) != null)
     94                if((styleLine = modifiers.get(idx)) != null && styleLine.check(keys))
    9195                    over.put(idx, styleLine);
    9296                idx = "x" + key;
    9397                if((styleArea = areas.get(idx)) != null && (retArea == null
    94                 || styleArea.priority > retArea.priority) && (!noclosed || !styleArea.closed))
     98                || styleArea.priority > retArea.priority) && (!noclosed
     99                || !styleArea.closed) && styleArea.check(keys))
    95100                    retArea = styleArea;
    96                 if((styleLine = lines.get(idx)) != null && (retLine == null || styleLine.priority > retLine.priority))
     101                if((styleLine = lines.get(idx)) != null && (retLine == null
     102                || styleLine.priority > retLine.priority) && styleLine.check(keys))
    97103                {
    98104                    retLine = styleLine;
    99105                    linestring = idx;
    100106                }
    101                 if((styleLine = modifiers.get(idx)) != null)
     107                if((styleLine = modifiers.get(idx)) != null && styleLine.check(keys))
    102108                    over.put(idx, styleLine);
    103109            }
     
    177183    }
    178184
    179     private String getKey(String k, String v, String b)
    180     {
    181         if(v != null)
    182             return "n" + k + "=" + v;
    183         else if(b != null)
    184             return "b" + k  + "=" + OsmUtils.getNamedOsmBoolean(b);
    185         else
    186             return "x" + k;
    187     }
    188 
    189     public void add(String name, String k, String v, String b, LineElemStyle style)
    190     {
    191         String key = getKey(k,v,b);
     185    public void add(String name, Rule r, LineElemStyle style)
     186    {
     187        String key = r.getKey();
    192188        style.code = key;
    193189        getStyleSet(name, true).lines.put(key, style);
    194190    }
    195191
    196     public void addModifier(String name, String k, String v, String b, LineElemStyle style)
    197     {
    198         String key = getKey(k,v,b);
     192    public void addModifier(String name, Rule r, LineElemStyle style)
     193    {
     194        String key = r.getKey();
    199195        style.code = key;
    200196        getStyleSet(name, true).modifiers.put(key, style);
    201197    }
    202198
    203     public void add(String name, String k, String v, String b, AreaElemStyle style)
    204     {
    205         String key = getKey(k,v,b);
     199    public void add(String name, Rule r, AreaElemStyle style)
     200    {
     201        String key = r.getKey();
    206202        style.code = key;
    207203        getStyleSet(name, true).areas.put(key, style);
    208204    }
    209205
    210     public void add(String name, String k, String v, String b, IconElemStyle style)
    211     {
    212         String key = getKey(k,v,b);
     206    public void add(String name, Rule r, IconElemStyle style)
     207    {
     208        String key = r.getKey();
    213209        style.code = key;
    214210        getStyleSet(name, true).icons.put(key, style);
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r1241 r1743  
    11package org.openstreetmap.josm.gui.mappaint;
    22
     3import java.util.Collection;
     4import java.util.Collections;
    35import java.util.LinkedList;
    46import java.util.List;
     
    1719
    1820    private static ElemStyles styles = new ElemStyles();
    19     private static String iconDirs;
     21    private static Collection<String> iconDirs;
    2022
    2123    public static ElemStyles getStyles()
     
    2729    {
    2830        List<String> dirs = new LinkedList<String>();
    29         for(String fileset : iconDirs.split(";"))
     31        for(String fileset : iconDirs)
    3032        {
    3133            String[] a;
     
    4951
    5052    public static void readFromPreferences() {
    51         String[] a = null;
     53        iconDirs = Main.pref.getCollection("mappaint.icon.sources", Collections.<String>emptySet());
     54        if(Main.pref.getBoolean("mappaint.icon.enable-defaults", true))
     55        {
     56            LinkedList<String> f = new LinkedList<String>(iconDirs);
     57            /* don't prefix icon path, as it should be generic */
     58            f.add("resource://images/styles/standard/");
     59            f.add("resource://images/styles/");
     60            iconDirs = f;
     61        }
    5262
    53         /* don't prefix icon path, as it should be generic */
    54         String internalicon = "resource://images/styles/standard/;resource://images/styles/";
    55         String internalfile = "resource://styles/standard/elemstyles.xml";
     63        Collection<String> files = Main.pref.getCollection("mappaint.style.sources", Collections.<String>emptySet());
     64        if(Main.pref.getBoolean("mappaint.style.enable-defaults", true))
     65        {
     66            LinkedList<String> f = new LinkedList<String>();
     67            f.add("resource://styles/standard/elemstyles.xml");
     68            f.addAll(files);
     69            files = f;
     70        }
    5671
    57         iconDirs = Main.pref.get("mappaint.icon.sources");
    58         if(Main.pref.getBoolean("mappaint.icon.enable-defaults", true))
    59             iconDirs = iconDirs == null || iconDirs.length() == 0 ? internalicon : iconDirs + ";" + internalicon;
    60 
    61         String file = Main.pref.get("mappaint.style.sources");
    62         if(Main.pref.getBoolean("mappaint.style.enable-defaults", true))
    63             file = (file == null || file.length() == 0) ? internalfile : internalfile + ";" + file;
    64 
    65         for(String fileset : file.split(";"))
     72        for(String fileset : files)
    6673        {
     74            String[] a = null;
    6775            try
    6876            {
     
    8189                System.out.println("Mappaint-Style \"" + a[0] + "\" file \"" + a[1] + "\"");
    8290                System.out.println("Mappaint-Style problems: " + e);
     91                e.printStackTrace();
    8392            }
    8493        }
  • trunk/src/org/openstreetmap/josm/gui/preferences/MapPaintPreference.java

    r1742 r1743  
    22package org.openstreetmap.josm.gui.preferences;
    33
     4import static org.openstreetmap.josm.tools.I18n.tr;
     5
     6import java.awt.GridBagLayout;
     7
     8import javax.swing.BorderFactory;
     9import javax.swing.JCheckBox;
     10import javax.swing.JComboBox;
     11import javax.swing.JLabel;
     12import javax.swing.JPanel;
     13import javax.swing.JScrollPane;
     14
    415import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
     16import org.openstreetmap.josm.Main;
     17import org.openstreetmap.josm.tools.GBC;
    518
    619public class MapPaintPreference implements PreferenceSetting {
     20    private StyleSources sources;
     21    private JCheckBox enableIconDefault;
     22    private JCheckBox enableDefault;
     23    private JComboBox styleCombo = new JComboBox();
    724
    825    public static class Factory implements PreferenceSettingFactory {
     
    1330
    1431    public void addGui(final PreferenceDialog gui) {
    15         // this is intended for a future configuration panel for mappaint!
     32        enableDefault = new JCheckBox(tr("Enable built-in defaults"),
     33                Main.pref.getBoolean("mappaint.style.enable-defaults", true));
     34        enableIconDefault = new JCheckBox(tr("Enable built-in icon defaults"),
     35                Main.pref.getBoolean("mappaint.icon.enable-defaults", true));
     36
     37        styleCombo.addItem("standard");
     38
     39        String style = Main.pref.get("mappaint.style", "standard");
     40        styleCombo.setEditable(true);
     41        for (int i = 0; i < styleCombo.getItemCount(); ++i) {
     42            if (styleCombo.getItemAt(i).getClass().getName().equals(style)) {
     43                styleCombo.setSelectedIndex(i);
     44                break;
     45            }
     46        }
     47
     48        JPanel panel = new JPanel(new GridBagLayout());
     49        JScrollPane scrollpane = new JScrollPane(panel);
     50        panel.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
     51        panel.add(enableDefault, GBC.std().insets(5,5,5,0));
     52        panel.add(enableIconDefault, GBC.eol().insets(5,5,5,0));
     53
     54        panel.add(new JLabel(tr("Used style")), GBC.std().insets(5,5,0,5));
     55        panel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL));
     56        panel.add(styleCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,0,5,0));
     57
     58        sources = new StyleSources("mappaint.style.sources", "mappaint.icon.sources",
     59        "http://josm.openstreetmap.de/styles", false, tr("Map Paint Styles"));
     60        panel.add(sources, GBC.eol().fill(GBC.BOTH));
     61        gui.mapcontent.addTab(tr("Map Paint Styles"), scrollpane);
    1662    }
    1763
    1864    public boolean ok() {
    19         return false; // dummy
     65        Boolean restart = Main.pref.put("mappaint.style.enable-defaults", enableDefault.getSelectedObjects() != null);
     66        if(Main.pref.put("mappaint.icon.enable-defaults", enableIconDefault.getSelectedObjects() != null))
     67          restart = true;
     68        if(sources.finish())
     69          restart = true;
     70        Main.pref.put("mappaint.style", styleCombo.getEditor().getItem().toString());
     71        return restart;
    2072    }
    2173
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java

    r1742 r1743  
    4545
    4646    public final javax.swing.JTabbedPane displaycontent = new javax.swing.JTabbedPane();
     47    public final javax.swing.JTabbedPane mapcontent = new javax.swing.JTabbedPane();
    4748
    4849    /**
     
    118119
    119120        display.add(displaycontent, GBC.eol().fill(GBC.BOTH));
     121        map.add(mapcontent, GBC.eol().fill(GBC.BOTH));
    120122        for (Iterator<PreferenceSetting> it = settings.iterator(); it.hasNext();) {
    121123            try {
     
    150152        settingsFactory.add(new LafPreference.Factory());
    151153        settingsFactory.add(new LanguagePreference.Factory());
    152         settingsFactory.add(new MapPaintPreference.Factory());
    153154        settingsFactory.add(new ServerAccessPreference.Factory());
    154155        settingsFactory.add(new FilePreferences.Factory());
    155156        settingsFactory.add(new ProxyPreferences.Factory());
    156157        settingsFactory.add(new ProjectionPreference.Factory());
     158        settingsFactory.add(new MapPaintPreference.Factory());
    157159        settingsFactory.add(new TaggingPresetPreference.Factory());
    158160        settingsFactory.add(new PluginPreference.Factory());
  • trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java

    r1742 r1743  
    88
    99import javax.swing.BorderFactory;
     10import javax.swing.Box;
    1011import javax.swing.JComboBox;
    1112import javax.swing.JLabel;
     13import javax.swing.JScrollPane;
    1214import javax.swing.JPanel;
    1315
     
    5052
    5153        JPanel projPanel = new JPanel();
    52         projPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.gray), tr("Map Projection")));
     54        projPanel.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
    5355        projPanel.setLayout(new GridBagLayout());
    5456        projPanel.add(new JLabel(tr("Projection method")), GBC.std().insets(5,5,0,5));
     
    5860        projPanel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL));
    5961        projPanel.add(coordinatesCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5));
    60         gui.map.add(projPanel, GBC.eol().insets(0,0,0,10).fill(GBC.HORIZONTAL));
     62        projPanel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
     63        JScrollPane scrollpane = new JScrollPane(projPanel);
     64        gui.mapcontent.addTab(tr("Map Projection"), scrollpane);
    6165    }
    6266
  • trunk/src/org/openstreetmap/josm/gui/preferences/TaggingPresetPreference.java

    r1742 r1743  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.Color;
    76import java.awt.GridBagLayout;
    8 import java.awt.event.ActionEvent;
    9 import java.awt.event.ActionListener;
    10 import java.util.ArrayList;
    117import java.util.Collection;
    128import java.util.HashMap;
    139
    1410import javax.swing.BorderFactory;
    15 import javax.swing.Box;
    16 import javax.swing.DefaultListModel;
    17 import javax.swing.JButton;
    1811import javax.swing.JCheckBox;
    19 import javax.swing.JLabel;
    20 import javax.swing.JList;
    2112import javax.swing.JMenu;
    2213import javax.swing.JMenuItem;
    23 import javax.swing.JOptionPane;
    2414import javax.swing.JPanel;
     15import javax.swing.JSeparator;
    2516import javax.swing.JScrollPane;
    26 import javax.swing.JSeparator;
    2717
    2818import org.openstreetmap.josm.Main;
     
    4131
    4232    public static Collection<TaggingPreset> taggingPresets;
    43     private JList taggingPresetSources;
     33    private StyleSources sources;
    4434    private JCheckBox sortMenu;
    4535    private JCheckBox enableDefault;
    4636
    4737    public void addGui(final PreferenceDialog gui) {
    48 
    49         taggingPresetSources = new JList(new DefaultListModel());
    5038        sortMenu = new JCheckBox(tr("Sort presets menu"),
    5139                Main.pref.getBoolean("taggingpreset.sortmenu", false));
     
    5341                Main.pref.getBoolean("taggingpreset.enable-defaults", true));
    5442
    55         Collection<String> sources = Main.pref.getCollection("taggingpreset.sources", null);
    56         if(sources != null)
    57             for(String s : sources)
    58                 ((DefaultListModel)taggingPresetSources.getModel()).addElement(s);
    59 
    60         JButton addAnno = new JButton(tr("Add"));
    61         addAnno.addActionListener(new ActionListener(){
    62             public void actionPerformed(ActionEvent e) {
    63                 String source = JOptionPane.showInputDialog(Main.parent, tr("Tagging preset source"));
    64                 if (source != null)
    65                     ((DefaultListModel)taggingPresetSources.getModel()).addElement(source);
    66             }
    67         });
    68 
    69         JButton editAnno = new JButton(tr("Edit"));
    70         editAnno.addActionListener(new ActionListener(){
    71             public void actionPerformed(ActionEvent e) {
    72                 if (taggingPresetSources.getSelectedIndex() == -1)
    73                     JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to edit."));
    74                 else {
    75                     String source = JOptionPane.showInputDialog(Main.parent, tr("Tagging preset source"), taggingPresetSources.getSelectedValue());
    76                     if (source != null)
    77                         ((DefaultListModel)taggingPresetSources.getModel()).setElementAt(source, taggingPresetSources.getSelectedIndex());
    78                 }
    79             }
    80         });
    81 
    82         JButton deleteAnno = new JButton(tr("Delete"));
    83         deleteAnno.addActionListener(new ActionListener(){
    84             public void actionPerformed(ActionEvent e) {
    85                 if (taggingPresetSources.getSelectedIndex() == -1)
    86                     JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to delete."));
    87                 else {
    88                     ((DefaultListModel)taggingPresetSources.getModel()).remove(taggingPresetSources.getSelectedIndex());
    89                 }
    90             }
    91         });
    92         taggingPresetSources.setVisibleRowCount(3);
    93 
    94         taggingPresetSources.setToolTipText(tr("The sources (URL or filename) of tagging preset definition files. See http://josm.openstreetmap.de/wiki/TaggingPresets for help."));
    95         addAnno.setToolTipText(tr("Add a new tagging preset source to the list."));
    96         deleteAnno.setToolTipText(tr("Delete the selected source from the list."));
    97 
    98         JPanel tpPanel = new JPanel();
    99         tpPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.gray), tr("Tagging Presets")));
    100         tpPanel.setLayout(new GridBagLayout());
    101         tpPanel.add(sortMenu, GBC.eol().insets(5,5,5,0));
    102         tpPanel.add(enableDefault, GBC.eol().insets(5,5,5,0));
    103         tpPanel.add(new JLabel(tr("Tagging preset sources")), GBC.eol().insets(5,5,5,0));
    104         tpPanel.add(new JScrollPane(taggingPresetSources), GBC.eol().insets(5,0,5,0).fill(GBC.BOTH));
    105         JPanel buttonPanel = new JPanel(new GridBagLayout());
    106         tpPanel.add(buttonPanel, GBC.eol().insets(5,0,5,5).fill(GBC.HORIZONTAL));
    107         buttonPanel.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL));
    108         buttonPanel.add(addAnno, GBC.std().insets(0,5,0,0));
    109         buttonPanel.add(editAnno, GBC.std().insets(5,5,5,0));
    110         buttonPanel.add(deleteAnno, GBC.std().insets(0,5,0,0));
    111         gui.map.add(tpPanel, GBC.eol().fill(GBC.BOTH));
     43        JPanel panel = new JPanel(new GridBagLayout());
     44        JScrollPane scrollpane = new JScrollPane(panel);
     45        panel.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
     46        panel.add(sortMenu, GBC.eol().insets(5,5,5,0));
     47        panel.add(enableDefault, GBC.eol().insets(5,0,5,0));
     48        sources = new StyleSources("taggingpreset.sources", "taggingpreset.icon.sources",
     49        "http://josm.openstreetmap.de/presets", false, tr("Tagging Presets"));
     50        panel.add(sources, GBC.eol().fill(GBC.BOTH));
     51        gui.mapcontent.addTab(tr("Tagging Presets"), scrollpane);
    11252    }
    11353
    11454    public boolean ok() {
    115         boolean restart;
    116         Main.pref.put("taggingpreset.enable-defaults", enableDefault.getSelectedObjects() != null);
    117         restart = Main.pref.put("taggingpreset.sortmenu", sortMenu.getSelectedObjects() != null);
    118         int num = taggingPresetSources.getModel().getSize();
    119         if (num > 0)
    120         {
    121             ArrayList<String> l = new ArrayList<String>();
    122             for (int i = 0; i < num; ++i)
    123                 l.add((String)taggingPresetSources.getModel().getElementAt(i));
    124             if(Main.pref.putCollection("taggingpreset.sources", l))
    125                 restart = true;
    126         }
    127         else if(Main.pref.putCollection("taggingpreset.sources", null))
     55        boolean restart = Main.pref.put("taggingpreset.enable-defaults",
     56        enableDefault.getSelectedObjects() != null);
     57        if(Main.pref.put("taggingpreset.sortmenu", sortMenu.getSelectedObjects() != null))
     58            restart = true;
     59        if(sources.finish())
    12860            restart = true;
    12961        return restart;
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r1632 r1743  
    465465     */
    466466    public void setIcon(String iconName) {
    467         Collection<String> s = Main.pref.getCollection("taggingpreset.iconpaths", null);
     467        Collection<String> s = Main.pref.getCollection("taggingpreset.icon.sources", null);
    468468        ImageIcon icon = ImageProvider.getIfAvailable(s, "presets", null, iconName);
    469469        if (icon == null)
  • trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java

    r1711 r1743  
    8585            destDirFile.mkdirs();
    8686
    87         localPath = "mirror_" + new File(url.getPath()).getName();
     87        String a = url.toString().replaceAll("[^A-Za-z0-9_.-]", "_");
     88        localPath = "mirror_" + a;
    8889        destDirFile = new File(destDir, localPath + ".tmp");
    8990        BufferedOutputStream bos = null;
Note: See TracChangeset for help on using the changeset viewer.