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

Last change on this file since 10189 was 10183, checked in by Don-vip, 8 years ago

sonar - squid:AssignmentInSubExpressionCheck - Assignments should not be made from within sub-expressions

  • Property svn:eol-style set to native
File size: 4.0 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
17public class OsmPrivilegesPanel extends VerticallyScrollablePanel {
18
19 private final JCheckBox cbWriteApi = new JCheckBox();
20 private final JCheckBox cbWriteGpx = new JCheckBox();
21 private final JCheckBox cbReadGpx = new JCheckBox();
22 private final JCheckBox cbWritePrefs = new JCheckBox();
23 private final JCheckBox cbReadPrefs = new JCheckBox();
24 private final JCheckBox cbModifyNotes = new JCheckBox();
25
26 /**
27 * Constructs a new {@code OsmPrivilegesPanel}.
28 */
29 public OsmPrivilegesPanel() {
30 build();
31 }
32
33 protected final void build() {
34 setLayout(new GridBagLayout());
35 GridBagConstraints gc = new GridBagConstraints();
36 setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
37
38 // checkbox for "allow to upload map data"
39 //
40 gc.anchor = GridBagConstraints.NORTHWEST;
41 gc.fill = GridBagConstraints.HORIZONTAL;
42 gc.weightx = 1.0;
43 gc.insets = new Insets(0, 0, 3, 3);
44 add(cbWriteApi, gc);
45 cbWriteApi.setText(tr("Allow to upload map data"));
46 cbWriteApi.setToolTipText(tr("Select to grant JOSM the right to upload map data on your behalf"));
47 cbWriteApi.setSelected(true);
48
49 // checkbox for "allow to upload gps traces"
50 //
51 gc.gridy = 1;
52 add(cbWriteGpx, gc);
53 cbWriteGpx.setText(tr("Allow to upload GPS traces"));
54 cbWriteGpx.setToolTipText(tr("Select to grant JOSM the right to upload GPS traces on your behalf"));
55 cbWriteGpx.setSelected(true);
56
57 // checkbox for "allow to download private gps traces"
58 //
59 gc.gridy = 2;
60 add(cbReadGpx, gc);
61 cbReadGpx.setText(tr("Allow to download your private GPS traces"));
62 cbReadGpx.setToolTipText(tr("Select to grant JOSM the right to download your private GPS traces into JOSM layers"));
63 cbReadGpx.setSelected(true);
64
65 // checkbox for "allow to download private gps traces"
66 //
67 gc.gridy = 3;
68 add(cbReadPrefs, gc);
69 cbReadPrefs.setText(tr("Allow to read your preferences"));
70 cbReadPrefs.setToolTipText(tr("Select to grant JOSM the right to read your server preferences"));
71 cbReadPrefs.setSelected(true);
72
73 // checkbox for "allow to download private gps traces"
74 //
75 gc.gridy = 4;
76 add(cbWritePrefs, gc);
77 cbWritePrefs.setText(tr("Allow to write your preferences"));
78 cbWritePrefs.setToolTipText(tr("Select to grant JOSM the right to write your server preferences"));
79 cbWritePrefs.setSelected(true);
80
81 gc.gridy = 5;
82 add(cbModifyNotes, gc);
83 cbModifyNotes.setText(tr("Allow modifications of notes"));
84 cbModifyNotes.setToolTipText(tr("Select to grant JOSM the right to modify notes on your behalf"));
85 cbModifyNotes.setSelected(true);
86
87 // filler - grab remaining space
88 gc.gridy = 6;
89 gc.fill = GridBagConstraints.BOTH;
90 gc.weightx = 1.0;
91 gc.weighty = 1.0;
92 add(new JPanel(), gc);
93 }
94
95 /**
96 * Replies the currently entered privileges
97 *
98 * @return the privileges
99 */
100 public OsmPrivileges getPrivileges() {
101 OsmPrivileges privileges = new OsmPrivileges();
102 privileges.setAllowWriteApi(cbWriteApi.isSelected());
103 privileges.setAllowWriteGpx(cbWriteGpx.isSelected());
104 privileges.setAllowReadGpx(cbReadGpx.isSelected());
105 privileges.setAllowWritePrefs(cbWritePrefs.isSelected());
106 privileges.setAllowReadPrefs(cbReadPrefs.isSelected());
107 privileges.setAllowModifyNotes(cbModifyNotes.isSelected());
108 return privileges;
109 }
110}
Note: See TracBrowser for help on using the repository browser.