Changeset 745 in josm for trunk


Ignore:
Timestamp:
2008-08-04T16:51:56+02:00 (16 years ago)
Author:
stoecker
Message:

added security check for layer deletion. Fixes #262

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r744 r745  
    2222import javax.swing.JLabel;
    2323import javax.swing.JList;
     24import javax.swing.JOptionPane;
    2425import javax.swing.JPanel;
    2526import javax.swing.JScrollPane;
     
    6970                        int sel = instance.getSelectedIndex();
    7071                        Layer l = layer != null ? layer : (Layer)instance.getSelectedValue();
    71                         if (l instanceof OsmDataLayer && !DontShowAgainInfo.show("delete_layer", tr("Do you really want to delete the whole layer?")))
    72                                 return;
     72                        if (l instanceof OsmDataLayer)
     73                        {
     74                                if (((OsmDataLayer)l).isModified())
     75                                {
     76                                        if(JOptionPane.showConfirmDialog(instance, tr("There are unsaved changes. Delete the layer anwyay?"),
     77                                        tr("Unsaved Changes"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
     78                                                return;
     79                                }
     80                                else if(!DontShowAgainInfo.show("delete_layer", tr("Do you really want to delete the whole layer?"), false))
     81                                        return;
     82                        }
    7383                        Main.main.removeLayer(l);
    7484                        if (sel >= instance.getModel().getSize())
  • trunk/src/org/openstreetmap/josm/tools/DontShowAgainInfo.java

    r627 r745  
    1717
    1818        public static boolean show(String prefKey, String msg) {
    19                 return show(prefKey, new JLabel(msg));
     19                return show(prefKey, new JLabel(msg), true);
     20        }
     21
     22        public static boolean show(String prefKey, String msg, Boolean state) {
     23                return show(prefKey, new JLabel(msg), state);
    2024        }
    2125
    2226        public static boolean show(String prefKey, Container msg) {
     27                return show(prefKey, msg, true);
     28        }
     29
     30        public static boolean show(String prefKey, Container msg, Boolean state) {
    2331                if (!Main.pref.getBoolean("message."+prefKey)) {
    2432                        JCheckBox dontshowagain = new JCheckBox(tr("Do not show again"));
    25                         dontshowagain.setSelected(Main.pref.getBoolean("message."+prefKey, true));
     33                        dontshowagain.setSelected(Main.pref.getBoolean("message."+prefKey, state));
    2634                        JPanel all = new JPanel(new GridBagLayout());
    2735                        all.add(msg, GBC.eop());
Note: See TracChangeset for help on using the changeset viewer.