source: josm/trunk/src/org/openstreetmap/josm/gui/oauth/OsmPrivilegesPanel.java@ 14206

Last change on this file since 14206 was 12646, checked in by bastiK, 7 years ago

see #14794 - javadoc

  • Property svn:eol-style set to native
File size: 4.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.oauth;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.GridBagConstraints;
7import java.awt.GridBagLayout;
8import java.awt.Insets;
9
10import javax.swing.BorderFactory;
11import javax.swing.JCheckBox;
12import javax.swing.JPanel;
13
14import org.openstreetmap.josm.data.oauth.OsmPrivileges;
15import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
16
17/**
18 * Panel letting the user choose from a detailed list of privileges that will be
19 * requested for the OAuth token.
20 */
21public class OsmPrivilegesPanel extends VerticallyScrollablePanel {
22
23 private final JCheckBox cbWriteApi = new JCheckBox();
24 private final JCheckBox cbWriteGpx = new JCheckBox();
25 private final JCheckBox cbReadGpx = new JCheckBox();
26 private final JCheckBox cbWritePrefs = new JCheckBox();
27 private final JCheckBox cbReadPrefs = new JCheckBox();
28 private final JCheckBox cbModifyNotes = new JCheckBox();
29
30 /**
31 * Constructs a new {@code OsmPrivilegesPanel}.
32 */
33 public OsmPrivilegesPanel() {
34 build();
35 }
36
37 protected final void build() {
38 setLayout(new GridBagLayout());
39 GridBagConstraints gc = new GridBagConstraints();
40 setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
41
42 // checkbox for "allow to upload map data"
43 //
44 gc.anchor = GridBagConstraints.NORTHWEST;
45 gc.fill = GridBagConstraints.HORIZONTAL;
46 gc.weightx = 1.0;
47 gc.insets = new Insets(0, 0, 3, 3);
48 add(cbWriteApi, gc);
49 cbWriteApi.setText(tr("Allow to upload map data"));
50 cbWriteApi.setToolTipText(tr("Select to grant JOSM the right to upload map data on your behalf"));
51 cbWriteApi.setSelected(true);
52
53 // checkbox for "allow to upload gps traces"
54 //
55 gc.gridy = 1;
56 add(cbWriteGpx, gc);
57 cbWriteGpx.setText(tr("Allow to upload GPS traces"));
58 cbWriteGpx.setToolTipText(tr("Select to grant JOSM the right to upload GPS traces on your behalf"));
59 cbWriteGpx.setSelected(true);
60
61 // checkbox for "allow to download private gps traces"
62 //
63 gc.gridy = 2;
64 add(cbReadGpx, gc);
65 cbReadGpx.setText(tr("Allow to download your private GPS traces"));
66 cbReadGpx.setToolTipText(tr("Select to grant JOSM the right to download your private GPS traces into JOSM layers"));
67 cbReadGpx.setSelected(true);
68
69 // checkbox for "allow to download private gps traces"
70 //
71 gc.gridy = 3;
72 add(cbReadPrefs, gc);
73 cbReadPrefs.setText(tr("Allow to read your preferences"));
74 cbReadPrefs.setToolTipText(tr("Select to grant JOSM the right to read your server preferences"));
75 cbReadPrefs.setSelected(true);
76
77 // checkbox for "allow to download private gps traces"
78 //
79 gc.gridy = 4;
80 add(cbWritePrefs, gc);
81 cbWritePrefs.setText(tr("Allow to write your preferences"));
82 cbWritePrefs.setToolTipText(tr("Select to grant JOSM the right to write your server preferences"));
83 cbWritePrefs.setSelected(true);
84
85 gc.gridy = 5;
86 add(cbModifyNotes, gc);
87 cbModifyNotes.setText(tr("Allow modifications of notes"));
88 cbModifyNotes.setToolTipText(tr("Select to grant JOSM the right to modify notes on your behalf"));
89 cbModifyNotes.setSelected(true);
90
91 // filler - grab remaining space
92 gc.gridy = 6;
93 gc.fill = GridBagConstraints.BOTH;
94 gc.weightx = 1.0;
95 gc.weighty = 1.0;
96 add(new JPanel(), gc);
97 }
98
99 /**
100 * Replies the currently entered privileges
101 *
102 * @return the privileges
103 */
104 public OsmPrivileges getPrivileges() {
105 OsmPrivileges privileges = new OsmPrivileges();
106 privileges.setAllowWriteApi(cbWriteApi.isSelected());
107 privileges.setAllowWriteGpx(cbWriteGpx.isSelected());
108 privileges.setAllowReadGpx(cbReadGpx.isSelected());
109 privileges.setAllowWritePrefs(cbWritePrefs.isSelected());
110 privileges.setAllowReadPrefs(cbReadPrefs.isSelected());
111 privileges.setAllowModifyNotes(cbModifyNotes.isSelected());
112 return privileges;
113 }
114}
Note: See TracBrowser for help on using the repository browser.