Ignore:
Timestamp:
2010-01-06T20:35:56+01:00 (16 years ago)
Author:
Gubaer
Message:

new: JOSM now supports OAuth

See also online help for server preferences and new OAuth Authorisation Wizard

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r2715 r2748  
    2121
    2222import org.openstreetmap.josm.Main;
     23import org.openstreetmap.josm.gui.preferences.server.OAuthAccessTokenHolder;
    2324import org.openstreetmap.josm.io.DefaultProxySelector;
    2425import org.openstreetmap.josm.io.auth.CredentialsManagerFactory;
     
    6263
    6364    /**
     65     * Displays help on the console
     66     *
     67     */
     68    public static void showHelp() {
     69        // TODO: put in a platformHook for system that have no console by default
     70        System.out.println(tr("Java OpenStreetMap Editor")+"\n\n"+
     71                tr("usage")+":\n"+
     72                "\tjava -jar josm.jar <options>...\n\n"+
     73                tr("options")+":\n"+
     74                "\t--help|-?|-h                              "+tr("Show this help")+"\n"+
     75                "\t--geometry=widthxheight(+|-)x(+|-)y       "+tr("Standard unix geometry argument")+"\n"+
     76                "\t[--download=]minlat,minlon,maxlat,maxlon  "+tr("Download the bounding box")+"\n"+
     77                "\t[--download=]<url>                        "+tr("Download the location at the url (with lat=x&lon=y&zoom=z)")+"\n"+
     78                "\t[--download=]<filename>                   "+tr("Open file (as raw gps, if .gpx)")+"\n"+
     79                "\t--downloadgps=minlat,minlon,maxlat,maxlon "+tr("Download the bounding box as raw gps")+"\n"+
     80                "\t--selection=<searchstring>                "+tr("Select with the given search")+"\n"+
     81                "\t--[no-]maximize                           "+tr("Launch in maximized mode")+"\n"+
     82                "\t--reset-preferences                       "+tr("Reset the preferences to default")+"\n\n"+
     83                "\t--language=<language>                     "+tr("Set the language.")+"\n\n"+
     84                tr("options provided as Java system properties")+":\n"+
     85                "\t-Djosm.home="+tr("/PATH/TO/JOSM/FOLDER/         ")+tr("Change the folder for all user settings")+"\n\n"+
     86                tr("note: For some tasks, JOSM needs a lot of memory. It can be necessary to add the following\n" +
     87                "      Java option to increase the maximum size of allocated memory")+":\n"+
     88                "\t-Xmx...m\n\n"+
     89                tr("examples")+":\n"+
     90                "\tjava -jar josm.jar track1.gpx track2.gpx london.osm\n"+
     91                "\tjava -jar josm.jar http://www.openstreetmap.org/index.html?lat=43.2&lon=11.1&zoom=13\n"+
     92                "\tjava -jar josm.jar london.osm --selection=http://www.ostertag.name/osm/OSM_errors_node-duplicate.xml\n"+
     93                "\tjava -jar josm.jar 43.2,11.1,43.4,11.4\n"+
     94                "\tjava -Djosm.home=/home/user/.josm_dev -jar josm.jar\n"+
     95                "\tjava -Xmx400m -jar josm.jar\n\n"+
     96                tr("Parameters are read in the order they are specified, so make sure you load\n"+
     97                "some data before --selection")+"\n\n"+
     98                tr("Instead of --download=<bbox> you may specify osm://<bbox>\n"));
     99    }
     100
     101    /**
    64102     * Main application Startup
    65103     */
     
    102140        Main.pref.updateSystemProperties();
    103141
    104         Authenticator.setDefault(
    105                 new DefaultAuthenticator(
    106                         CredentialsManagerFactory.getCredentialManager()
    107                 )
    108         );
     142        DefaultAuthenticator.createInstance(CredentialsManagerFactory.getCredentialManager());
     143        Authenticator.setDefault(DefaultAuthenticator.getInstance());
    109144        ProxySelector.setDefault(new DefaultProxySelector(ProxySelector.getDefault()));
    110 
     145        OAuthAccessTokenHolder.getInstance().init(Main.pref, CredentialsManagerFactory.getCredentialManager());
     146
     147        // asking for help? show help and exit
    111148        if (argList.contains("--help") || argList.contains("-?") || argList.contains("-h")) {
    112             // TODO: put in a platformHook for system that have no console by default
    113             System.out.println(tr("Java OpenStreetMap Editor")+"\n\n"+
    114                     tr("usage")+":\n"+
    115                     "\tjava -jar josm.jar <options>...\n\n"+
    116                     tr("options")+":\n"+
    117                     "\t--help|-?|-h                              "+tr("Show this help")+"\n"+
    118                     "\t--geometry=widthxheight(+|-)x(+|-)y       "+tr("Standard unix geometry argument")+"\n"+
    119                     "\t[--download=]minlat,minlon,maxlat,maxlon  "+tr("Download the bounding box")+"\n"+
    120                     "\t[--download=]<url>                        "+tr("Download the location at the url (with lat=x&lon=y&zoom=z)")+"\n"+
    121                     "\t[--download=]<filename>                   "+tr("Open file (as raw gps, if .gpx)")+"\n"+
    122                     "\t--downloadgps=minlat,minlon,maxlat,maxlon "+tr("Download the bounding box as raw gps")+"\n"+
    123                     "\t--selection=<searchstring>                "+tr("Select with the given search")+"\n"+
    124                     "\t--[no-]maximize                           "+tr("Launch in maximized mode")+"\n"+
    125                     "\t--reset-preferences                       "+tr("Reset the preferences to default")+"\n\n"+
    126                     "\t--language=<language>                     "+tr("Set the language.")+"\n\n"+
    127                     tr("options provided as Java system properties")+":\n"+
    128                     "\t-Djosm.home="+tr("/PATH/TO/JOSM/FOLDER/         ")+tr("Change the folder for all user settings")+"\n\n"+
    129                     tr("note: For some tasks, JOSM needs a lot of memory. It can be necessary to add the following\n" +
    130                     "      Java option to increase the maximum size of allocated memory")+":\n"+
    131                     "\t-Xmx...m\n\n"+
    132                     tr("examples")+":\n"+
    133                     "\tjava -jar josm.jar track1.gpx track2.gpx london.osm\n"+
    134                     "\tjava -jar josm.jar http://www.openstreetmap.org/index.html?lat=43.2&lon=11.1&zoom=13\n"+
    135                     "\tjava -jar josm.jar london.osm --selection=http://www.ostertag.name/osm/OSM_errors_node-duplicate.xml\n"+
    136                     "\tjava -jar josm.jar 43.2,11.1,43.4,11.4\n"+
    137                     "\tjava -Djosm.home=/home/user/.josm_dev -jar josm.jar\n"+
    138                     "\tjava -Xmx400m -jar josm.jar\n\n"+
    139                     tr("Parameters are read in the order they are specified, so make sure you load\n"+
    140                     "some data before --selection")+"\n\n"+
    141                     tr("Instead of --download=<bbox> you may specify osm://<bbox>\n"));
     149            showHelp();
    142150            System.exit(0);
    143151        }
     
    185193    public static void removeObsoletePreferences() {
    186194        String[] obsolete = {
    187                 "sample.preference.that.does.not.exist", // sample comment, expiry date should go here
    188                 "osm-server.version", // remove this around 10/2009
    189                 "osm-server.additional-versions", // remove this around 10/2009
    190                 null
     195                "proxy.anonymous", // 01/2010 - not needed anymore. Can be removed mid 2010
     196                "proxy.enable"     // 01/2010 - not needed anymore. Can be removed mid 2010
    191197        };
    192         for (String i : obsolete) {
    193             if (i == null) {
    194                 continue;
    195             }
    196             if (Main.pref.hasKey(i)) {
    197                 Main.pref.removeFromCollection(i, Main.pref.get(i));
    198                 System.out.println(tr("Preference setting {0} has been removed since it is no longer used.", i));
     198        for (String key : obsolete) {
     199            if (Main.pref.hasKey(key)) {
     200                Main.pref.removeFromCollection(key, Main.pref.get(key));
     201                System.out.println(tr("Preference setting {0} has been removed since it is no longer used.", key));
    199202            }
    200203        }
Note: See TracChangeset for help on using the changeset viewer.