Changeset 10948 in josm


Ignore:
Timestamp:
2016-09-03T22:29:48+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #13491 - fix EDT violation (patch by Gerd Petermann, modified)

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/Command.java

    r10663 r10948  
    4242public abstract class Command implements PseudoCommand {
    4343
     44    /** IS_OK : operation is okay */
     45    public static final int IS_OK = 0;
     46    /** IS_OUTSIDE : operation on element outside of download area */
     47    public static final int IS_OUTSIDE = 1;
     48    /** IS_INCOMPLETE: operation on incomplete target */
     49    public static final int IS_INCOMPLETE = 2;
     50
    4451    private static final class CloneVisitor extends AbstractVisitor {
    4552        public final Map<OsmPrimitive, PrimitiveData> orig = new LinkedHashMap<>();
     
    245252    /**
    246253     * Check whether user is about to operate on data outside of the download area.
     254     *
     255     * @param operation the operation name which is used for setting some preferences
     256     * @param primitives the primitives to operate on
     257     * @param ignore {@code null} or a primitive to be ignored
     258     * @return true, if operating on outlying primitives is OK; false, otherwise
     259     */
     260    public static int checkOutlyingOrIncompleteOperation(String operation,
     261            Collection<? extends OsmPrimitive> primitives,
     262            Collection<? extends OsmPrimitive> ignore) {
     263        int res = 0;
     264        for (OsmPrimitive osm : primitives) {
     265            if (osm.isIncomplete()) {
     266                res |= IS_INCOMPLETE;
     267            } else if (osm.isOutsideDownloadArea()
     268                    && (ignore == null || !ignore.contains(osm))) {
     269                res |= IS_OUTSIDE;
     270            }
     271        }
     272        return res;
     273    }
     274
     275    /**
     276     * Check whether user is about to operate on data outside of the download area.
    247277     * Request confirmation if he is.
    248278     *
     
    259289            Collection<? extends OsmPrimitive> primitives,
    260290            Collection<? extends OsmPrimitive> ignore) {
    261         boolean outside = false;
    262         boolean incomplete = false;
    263         for (OsmPrimitive osm : primitives) {
    264             if (osm.isIncomplete()) {
    265                 incomplete = true;
    266             } else if (osm.isOutsideDownloadArea()
    267                     && (ignore == null || !ignore.contains(osm))) {
    268                 outside = true;
    269             }
    270         }
    271         if (outside) {
     291        int checkRes = checkOutlyingOrIncompleteOperation(operation, primitives, ignore);
     292        if ((checkRes & IS_OUTSIDE) != 0) {
    272293            JPanel msg = new JPanel(new GridBagLayout());
    273294            msg.add(new JMultilineLabel("<html>" + outsideDialogMessage + "</html>"));
     
    283304                return false;
    284305        }
    285         if (incomplete) {
     306        if ((checkRes & IS_INCOMPLETE) != 0) {
    286307            JPanel msg = new JPanel(new GridBagLayout());
    287308            msg.add(new JMultilineLabel("<html>" + incompleteDialogMessage + "</html>"));
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java

    r10924 r10948  
    2121import org.openstreetmap.josm.actions.MergeNodesAction;
    2222import org.openstreetmap.josm.command.Command;
    23 import org.openstreetmap.josm.command.DeleteCommand;
    2423import org.openstreetmap.josm.data.coor.LatLon;
    2524import org.openstreetmap.josm.data.osm.Hash;
     
    408407            }
    409408
    410             if (DeleteCommand.checkAndConfirmOutlyingDelete(nodes, Collections.singleton(target)))
     409            if (Command.checkOutlyingOrIncompleteOperation("delete", nodes, Collections.singleton(target)) == Command.IS_OK)
    411410                return MergeNodesAction.mergeNodes(Main.getLayerManager().getEditLayer(), nodes, target);
    412411        }
Note: See TracChangeset for help on using the changeset viewer.