1 | package org.openstreetmap.josm.tools;
|
---|
2 |
|
---|
3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
4 |
|
---|
5 | import java.awt.Container;
|
---|
6 | import java.awt.GridBagLayout;
|
---|
7 |
|
---|
8 | import javax.swing.JCheckBox;
|
---|
9 | import javax.swing.JLabel;
|
---|
10 | import javax.swing.JOptionPane;
|
---|
11 | import javax.swing.JPanel;
|
---|
12 |
|
---|
13 | import org.openstreetmap.josm.Main;
|
---|
14 |
|
---|
15 | public class DontShowAgainInfo {
|
---|
16 |
|
---|
17 | public static boolean show(String prefKey, String msg) {
|
---|
18 | return show(prefKey, new JLabel(msg));
|
---|
19 | }
|
---|
20 |
|
---|
21 | public static boolean show(String prefKey, Container msg) {
|
---|
22 | if (!Main.pref.getBoolean("message."+prefKey)) {
|
---|
23 | JCheckBox dontshowagain = new JCheckBox(tr("Do not show again"));
|
---|
24 | dontshowagain.setSelected(Main.pref.getBoolean("message."+prefKey, true));
|
---|
25 | JPanel all = new JPanel(new GridBagLayout());
|
---|
26 | all.add(msg, GBC.eop());
|
---|
27 | all.add(dontshowagain, GBC.eol());
|
---|
28 | int answer = JOptionPane.showConfirmDialog(Main.parent, all, tr("Information"), JOptionPane.OK_CANCEL_OPTION);
|
---|
29 | if (answer != JOptionPane.OK_OPTION)
|
---|
30 | return false;
|
---|
31 | Main.pref.put("message."+prefKey, dontshowagain.isSelected());
|
---|
32 | }
|
---|
33 | return true;
|
---|
34 | }
|
---|
35 | }
|
---|