- Timestamp:
- 2017-09-06T17:27:26+02:00 (7 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/TagInfoExtract.groovy
r12752 r12760 386 386 tmpdir.toFile().deleteOnExit() 387 387 System.setProperty("josm.home", tmpdir.toString()) 388 DeleteCommand.setDeletionCallback(DeleteAction. &checkAndConfirmOutlyingDelete)388 DeleteCommand.setDeletionCallback(DeleteAction.defaultDeletionCallback) 389 389 Territories.initialize() 390 390 RightAndLefthandTraffic.initialize() -
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 } -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r12749 r12760 6 6 import static org.openstreetmap.josm.tools.I18n.trn; 7 7 8 import java.awt.GridBagLayout;9 8 import java.util.ArrayList; 10 9 import java.util.Arrays; … … 22 21 23 22 import javax.swing.Icon; 24 import javax.swing.JOptionPane; 25 import javax.swing.JPanel; 26 27 import org.openstreetmap.josm.Main; 23 28 24 import org.openstreetmap.josm.actions.SplitWayAction; 29 25 import org.openstreetmap.josm.actions.SplitWayAction.SplitWayResult; … … 38 34 import org.openstreetmap.josm.data.osm.Way; 39 35 import org.openstreetmap.josm.data.osm.WaySegment; 40 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;41 36 import org.openstreetmap.josm.gui.dialogs.DeleteFromRelationConfirmationDialog; 42 37 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 43 import org.openstreetmap.josm.gui.widgets.JMultilineLabel;44 38 import org.openstreetmap.josm.tools.CheckParameterUtil; 45 39 import org.openstreetmap.josm.tools.ImageProvider; … … 83 77 * @since 12749 84 78 */ 85 @FunctionalInterface86 79 public interface DeletionCallback { 87 80 /** … … 93 86 */ 94 87 boolean checkAndConfirmOutlyingDelete(Collection<? extends OsmPrimitive> primitives, Collection<? extends OsmPrimitive> ignore); 88 89 /** 90 * Confirm before deleting a relation, as it is a common newbie error. 91 * @param relations relation to check for deletion 92 * @return {@code true} if user confirms the deletion 93 * @since 12760 94 */ 95 boolean confirmRelationDeletion(Collection<Relation> relations); 95 96 } 96 97 … … 545 546 546 547 Collection<Relation> relationsToDelete = Utils.filteredCollection(primitivesToDelete, Relation.class); 547 if (!relationsToDelete.isEmpty() && !silent && !c onfirmRelationDeletion(relationsToDelete))548 if (!relationsToDelete.isEmpty() && !silent && !callback.confirmRelationDeletion(relationsToDelete)) 548 549 return null; 549 550 … … 658 659 } 659 660 660 private static boolean confirmRelationDeletion(Collection<Relation> relations) {661 JPanel msg = new JPanel(new GridBagLayout());662 msg.add(new JMultilineLabel("<html>" + trn(663 "You are about to delete {0} relation: {1}"664 + "<br/>"665 + "This step is rarely necessary and cannot be undone easily after being uploaded to the server."666 + "<br/>"667 + "Do you really want to delete?",668 "You are about to delete {0} relations: {1}"669 + "<br/>"670 + "This step is rarely necessary and cannot be undone easily after being uploaded to the server."671 + "<br/>"672 + "Do you really want to delete?",673 relations.size(), relations.size(), DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(relations, 20))674 + "</html>"));675 return ConditionalOptionPaneUtil.showConfirmationDialog(676 "delete_relations",677 Main.parent,678 msg,679 tr("Delete relation?"),680 JOptionPane.YES_NO_OPTION,681 JOptionPane.QUESTION_MESSAGE,682 JOptionPane.YES_OPTION);683 }684 685 661 @Override 686 662 public int hashCode() { -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r12755 r12760 968 968 969 969 static void setupCallbacks() { 970 DeleteCommand.setDeletionCallback(DeleteAction ::checkAndConfirmOutlyingDelete);970 DeleteCommand.setDeletionCallback(DeleteAction.defaultDeletionCallback); 971 971 } 972 972 -
trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java
r12757 r12760 128 128 129 129 // Setup callbacks 130 DeleteCommand.setDeletionCallback(DeleteAction ::checkAndConfirmOutlyingDelete);130 DeleteCommand.setDeletionCallback(DeleteAction.defaultDeletionCallback); 131 131 132 132 if (createGui) { -
trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
r12751 r12760 272 272 User.clearUserMap(); 273 273 // Setup callbacks 274 DeleteCommand.setDeletionCallback(DeleteAction ::checkAndConfirmOutlyingDelete);274 DeleteCommand.setDeletionCallback(DeleteAction.defaultDeletionCallback); 275 275 276 276 // Set up i18n
Note:
See TracChangeset
for help on using the changeset viewer.