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 |
|
---|
25 | protected void build() {
|
---|
26 | setLayout(new GridBagLayout());
|
---|
27 | GridBagConstraints gc = new GridBagConstraints();
|
---|
28 | setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
29 |
|
---|
30 | // checkbox for "allow to upload map data"
|
---|
31 | //
|
---|
32 | gc.anchor = GridBagConstraints.NORTHWEST;
|
---|
33 | gc.fill = GridBagConstraints.HORIZONTAL;
|
---|
34 | gc.weightx = 1.0;
|
---|
35 | gc.insets = new Insets(0,0,3,3);
|
---|
36 | add(cbWriteApi = new JCheckBox(), gc);
|
---|
37 | cbWriteApi.setText(tr("Allow to upload map data"));
|
---|
38 | cbWriteApi.setToolTipText(tr("Select to grant JOSM the right to upload map data on your behalf"));
|
---|
39 | cbWriteApi.setSelected(true);
|
---|
40 |
|
---|
41 | // checkbox for "allow to upload gps traces"
|
---|
42 | //
|
---|
43 | gc.gridy = 1;
|
---|
44 | add(cbWriteGpx = new JCheckBox(), gc);
|
---|
45 | cbWriteGpx.setText(tr("Allow to upload GPS traces"));
|
---|
46 | cbWriteGpx.setToolTipText(tr("Select to grant JOSM the right to upload GPS traces on your behalf"));
|
---|
47 | cbWriteGpx.setSelected(true);
|
---|
48 |
|
---|
49 | // checkbox for "allow to download private gps traces"
|
---|
50 | //
|
---|
51 | gc.gridy = 2;
|
---|
52 | add(cbReadGpx = new JCheckBox(), gc);
|
---|
53 | cbReadGpx.setText(tr("Allow to download your private GPS traces"));
|
---|
54 | cbReadGpx.setToolTipText(tr("Select to grant JOSM the right to download your private GPS traces into JOSM layers"));
|
---|
55 | cbReadGpx.setSelected(true);
|
---|
56 |
|
---|
57 | // checkbox for "allow to download private gps traces"
|
---|
58 | //
|
---|
59 | gc.gridy = 3;
|
---|
60 | add(cbReadPrefs = new JCheckBox(), gc);
|
---|
61 | cbReadPrefs.setText(tr("Allow to read your preferences"));
|
---|
62 | cbReadPrefs.setToolTipText(tr("Select to grant JOSM the right to read your server preferences"));
|
---|
63 | cbReadPrefs.setSelected(true);
|
---|
64 |
|
---|
65 | // checkbox for "allow to download private gps traces"
|
---|
66 | //
|
---|
67 | gc.gridy = 4;
|
---|
68 | add(cbWritePrefs = new JCheckBox(), gc);
|
---|
69 | cbWritePrefs.setText(tr("Allow to write your preferences"));
|
---|
70 | cbWritePrefs.setToolTipText(tr("Select to grant JOSM the right to write your server preferences"));
|
---|
71 | cbWritePrefs.setSelected(true);
|
---|
72 |
|
---|
73 | // filler - grab remaining space
|
---|
74 | gc.gridy = 5;
|
---|
75 | gc.fill = GridBagConstraints.BOTH;
|
---|
76 | gc.weightx = 1.0;
|
---|
77 | gc.weighty = 1.0;
|
---|
78 | add(new JPanel(), gc);
|
---|
79 | }
|
---|
80 |
|
---|
81 | public OsmPrivilegesPanel() {
|
---|
82 | build();
|
---|
83 | }
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * Replies the currently entered privileges
|
---|
87 | *
|
---|
88 | * @return the privileges
|
---|
89 | */
|
---|
90 | public OsmPrivileges getPrivileges() {
|
---|
91 | OsmPrivileges privileges = new OsmPrivileges();
|
---|
92 | privileges.setAllowWriteApi(cbWriteApi.isSelected());
|
---|
93 | privileges.setAllowWriteGpx(cbWriteGpx.isSelected());
|
---|
94 | privileges.setAllowReadGpx(cbReadGpx.isSelected());
|
---|
95 | privileges.setAllowWritePrefs(cbWritePrefs.isSelected());
|
---|
96 | privileges.setAllowReadPrefs(cbReadPrefs.isSelected());
|
---|
97 | return privileges;
|
---|
98 | }
|
---|
99 | }
|
---|