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

Last change on this file since 5085 was 5085, checked in by simon04, 12 years ago

fix #5824 - remotecontrol: add command for opening local files + refactoring of permission preference

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