1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.oauth;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.GridBagConstraints;
|
---|
7 | import java.awt.GridBagLayout;
|
---|
8 | import java.awt.Insets;
|
---|
9 |
|
---|
10 | import javax.swing.BorderFactory;
|
---|
11 | import javax.swing.JCheckBox;
|
---|
12 | import javax.swing.JPanel;
|
---|
13 |
|
---|
14 | import org.openstreetmap.josm.data.oauth.OsmPrivileges;
|
---|
15 | import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
|
---|
16 |
|
---|
17 | public class OsmPrivilegesPanel extends VerticallyScrollablePanel {
|
---|
18 |
|
---|
19 | private JCheckBox cbWriteApi;
|
---|
20 | private JCheckBox cbWriteGpx;
|
---|
21 | private JCheckBox cbReadGpx;
|
---|
22 | private JCheckBox cbWritePrefs;
|
---|
23 | private JCheckBox cbReadPrefs;
|
---|
24 | private JCheckBox cbModifyNotes;
|
---|
25 |
|
---|
26 | protected final void build() {
|
---|
27 | setLayout(new GridBagLayout());
|
---|
28 | GridBagConstraints gc = new GridBagConstraints();
|
---|
29 | setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
---|
30 |
|
---|
31 | // checkbox for "allow to upload map data"
|
---|
32 | //
|
---|
33 | gc.anchor = GridBagConstraints.NORTHWEST;
|
---|
34 | gc.fill = GridBagConstraints.HORIZONTAL;
|
---|
35 | gc.weightx = 1.0;
|
---|
36 | gc.insets = new Insets(0, 0, 3, 3);
|
---|
37 | add(cbWriteApi = new JCheckBox(), gc);
|
---|
38 | cbWriteApi.setText(tr("Allow to upload map data"));
|
---|
39 | cbWriteApi.setToolTipText(tr("Select to grant JOSM the right to upload map data on your behalf"));
|
---|
40 | cbWriteApi.setSelected(true);
|
---|
41 |
|
---|
42 | // checkbox for "allow to upload gps traces"
|
---|
43 | //
|
---|
44 | gc.gridy = 1;
|
---|
45 | add(cbWriteGpx = new JCheckBox(), gc);
|
---|
46 | cbWriteGpx.setText(tr("Allow to upload GPS traces"));
|
---|
47 | cbWriteGpx.setToolTipText(tr("Select to grant JOSM the right to upload GPS traces on your behalf"));
|
---|
48 | cbWriteGpx.setSelected(true);
|
---|
49 |
|
---|
50 | // checkbox for "allow to download private gps traces"
|
---|
51 | //
|
---|
52 | gc.gridy = 2;
|
---|
53 | add(cbReadGpx = new JCheckBox(), gc);
|
---|
54 | cbReadGpx.setText(tr("Allow to download your private GPS traces"));
|
---|
55 | cbReadGpx.setToolTipText(tr("Select to grant JOSM the right to download your private GPS traces into JOSM layers"));
|
---|
56 | cbReadGpx.setSelected(true);
|
---|
57 |
|
---|
58 | // checkbox for "allow to download private gps traces"
|
---|
59 | //
|
---|
60 | gc.gridy = 3;
|
---|
61 | add(cbReadPrefs = new JCheckBox(), gc);
|
---|
62 | cbReadPrefs.setText(tr("Allow to read your preferences"));
|
---|
63 | cbReadPrefs.setToolTipText(tr("Select to grant JOSM the right to read your server preferences"));
|
---|
64 | cbReadPrefs.setSelected(true);
|
---|
65 |
|
---|
66 | // checkbox for "allow to download private gps traces"
|
---|
67 | //
|
---|
68 | gc.gridy = 4;
|
---|
69 | add(cbWritePrefs = new JCheckBox(), gc);
|
---|
70 | cbWritePrefs.setText(tr("Allow to write your preferences"));
|
---|
71 | cbWritePrefs.setToolTipText(tr("Select to grant JOSM the right to write your server preferences"));
|
---|
72 | cbWritePrefs.setSelected(true);
|
---|
73 |
|
---|
74 | gc.gridy = 5;
|
---|
75 | add(cbModifyNotes = new JCheckBox(), gc);
|
---|
76 | cbModifyNotes.setText(tr("Allow modifications of notes"));
|
---|
77 | cbModifyNotes.setToolTipText(tr("Select to grant JOSM the right to modify notes on your behalf"));
|
---|
78 | cbModifyNotes.setSelected(true);
|
---|
79 |
|
---|
80 | // filler - grab remaining space
|
---|
81 | gc.gridy = 6;
|
---|
82 | gc.fill = GridBagConstraints.BOTH;
|
---|
83 | gc.weightx = 1.0;
|
---|
84 | gc.weighty = 1.0;
|
---|
85 | add(new JPanel(), gc);
|
---|
86 | }
|
---|
87 |
|
---|
88 | /**
|
---|
89 | * Constructs a new {@code OsmPrivilegesPanel}.
|
---|
90 | */
|
---|
91 | public OsmPrivilegesPanel() {
|
---|
92 | build();
|
---|
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 | }
|
---|