source: josm/trunk/src/org/openstreetmap/josm/io/remotecontrol/PermissionPrefWithDefault.java@ 13228

Last change on this file since 13228 was 12846, checked in by bastiK, 7 years ago

see #15229 - use Config.getPref() wherever possible

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io.remotecontrol;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.Arrays;
7import java.util.List;
8
9import org.openstreetmap.josm.spi.preferences.Config;
10
11/**
12 * Contains a preference name to control permission for the operation
13 * implemented by the RequestHandler, and an error message to be displayed if
14 * not permitted.
15 *
16 * @author Bodo Meissner
17 */
18public class PermissionPrefWithDefault {
19
20 public static final PermissionPrefWithDefault LOAD_DATA =
21 new PermissionPrefWithDefault("remotecontrol.permission.load-data", true, tr("Load data from API"));
22 public static final PermissionPrefWithDefault IMPORT_DATA =
23 new PermissionPrefWithDefault("remotecontrol.permission.import", true, tr("Import data from URL"));
24 public static final PermissionPrefWithDefault OPEN_FILES =
25 new PermissionPrefWithDefault("remotecontrol.permission.open-files", false, tr("Open local files"));
26 public static final PermissionPrefWithDefault LOAD_IMAGERY =
27 new PermissionPrefWithDefault("remotecontrol.permission.imagery", true, tr("Load imagery layers"));
28 public static final PermissionPrefWithDefault CHANGE_SELECTION =
29 new PermissionPrefWithDefault("remotecontrol.permission.change-selection", true, tr("Change the selection"));
30 public static final PermissionPrefWithDefault CHANGE_VIEWPORT =
31 new PermissionPrefWithDefault("remotecontrol.permission.change-viewport", true, tr("Change the viewport"));
32 public static final PermissionPrefWithDefault CREATE_OBJECTS =
33 new PermissionPrefWithDefault("remotecontrol.permission.create-objects", true, tr("Create new objects"));
34 public static final PermissionPrefWithDefault READ_PROTOCOL_VERSION =
35 new PermissionPrefWithDefault("remotecontrol.permission.read-protocolversion", true, tr("Read protocol version"));
36 /**
37 * name of the preference setting to permit the remote operation
38 */
39 public final String pref;
40 /**
41 * default preference setting
42 */
43 public final boolean defaultVal;
44 /**
45 * text for the preference dialog checkbox
46 */
47 public final String preferenceText;
48
49 public PermissionPrefWithDefault(String pref, boolean defaultVal, String preferenceText) {
50 this.pref = pref;
51 this.defaultVal = defaultVal;
52 this.preferenceText = preferenceText;
53 }
54
55 public boolean isAllowed() {
56 return Config.getPref().getBoolean(pref, defaultVal);
57 }
58
59 public static List<PermissionPrefWithDefault> getPermissionPrefs() {
60 return Arrays.asList(
61 LOAD_DATA, IMPORT_DATA, OPEN_FILES, LOAD_IMAGERY,
62 CHANGE_SELECTION, CHANGE_VIEWPORT,
63 CREATE_OBJECTS, READ_PROTOCOL_VERSION);
64 }
65}
Note: See TracBrowser for help on using the repository browser.