Changeset 15507 in josm for trunk/src/org


Ignore:
Timestamp:
2019-11-04T22:12:14+01:00 (5 years ago)
Author:
Don-vip
Message:

fix #18292 - Initialize pref list for remote control (patch by taylor.smock)

Location:
trunk/src/org/openstreetmap/josm/io/remotecontrol
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/PermissionPrefWithDefault.java

    r15500 r15507  
    7676     */
    7777    public static List<PermissionPrefWithDefault> getPermissionPrefs() {
     78        if (PREFS.isEmpty())
     79            RequestProcessor.initialize();
    7880        return Collections.unmodifiableList(PREFS);
    7981    }
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java

    r15500 r15507  
    7474    private static Map<String, Class<? extends RequestHandler>> handlers = new TreeMap<>();
    7575
     76    static {
     77        initialize();
     78    }
     79
    7680    /**
    7781     * Constructor
     
    138142
    139143    /**
    140      * Add default request handlers and permission preferences (order is important)
    141      */
    142     static {
    143         addRequestHandlerClass(LoadAndZoomHandler.command, LoadAndZoomHandler.class, true);
    144         addRequestHandlerClass(LoadAndZoomHandler.command2, LoadAndZoomHandler.class, true);
    145         addRequestHandlerClass(LoadObjectHandler.command, LoadObjectHandler.class, true);
    146         addRequestHandlerClass(LoadDataHandler.command, LoadDataHandler.class, true);
    147         addRequestHandlerClass(ImportHandler.command, ImportHandler.class, true);
    148         addRequestHandlerClass(OpenFileHandler.command, OpenFileHandler.class, true);
    149         addRequestHandlerClass(ImageryHandler.command, ImageryHandler.class, true);
    150         PermissionPrefWithDefault.addPermissionPref(PermissionPrefWithDefault.CHANGE_SELECTION);
    151         PermissionPrefWithDefault.addPermissionPref(PermissionPrefWithDefault.CHANGE_VIEWPORT);
    152         addRequestHandlerClass(AddNodeHandler.command, AddNodeHandler.class, true);
    153         addRequestHandlerClass(AddWayHandler.command, AddWayHandler.class, true);
    154         addRequestHandlerClass(VersionHandler.command, VersionHandler.class, true);
    155         addRequestHandlerClass(FeaturesHandler.command, FeaturesHandler.class, true);
     144     * Force the class to initialize and load the handlers
     145     */
     146    public static void initialize() {
     147        if (handlers.isEmpty()) {
     148            addRequestHandlerClass(LoadAndZoomHandler.command, LoadAndZoomHandler.class, true);
     149            addRequestHandlerClass(LoadAndZoomHandler.command2, LoadAndZoomHandler.class, true);
     150            addRequestHandlerClass(LoadObjectHandler.command, LoadObjectHandler.class, true);
     151            addRequestHandlerClass(LoadDataHandler.command, LoadDataHandler.class, true);
     152            addRequestHandlerClass(ImportHandler.command, ImportHandler.class, true);
     153            addRequestHandlerClass(OpenFileHandler.command, OpenFileHandler.class, true);
     154            addRequestHandlerClass(ImageryHandler.command, ImageryHandler.class, true);
     155            PermissionPrefWithDefault.addPermissionPref(PermissionPrefWithDefault.CHANGE_SELECTION);
     156            PermissionPrefWithDefault.addPermissionPref(PermissionPrefWithDefault.CHANGE_VIEWPORT);
     157            addRequestHandlerClass(AddNodeHandler.command, AddNodeHandler.class, true);
     158            addRequestHandlerClass(AddWayHandler.command, AddWayHandler.class, true);
     159            addRequestHandlerClass(VersionHandler.command, VersionHandler.class, true);
     160            addRequestHandlerClass(FeaturesHandler.command, FeaturesHandler.class, true);
     161        }
    156162    }
    157163
Note: See TracChangeset for help on using the changeset viewer.