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