Changeset 16561 in josm for trunk


Ignore:
Timestamp:
2020-06-07T17:32:46+02:00 (4 years ago)
Author:
simon04
Message:

fix #14701 - Confirm relation duplicate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/relation/DuplicateRelationAction.java

    r14241 r16561  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.GridBagLayout;
    67import java.awt.event.ActionEvent;
    78
     9import javax.swing.JOptionPane;
     10import javax.swing.JPanel;
     11
     12import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
    813import org.openstreetmap.josm.data.osm.IRelation;
    914import org.openstreetmap.josm.data.osm.Relation;
     15import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
    1016import org.openstreetmap.josm.gui.MainApplication;
    1117import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
     18import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    1219import org.openstreetmap.josm.tools.ImageProvider;
    1320
     
    3239     */
    3340    public static void duplicateRelationAndLaunchEditor(Relation original) {
     41        if (!confirmRelationDuplicate(original)) {
     42            return;
     43        }
    3444        Relation copy = new Relation(original, true);
    3545        copy.setModified(true);
     
    6272                && isEditableRelation(relations.iterator().next()));
    6373    }
     74
     75    private static boolean confirmRelationDuplicate(Relation relation) {
     76        JPanel msg = new JPanel(new GridBagLayout());
     77        msg.add(new JMultilineLabel("<html>" + tr(
     78                "You are about to duplicate {0} relation: {1}"
     79                        + "<br/>"
     80                        + "This step is rarely necessary. Do you really want to duplicate?",
     81                1, DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(relation))
     82                + "</html>"));
     83        return ConditionalOptionPaneUtil.showConfirmationDialog(
     84                "delete_relations",
     85                MainApplication.getMainFrame(),
     86                msg,
     87                tr("Duplicate relation?"),
     88                JOptionPane.YES_NO_OPTION,
     89                JOptionPane.QUESTION_MESSAGE,
     90                JOptionPane.YES_OPTION);
     91    }
    6492}
Note: See TracChangeset for help on using the changeset viewer.