Changeset 8814 in josm for trunk


Ignore:
Timestamp:
2015-10-01T21:31:05+02:00 (9 years ago)
Author:
simon04
Message:

fix #11656 - Use notifications when (one click) presets cannot be applied

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r8811 r8814  
    2626import javax.swing.ImageIcon;
    2727import javax.swing.JLabel;
     28import javax.swing.JOptionPane;
    2829import javax.swing.JPanel;
    2930import javax.swing.JToggleButton;
     
    4344import org.openstreetmap.josm.gui.ExtendedDialog;
    4445import org.openstreetmap.josm.gui.MapView;
     46import org.openstreetmap.josm.gui.Notification;
    4547import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
    4648import org.openstreetmap.josm.gui.layer.Layer;
     
    377379
    378380        int answer = 1;
    379         if (p.getComponentCount() != 0 && (sel.isEmpty() || p.hasElements)) {
     381        boolean canCreateRelation = types == null || types.contains(TaggingPresetType.RELATION);
     382        if (originalSelectionEmpty && !canCreateRelation) {
     383            new Notification(
     384                    tr("The preset <i>{0}</i> cannot be applied since nothing has been selected!", getLocaleName()))
     385                    .setIcon(JOptionPane.WARNING_MESSAGE)
     386                    .show();
     387            return DIALOG_ANSWER_CANCEL;
     388        } else if (sel.isEmpty() && !canCreateRelation) {
     389            new Notification(
     390                    tr("The preset <i>{0}</i> cannot be applied since the selection is unsuitable!", getLocaleName()))
     391                    .setIcon(JOptionPane.WARNING_MESSAGE)
     392                    .show();
     393            return DIALOG_ANSWER_CANCEL;
     394        } else if (p.getComponentCount() != 0 && (sel.isEmpty() || p.hasElements)) {
    380395            String title = trn("Change {0} object", "Change {0} objects", sel.size(), sel.size());
    381396            if (sel.isEmpty()) {
Note: See TracChangeset for help on using the changeset viewer.