Changeset 2370 in josm for trunk/src


Ignore:
Timestamp:
2009-11-01T10:20:23+01:00 (14 years ago)
Author:
stoecker
Message:

reworked user agent string to match established format

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

Legend:

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

    r2369 r2370  
    3535 */
    3636public class AboutAction extends JosmAction {
    37  
     37
    3838    public AboutAction() {
    3939        super(tr("About"), "about", tr("Display the about screen."), Shortcut.registerShortcut("system:about", tr("About"), KeyEvent.VK_F1, Shortcut.GROUP_DIRECT, Shortcut.SHIFT_DEFAULT), true);
     
    4242    public void actionPerformed(ActionEvent e) {
    4343        JTabbedPane about = new JTabbedPane();
    44        
     44
    4545        JTextArea readme = new JTextArea();
    4646        readme.setEditable(false);
     
    5454        license.setEditable(false);
    5555        license.setText(Version.loadResourceFile(Main.class.getResource("/LICENSE")));
    56        
     56
    5757        Version version = Version.getInstance();
    5858
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r2369 r2370  
    3232import org.openstreetmap.josm.gui.preferences.ProxyPreferences;
    3333import org.openstreetmap.josm.tools.ColorHelper;
    34 import org.openstreetmap.josm.tools.LanguageInfo;
    3534
    3635/**
     
    6261        private String name;
    6362        private Bounds area;
    64        
    65         public Bookmark() {   
     63
     64        public Bookmark() {
    6665            area = null;
    6766            name = null;
    6867        }
    69        
     68
    7069        public Bookmark(Bounds area) {
    71             this.area = area;           
    72         }
    73        
     70            this.area = area;
     71        }
     72
    7473        @Override public String toString() {
    7574            return name;
    7675        }
    77                
     76
    7877        public int compareTo(Bookmark b) {
    7978            return name.toLowerCase().compareTo(b.name.toLowerCase());
    8079        }
    81        
    82         public Bounds getArea() { 
     80
     81        public Bounds getArea() {
    8382            return area;
    8483        }
     
    504503                } catch(NumberFormatException e) {
    505504                    System.err.println(tr("Error: Illegal double value ''{0}'' on line ''{1}'' in bookmark file ''{2}''",m.group(i+2),line, bookmarkFile.toString()));
    506                     continue;                   
     505                    continue;
    507506                }
    508507            }
     
    681680        return put(key, s);
    682681    }
    683    
     682
    684683    /**
    685684     * Updates system properties with the current values in the preferences.
    686      * 
     685     *
    687686     */
    688687    public void updateSystemProperties() {
     
    696695                sysProp.put("proxyPassword", get(ProxyPreferences.PROXY_PASS));
    697696            }
    698          
    699         }
    700         int v = Version.getInstance().getVersion();
    701         String s = (v == Version.JOSM_UNKNOWN_VERSION) ? "UNKNOWN" : Integer.toString(v);   
    702         if (! Version.getInstance().isLocalBuild() && v != Version.JOSM_UNKNOWN_VERSION) {
    703             s += " SVN";
    704         } else if (Version.getInstance().isLocalBuild() && v != Version.JOSM_UNKNOWN_VERSION) {
    705             s += " Local";
    706         }
    707         sysProp.put("http.agent", "JOSM/1.5 ("+ s+" "+LanguageInfo.getJOSMLocaleCode()+")");
     697
     698        }
     699        sysProp.put("http.agent", Version.getInstance().getAgentString());
    708700        System.setProperties(sysProp);
    709701    }
  • trunk/src/org/openstreetmap/josm/data/Version.java

    r2369 r2370  
    1414
    1515import org.openstreetmap.josm.Main;
     16import org.openstreetmap.josm.tools.LanguageInfo;
    1617
    1718/**
    1819 * Provides basic information about the currently used JOSM build.
    19  * 
     20 *
    2021 */
    2122public class Version {
     
    2324    static public final int JOSM_UNKNOWN_VERSION = 0;
    2425
    25     /** the unique instance */ 
     26    /** the unique instance */
    2627    private static Version instance;
    27    
     28
    2829    /**
    2930     * Load the specified resource as string.
    30      * 
     31     *
    3132     * @param resource the resource url to load
    32      * @return  the content of the resource file; null, if an error occurred 
     33     * @return  the content of the resource file; null, if an error occurred
    3334     */
    3435    static public String loadResourceFile(URL resource) {
     
    4849        return s;
    4950    }
    50    
    51     /**
    52      * Replies the unique instance of the version information 
    53      * 
     51
     52    /**
     53     * Replies the unique instance of the version information
     54     *
    5455     * @return the unique instance of the version information
    5556     */
    56    
     57
    5758    static public Version getInstance() {
    5859        if (instance == null) {
     
    6061            instance.init();
    6162        }
    62         return instance;           
    63     }
    64    
     63        return instance;
     64    }
     65
    6566    private int version;
    6667    private String revision;
    6768    private String time;
    6869    private boolean isLocalBuild;
    69    
     70
    7071    protected HashMap<String, String> parseManifestStyleFormattedString(String content) {
    7172        HashMap<String, String> properties = new HashMap<String, String>();
     
    8283        return properties;
    8384    }
    84    
    85     /**
    86      * Initializes the version infos from the revision resource file 
    87      * 
    88      * @param revisionInfo the revision info loaded from a revision resource file 
     85
     86    /**
     87     * Initializes the version infos from the revision resource file
     88     *
     89     * @param revisionInfo the revision info loaded from a revision resource file
    8990     */
    9091    protected void initFromRevisionInfo(String revisionInfo) {
     
    9394            this.version = JOSM_UNKNOWN_VERSION;
    9495            this.time = null;
    95             return;       
    96         }
    97        
     96            return;
     97        }
     98
    9899        HashMap<String, String> properties = parseManifestStyleFormattedString(revisionInfo);
    99100        String value = properties.get("Revision");
     
    109110            version = JOSM_UNKNOWN_VERSION;
    110111        }
    111                
    112         // the last changed data 
     112
     113        // the last changed data
    113114        //
    114115        time = properties.get("Last Changed Date");
     
    116117            time = properties.get("Build-Date");
    117118        }
    118        
     119
    119120        // is this a local build ?
    120121        //
    121         isLocalBuild = false; 
     122        isLocalBuild = false;
    122123        value = properties.get("Is-Local-Build");
    123124        if (value != null && value.trim().toLowerCase().equals("true"))  {
    124125            isLocalBuild = true;
    125126        }
    126        
     127
    127128        // the revision info
    128129        //
     
    132133        }
    133134        revision = sb.toString();
    134     }   
    135        
    136     public void init() {   
     135    }
     136
     137    public void init() {
    137138        URL u = Main.class.getResource("/REVISION");
    138139        if (u == null) {
     
    145146        System.out.println(revision);
    146147    }
    147    
    148     /**
    149      * Replies the version string. Either the SVN revision "1234" (as string) or the 
     148
     149    /**
     150     * Replies the version string. Either the SVN revision "1234" (as string) or the
    150151     * the I18n equivalent of "UNKNOWN".
    151      * 
    152      * @return the JOSM version 
     152     *
     153     * @return the JOSM version
    153154     */
    154155    public String getVersionString() {
    155156        return  version == 0 ? tr("UNKNOWN") : Integer.toString(version);
    156157    }
    157    
     158
    158159    /**
    159160     * Replies a text with the release attributes
    160      * 
     161     *
    161162     * @return a text with the release attributes
    162163     */
     
    166167
    167168    /**
    168      * Replies the build date as string 
    169      * 
    170      * @return the build date as string 
     169     * Replies the build date as string
     170     *
     171     * @return the build date as string
    171172     */
    172173    public String getTime() {
    173174        return time;
    174175    }
    175    
    176     /**
    177      * Replies the JOSM version. Replies {@see #JOSM_UNKNOWN_VERSION} if the version isn't known. 
     176
     177    /**
     178     * Replies the JOSM version. Replies {@see #JOSM_UNKNOWN_VERSION} if the version isn't known.
    178179     * @return the JOSM version
    179180     */
     
    184185    /**
    185186     * Replies true if this is a local build, i.e. an inofficial development build.
    186      * 
     187     *
    187188     * @return true if this is a local build, i.e. an inofficial development build.
    188189     */
     
    190191        return isLocalBuild;
    191192    }
     193
     194    public String getAgentString() {
     195        int v = getVersion();
     196        String s = (v == JOSM_UNKNOWN_VERSION) ? "UNKNOWN" : Integer.toString(v);
     197        if (isLocalBuild() && v != JOSM_UNKNOWN_VERSION) {
     198            s += " SVN";
     199        }
     200        return "JOSM/1.5 ("+ s+" "+LanguageInfo.getJOSMLocaleCode()+")";
     201    }
    192202}
Note: See TracChangeset for help on using the changeset viewer.