source: josm/trunk/src/org/openstreetmap/josm/tools/DontShowAgainInfo.java@ 1102

Last change on this file since 1102 was 1004, checked in by framm, 16 years ago
  • display a confirmation request if user tries to delete data outside downloaded area (can be don't-show-again'd). Note this feature is not a hard measure but needs to be actively requested by the component making the deletion, so it is possible that plugins deleting data do not honour this. Also, this currently only affects deleting, not otherwise modifying stuff outside of the box.
  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.tools;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.Container;
7import java.awt.GridBagLayout;
8
9import javax.swing.JCheckBox;
10import javax.swing.JLabel;
11import javax.swing.JOptionPane;
12import javax.swing.JPanel;
13
14import org.openstreetmap.josm.Main;
15
16public class DontShowAgainInfo {
17
18 public static boolean show(String prefKey, String msg) {
19 return show(prefKey, new JLabel(msg), true, JOptionPane.OK_CANCEL_OPTION, JOptionPane.OK_OPTION);
20 }
21
22 public static boolean show(String prefKey, String msg, Boolean state) {
23 return show(prefKey, new JLabel(msg), state, JOptionPane.OK_CANCEL_OPTION, JOptionPane.OK_OPTION);
24 }
25
26 public static boolean show(String prefKey, Container msg) {
27 return show(prefKey, msg, true, JOptionPane.OK_CANCEL_OPTION, JOptionPane.OK_OPTION);
28 }
29
30 public static boolean show(String prefKey, Container msg, Boolean state, int options, int true_option) {
31 if (!Main.pref.getBoolean("message."+prefKey)) {
32 JCheckBox dontshowagain = new JCheckBox(tr("Do not show again"));
33 dontshowagain.setSelected(Main.pref.getBoolean("message."+prefKey, state));
34 JPanel all = new JPanel(new GridBagLayout());
35 all.add(msg, GBC.eop());
36 all.add(dontshowagain, GBC.eol());
37 int answer = JOptionPane.showConfirmDialog(Main.parent, all, tr("Information"), options);
38 if (answer != true_option)
39 return false;
40 Main.pref.put("message."+prefKey, dontshowagain.isSelected());
41 }
42 return true;
43 }
44}
Note: See TracBrowser for help on using the repository browser.