Changeset 12760 in josm for trunk/src/org/openstreetmap/josm/actions/DeleteAction.java
- Timestamp:
- 2017-09-06T17:27:26+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/DeleteAction.java
r12749 r12760 4 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 import static org.openstreetmap.josm.tools.I18n.trn; 6 7 8 import java.awt.GridBagLayout; 7 9 import java.awt.event.ActionEvent; 8 10 import java.awt.event.KeyEvent; 9 11 import java.util.Collection; 10 12 13 import javax.swing.JOptionPane; 14 import javax.swing.JPanel; 15 16 import org.openstreetmap.josm.Main; 17 import org.openstreetmap.josm.command.DeleteCommand.DeletionCallback; 18 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 11 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 import org.openstreetmap.josm.data.osm.Relation; 21 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 12 22 import org.openstreetmap.josm.gui.MainApplication; 13 23 import org.openstreetmap.josm.gui.MapFrame; 24 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; 14 25 import org.openstreetmap.josm.tools.Shortcut; 15 26 … … 19 30 */ 20 31 public final class DeleteAction extends JosmAction { 32 33 /** 34 * The default {@link DeletionCallback} for {@code DeleteCommand}. 35 * @since 12760 36 */ 37 public static final DeletionCallback defaultDeletionCallback = new DeletionCallback() { 38 @Override 39 public boolean checkAndConfirmOutlyingDelete(Collection<? extends OsmPrimitive> primitives, 40 Collection<? extends OsmPrimitive> ignore) { 41 return checkAndConfirmOutlyingDelete(primitives, ignore); 42 } 43 44 @Override 45 public boolean confirmRelationDeletion(Collection<Relation> relations) { 46 return confirmRelationDeletion(relations); 47 } 48 }; 21 49 22 50 /** … … 70 98 primitives, ignore); 71 99 } 100 101 /** 102 * Confirm before deleting a relation, as it is a common newbie error. 103 * @param relations relation to check for deletion 104 * @return {@code true} if user confirms the deletion 105 * @since 12760 106 */ 107 public static boolean confirmRelationDeletion(Collection<Relation> relations) { 108 JPanel msg = new JPanel(new GridBagLayout()); 109 msg.add(new JMultilineLabel("<html>" + trn( 110 "You are about to delete {0} relation: {1}" 111 + "<br/>" 112 + "This step is rarely necessary and cannot be undone easily after being uploaded to the server." 113 + "<br/>" 114 + "Do you really want to delete?", 115 "You are about to delete {0} relations: {1}" 116 + "<br/>" 117 + "This step is rarely necessary and cannot be undone easily after being uploaded to the server." 118 + "<br/>" 119 + "Do you really want to delete?", 120 relations.size(), relations.size(), DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(relations, 20)) 121 + "</html>")); 122 return ConditionalOptionPaneUtil.showConfirmationDialog( 123 "delete_relations", 124 Main.parent, 125 msg, 126 tr("Delete relation?"), 127 JOptionPane.YES_NO_OPTION, 128 JOptionPane.QUESTION_MESSAGE, 129 JOptionPane.YES_OPTION); 130 } 72 131 }
Note:
See TracChangeset
for help on using the changeset viewer.