Changeset 16546 in josm for trunk/src/org/openstreetmap/josm/data/osm/DataIntegrityProblemException.java
- Timestamp:
- 2020-06-07T11:36:21+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataIntegrityProblemException.java
r12036 r16546 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.osm; 3 4 import java.util.Arrays; 5 import java.util.function.Predicate; 6 import java.util.stream.Collectors; 7 import java.util.stream.Stream; 8 9 import org.openstreetmap.josm.command.Command; 10 import org.openstreetmap.josm.data.UndoRedoHandler; 3 11 4 12 /** … … 22 30 * @param message the detail message 23 31 * @param htmlMessage HTML-formatted error message. Can be null 32 * @param p the primitive involved in this integrity problem (used for constructing a detailed message) 24 33 */ 25 public DataIntegrityProblemException(String message, String htmlMessage ) {26 super(message );34 public DataIntegrityProblemException(String message, String htmlMessage, OsmPrimitive... p) { 35 super(message + relevantCommands(p)); 27 36 this.htmlMessage = htmlMessage; 28 37 } … … 35 44 return htmlMessage; 36 45 } 46 47 private static String relevantCommands(OsmPrimitive... p) { 48 if (p == null || p.length == 0) { 49 return ""; 50 } 51 Predicate<Command> isParticipating = c -> Arrays.stream(p).anyMatch(c.getParticipatingPrimitives()::contains); 52 Stream<String> undo = UndoRedoHandler.getInstance().getUndoCommands().stream() 53 .filter(isParticipating) 54 .map(c -> "[" + c.getDescriptionText() + "]"); 55 Stream<String> redo = UndoRedoHandler.getInstance().getRedoCommands().stream() 56 .filter(isParticipating) 57 .map(c -> "[" + c.getDescriptionText() + " (undone)]"); 58 return Stream.concat(undo, redo) 59 .collect(Collectors.joining(", ", " (changed by the following commands: ", ")")); 60 } 37 61 }
Note:
See TracChangeset
for help on using the changeset viewer.