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


Ignore:
Timestamp:
2008-08-16T18:27:50+02:00 (16 years ago)
Author:
stoecker
Message:

einstein mode preferences now shows all options and their default values

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

Legend:

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

    r758 r795  
    8989                        if (v.min != null && v.max != null) // && v.min.north() == v.max.north() && v.min.east() == v.max.east()) {
    9090                        {
    91                                 EastNorth en = Main.proj.latlon2eastNorth(new LatLon(0.001, 0.001));
     91                                EastNorth en = new EastNorth(0,0);
    9292                                v.min = new EastNorth(v.min.east()-en.east(), v.min.north()-en.north());
    9393                                v.max = new EastNorth(v.max.east()+en.east(), v.max.north()+en.north());
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r768 r795  
    5454         */
    5555        protected final SortedMap<String, String> properties = new TreeMap<String, String>();
     56        protected final SortedMap<String, String> defaults = new TreeMap<String, String>();
    5657
    5758        /**
     
    118119        }
    119120        synchronized public String get(final String key, final String def) {
     121                if(!defaults.containsKey(key))
     122                        defaults.put(key, def);
     123                else if(!defaults.get(key).equals(def))
     124                        System.out.println("Defaults for " + key + " differ: " + def + " != " + defaults.get(key));
    120125                if (override.containsKey(key))
    121126                        return override.get(key);
     
    139144        }
    140145       
     146        synchronized public Map<String, String> getDefaults()
     147        {
     148                return defaults;
     149        }
     150       
    141151        synchronized public boolean getBoolean(final String key) {
    142                 return getBoolean(key, false);
     152                if (override.containsKey(key))
     153                        return override.get(key) == null ? false : Boolean.parseBoolean(override.get(key));
     154                return properties.containsKey(key) ? Boolean.parseBoolean(properties.get(key)) : false;
    143155        }
    144156        synchronized public boolean getBoolean(final String key, final boolean def) {
     157                if(!defaults.containsKey(key))
     158                        defaults.put(key, Boolean.toString(def));
     159                else if(!defaults.get(key).equals(Boolean.toString(def)))
     160                        System.out.println("Defaults for " + key + " differ: " + def + " != " + defaults.get(key));
    145161                if (override.containsKey(key))
    146162                        return override.get(key) == null ? def : Boolean.parseBoolean(override.get(key));
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r791 r795  
    1515import org.openstreetmap.josm.data.osm.visitor.Visitor;
    1616import org.openstreetmap.josm.tools.DateParser;
     17import org.openstreetmap.josm.Main;
    1718
    1819
     
    2324 * Although OsmPrimitive is designed as a base class, it is not to be meant to subclass
    2425 * it by any other than from the package {@link org.openstreetmap.josm.data.osm}. The available primitives are a fixed set that are given
    25  * by the server environment and not an extendible data stuff. 
     26 * by the server environment and not an extendible data stuff.
    2627 *
    2728 * @author imi
     
    3637        /**
    3738         * Unique identifier in OSM. This is used to identify objects on the server.
    38          * An id of 0 means an unknown id. The object has not been uploaded yet to 
     39         * An id of 0 means an unknown id. The object has not been uploaded yet to
    3940         * know what id it will get.
    40          * 
     41         *
    4142         * Do not write to this attribute except you know exactly what you are doing.
    4243         * More specific, it is not good to set this to 0 and think the object is now
     
    5051         * the server. In this case, on next upload, this object will be updated.
    5152         * Deleted objects are deleted from the server. If the objects are added (id=0),
    52          * the modified is ignored and the object is added to the server. 
     53         * the modified is ignored and the object is added to the server.
    5354         */
    5455        public boolean modified = false;
     
    6667         */
    6768        public boolean visible = true;
    68        
    69         /** 
     69
     70        /**
    7071         * User that last modified this primitive, as specified by the server.
    7172         * Never changed by JOSM.
    7273         */
    7374        public User user = null;
    74        
     75
    7576        /**
    7677         * true if this object is considered "tagged". To be "tagged", an object
    7778         * must have one or more "non-standard" tags. "created_by" and "source"
    78          * are typically considered "standard" tags and do not make an object 
     79         * are typically considered "standard" tags and do not make an object
    7980         * "tagged".
    8081         */
    8182        public boolean tagged = false;
    82        
     83
    8384        /**
    8485         * true if this object has direction dependent tags (e.g. oneway)
    8586         */
    8687        public boolean hasDirectionKeys = false;
    87        
     88
    8889        /**
    8990         * If set to true, this object is currently selected.
     
    9798         */
    9899        public String timestamp = null;
    99        
    100         /**
    101          * The timestamp is only parsed when this is really necessary, and this 
     100
     101        /**
     102         * The timestamp is only parsed when this is really necessary, and this
    102103         * is the cache for the result.
    103104         */
    104105        public Date parsedTimestamp = null;
    105        
     106
    106107        /**
    107108         * If set to true, this object is incomplete, which means only the id
    108109         * and type is known (type is the objects instance class)
    109110         */
    110         public boolean incomplete = false; 
    111 
    112         /** 
     111        public boolean incomplete = false;
     112
     113        /**
    113114         * Contains the version number as returned by the API. Needed to
    114115         * ensure update consistency
    115116         */
    116117        public int version = -1;
    117          
     118
    118119        /**
    119120         * Contains a list of "uninteresting" keys that do not make an object
    120121         * "tagged".
    121          */
    122         public static Collection<String> uninteresting =
    123                 new HashSet<String>(Arrays.asList(new String[] {"source", "note", "converted_by", "created_by"}));
    124        
     122         * Initialized by checkTagged()
     123         */
     124        private static Collection<String> uninteresting = null;
     125
    125126        /**
    126127         * Contains a list of direction-dependent keys that make an object
    127128         * direction dependent.
    128          */
    129         public static Collection<String> directionKeys =
    130                 new HashSet<String>(Arrays.asList(new String[] {"oneway", "incline", "incline_steep", "aerialway"}));
    131        
     129         * Initialized by checkDirectionTagged()
     130         */
     131        private static Collection<String> directionKeys = null;
     132
    132133        /**
    133134         * Implementation of the visitor scheme. Subclasses have to call the correct
     
    142143                modified = true;
    143144        }
    144        
     145
    145146        /**
    146147         * Returns the timestamp for this object, or the current time if none is set.
     
    157158                }
    158159                return parsedTimestamp;
    159         }
    160 
    161         /**
    162          * Equal, if the id (and class) is equal. 
    163          * 
     160        }
     161
     162        /**
     163         * Equal, if the id (and class) is equal.
     164         *
    164165         * An primitive is equal to its incomplete counter part.
    165166         */
    166     @Override public boolean equals(Object obj) {
    167         if (id == 0) return obj == this;
    168         if (obj instanceof OsmPrimitive) { // not null too
    169             return ((OsmPrimitive)obj).id == id && obj.getClass() == getClass();
    170         }
    171         return false;
    172     }
     167        @Override public boolean equals(Object obj) {
     168                if (id == 0) return obj == this;
     169                if (obj instanceof OsmPrimitive) { // not null too
     170                        return ((OsmPrimitive)obj).id == id && obj.getClass() == getClass();
     171                }
     172                return false;
     173        }
    173174
    174175        /**
    175176         * Return the id plus the class type encoded as hashcode or super's hashcode if id is 0.
    176          * 
     177         *
    177178         * An primitive has the same hashcode as its incomplete counterpart.
    178179         */
     
    204205                }
    205206                checkTagged();
    206                 checkDirectionTagged();
     207                checkDirectionTagged();
    207208        }
    208209        /**
     
    216217                }
    217218                checkTagged();
    218                 checkDirectionTagged();
     219                checkDirectionTagged();
    219220        }
    220221
     
    256257
    257258        /**
    258          * Perform an equality compare for all non-volatile fields not only for the id 
     259         * Perform an equality compare for all non-volatile fields not only for the id
    259260         * but for the whole object (for conflict resolving)
    260261         * @param semanticOnly if <code>true</code>, modified flag and timestamp are not compared
     
    264265                        id == osm.id &&
    265266                        incomplete == osm.incomplete &&
    266                         (semanticOnly || (modified == osm.modified)) && 
     267                        (semanticOnly || (modified == osm.modified)) &&
    267268                        deleted == osm.deleted &&
    268269                        (semanticOnly || (timestamp == null ? osm.timestamp==null : timestamp.equals(osm.timestamp))) &&
     
    272273                        (keys == null ? osm.keys==null : keys.equals(osm.keys));
    273274        }
    274        
     275
    275276        public String getTimeStr() {
    276277                return timestamp == null ? null : new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timestamp);
    277278        }
    278        
     279
    279280        /**
    280281         * Updates the "tagged" flag. "keys" property should probably be made private
     
    283284        public void checkTagged() {
    284285                tagged = false;
     286                if(uninteresting == null)
     287                        uninteresting = new HashSet<String>(Arrays.asList(Main.pref.get("tags.uninteresting",
     288                        "source;note;converted_by;created_by").split(";")));
    285289                if (keys != null) {
    286290                        for (Entry<String,String> e : keys.entrySet()) {
     
    292296                }
    293297        }
    294     /**
    295      * Updates the "hasDirectionKeys" flag. "keys" property should probably be made private
    296      * to make sure this gets called when keys are set.
    297      */
    298     public void checkDirectionTagged() {
    299         hasDirectionKeys = false;
    300         if (keys != null) {
    301             for (Entry<String,String> e : keys.entrySet()) {
    302                 if (directionKeys.contains(e.getKey())) {
    303                     hasDirectionKeys = true;
    304                     break;
    305                 }
    306             }
    307         }
    308 
    309     }
    310        
     298        /**
     299         * Updates the "hasDirectionKeys" flag. "keys" property should probably be made private
     300         * to make sure this gets called when keys are set.
     301         */
     302        public void checkDirectionTagged() {
     303                hasDirectionKeys = false;
     304                if(directionKeys == null)
     305                        directionKeys = new HashSet<String>(Arrays.asList(Main.pref.get("tags.direction",
     306                        "oneway;incline;incline_step;aerialway").split(";")));
     307                if (keys != null) {
     308                        for (Entry<String,String> e : keys.entrySet()) {
     309                                if (directionKeys.contains(e.getKey())) {
     310                                        hasDirectionKeys = true;
     311                                        break;
     312                                }
     313                        }
     314                }
     315        }
    311316}
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r655 r795  
    110110                        } else {
    111111                                Main.pref.load();
    112                                
    113                                 // this is temporary code to ease the transition to built-in mappaint
    114                                 List<String> plugins = new LinkedList<String>();
    115                                 if (Main.pref.hasKey("plugins"))
    116                                         plugins.addAll(Arrays.asList(Main.pref.get("plugins").split(",")));
    117                                                                
    118                                 if (plugins.contains("mappaint")) {
    119                                         plugins.remove("mappaint");
    120                                         // XXX is there really no "public static String.join" or something?
    121                                         StringBuilder tmp = new StringBuilder();
    122                                         for (String p : plugins) { if (tmp.length()>0) tmp.append(","); tmp.append(p); }
    123                                         Main.pref.put("plugins", tmp.toString());
    124                                         Main.pref.put("draw.wireframe", false);
    125                                 } else if (!Main.pref.hasKey("draw.wireframe")) {
    126                                         Main.pref.put("draw.wireframe", true);
    127                                 }
    128112                        }
    129113                } catch (final IOException e1) {
  • trunk/src/org/openstreetmap/josm/gui/MainMenu.java

    r768 r795  
    195195                // TODO move code to an "action" like the others?
    196196        final JCheckBoxMenuItem wireframe = new JCheckBoxMenuItem(tr("Wireframe view"));
    197         wireframe.setSelected(Main.pref.getBoolean("draw.wireframe", true));     
     197                wireframe.setSelected(Main.pref.getBoolean("draw.wireframe", false));
    198198        wireframe.setAccelerator(KeyStroke.getKeyStroke("ctrl W"));
    199199        wireframe.addActionListener(new ActionListener() {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java

    r774 r795  
    422422                // menu.
    423423                if (TaggingPresetPreference.taggingPresets.size() > 0 &&
    424                                 Main.pref.getBoolean("taggingpresets.in-properties-dialog", false)) {
     424                                Main.pref.getBoolean("taggingpreset.in-properties-dialog", false)) {
    425425                        Vector<ActionListener> allPresets = new Vector<ActionListener>();
    426426                        for (final TaggingPreset p : TaggingPresetPreference.taggingPresets)
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r786 r795  
    148148        @Override public void paint(final Graphics g, final MapView mv) {
    149149                boolean inactive = Main.map.mapView.getActiveLayer() != this && Main.pref.getBoolean("draw.data.inactive_color", true);
    150                 if (Main.pref.getBoolean("draw.data.downloaded_area", false)) {
     150                if (Main.pref.getBoolean("draw.data.downloaded_area", true)) {
    151151                        // FIXME this is inefficient; instead a proper polygon has to be built, and instead
    152152                        // of drawing the outline, the outlying areas should perhaps be shaded.
  • trunk/src/org/openstreetmap/josm/gui/preferences/AdvancedPreference.java

    r627 r795  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.Component;
    67import java.awt.Dimension;
    78import java.awt.GridBagLayout;
     
    2223import javax.swing.JTable;
    2324import javax.swing.JTextField;
     25import javax.swing.table.DefaultTableCellRenderer;
    2426import javax.swing.table.DefaultTableModel;
    2527
     
    3032
    3133        private Map<String,String> orig;
     34        private Map<String,String> defaults;
    3235        private DefaultTableModel model;
    3336
     
    3538                JPanel p = gui.createPreferenceTab("advanced", tr("Advanced Preferences"), tr("Setting Preference entries directly. Use with caution!"));
    3639
    37                 model = new DefaultTableModel(new String[]{"Key", "Value"},0) {
     40                model = new DefaultTableModel(new String[]{tr("Key"), tr("Value")},0) {
    3841                        @Override public boolean isCellEditable(int row, int column) {
    3942                                return column != 0;
    4043                        }
    4144                };
     45                DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(){
     46                        public Component getTableCellRendererComponent(JTable table, Object value,
     47                                boolean isSelected, boolean hasFocus, int row, int column)
     48                        {
     49                                JLabel label=new JLabel();
     50                                String s = defaults.get((String)value);
     51                                if(s != null)
     52                                {
     53                                        if(s.equals(model.getValueAt(row, 1)))
     54                                                label.setToolTipText(tr("Current value is default."));
     55                                        else
     56                                                label.setToolTipText(tr("Default value is ''{0}''.", s));
     57                                }
     58                                else
     59                                        label.setToolTipText(tr("Default value currently unknown (setting has not been used yet)."));
     60                                label.setText((String)value);
     61                                return label;
     62                        };
     63                };
    4264                final JTable list = new JTable(model);
     65                list.getColumn(tr("Key")).setCellRenderer(renderer);
    4366                JScrollPane scroll = new JScrollPane(list);
    4467                p.add(scroll, GBC.eol().fill(GBC.BOTH));
     
    4669
    4770                orig = Main.pref.getAllPrefix("");
     71                defaults = Main.pref.getDefaults();
    4872                orig.remove("osm-server.password");
     73                TreeSet<String> ts = new TreeSet<String>(orig.keySet());
     74                for (String s : defaults.keySet())
     75                {
     76                        if(!ts.contains(s))
     77                                ts.add(s);
     78                }
    4979
    50                 for (String s : new TreeSet<String>(orig.keySet()))
    51                         model.addRow(new String[]{s, Main.pref.get(s)});
     80                for (String s : ts)
     81                {
     82                        String val = Main.pref.get(s);
     83                        if(val == null) val = "";
     84                        model.addRow(new String[]{s, val});
     85                }
    5286
    5387                JButton add = new JButton(tr("Add"));
     
    85119                                        return;
    86120                                }
    87                                 while (list.getSelectedRow() != -1)
    88                                         model.removeRow(list.getSelectedRow());
     121                                for(int row: list.getSelectedRows())
     122                                        model.setValueAt("", row, 1);
    89123                        }
    90124                });
     
    100134        public void ok() {
    101135                for (int i = 0; i < model.getRowCount(); ++i) {
    102                         String key = model.getValueAt(i,0).toString();
    103136                        String value = model.getValueAt(i,1).toString();
    104                         String origValue = orig.get(key);
    105                         if (origValue == null || !origValue.equals(value))
    106                                 Main.pref.put(key, value);
    107                         orig.remove(key); // processed.
     137                        if(value.length() != 0)
     138                        {
     139                                String key = model.getValueAt(i,0).toString();
     140                                String origValue = orig.get(key);
     141                                if (origValue == null || !origValue.equals(value))
     142                                        Main.pref.put(key, value);
     143                                orig.remove(key); // processed.
     144                        }
    108145                }
    109146                for (Entry<String, String> e : orig.entrySet())
  • trunk/src/org/openstreetmap/josm/gui/preferences/AudioPreference.java

    r627 r795  
    135135                gui.audio.add(audioMarkersFromStart, GBC.eol().insets(10,0,0,0));
    136136               
    137                 audioForwardBackAmount.setText(Main.pref.get("audio.forwardbackamount", "10"));
     137                audioForwardBackAmount.setText(Main.pref.get("audio.forwardbackamount", "10.0"));
    138138                audioForwardBackAmount.setToolTipText(tr("The number of seconds to jump forward or back when the relevant button is pressed"));
    139139                gui.audio.add(new JLabel(tr("Forward/back time (seconds)")), GBC.std());
Note: See TracChangeset for help on using the changeset viewer.