Ignore:
Timestamp:
2020-03-19T22:48:47+01:00 (4 years ago)
Author:
Don-vip
Message:

see #5710 - code refactor to ease a potential fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r15333 r16177  
    593593
    594594        if (mode == Mode.MOVE && e.getButton() == MouseEvent.BUTTON1) {
     595            DataSet ds = getLayerManager().getEditDataSet();
    595596            if (!didMouseDrag) {
    596597                // only built in move mode
     
    603604
    604605                    // If the user double-clicked a node, change to draw mode
    605                     Collection<OsmPrimitive> c = getLayerManager().getEditDataSet().getSelected();
     606                    Collection<OsmPrimitive> c = ds.getSelected();
    606607                    if (e.getClickCount() >= 2 && c.size() == 1 && c.iterator().next() instanceof Node) {
    607608                        // We need to do it like this as otherwise drawAction will see a double
     
    700701        Collection<OsmPrimitive> selection = ds.getSelectedNodesAndWays();
    701702        if (selection.isEmpty()) { // if nothing was selected to drag, just select nearest node/way to the cursor
    702             OsmPrimitive nearestPrimitive = mv.getNearestNodeOrWay(mv.getPoint(startEN), mv.isSelectablePredicate, true);
    703             ds.setSelected(nearestPrimitive);
     703            ds.setSelected(mv.getNearestNodeOrWay(mv.getPoint(startEN), mv.isSelectablePredicate, true));
    704704        }
    705705
     
    829829    private void confirmOrUndoMovement(MouseEvent e) {
    830830        if (movesHiddenWay()) {
    831             final ExtendedDialog ed = new ConfirmMoveDialog();
     831            final ConfirmMoveDialog ed = new ConfirmMoveDialog();
    832832            ed.setContent(tr("Are you sure that you want to move elements with attached ways that are hidden by filters?"));
    833833            ed.toggleEnable("movedHiddenElements");
    834             ed.showDialog();
    835             if (ed.getValue() != 1) {
    836                 UndoRedoHandler.getInstance().undo();
    837             }
     834            showConfirmMoveDialog(ed);
    838835        }
    839836        Set<Node> nodes = new HashSet<>();
     
    850847        }
    851848        if (nodes.size() > max) {
    852             final ExtendedDialog ed = new ConfirmMoveDialog();
     849            final ConfirmMoveDialog ed = new ConfirmMoveDialog();
    853850            ed.setContent(
    854851                    /* for correct i18n of plural forms - see #9110 */
     
    857854                        max, max));
    858855            ed.toggleEnable("movedManyElements");
    859             ed.showDialog();
    860 
    861             if (ed.getValue() != 1) {
    862                 UndoRedoHandler.getInstance().undo();
    863             }
     856            showConfirmMoveDialog(ed);
    864857        } else {
    865858            // if small number of elements were moved,
    866859            updateKeyModifiers(e);
    867860            if (ctrl) mergePrims(e.getPoint());
     861        }
     862    }
     863
     864    private void showConfirmMoveDialog(ConfirmMoveDialog ed) {
     865        if (ed.showDialog().getValue() != 1) {
     866            UndoRedoHandler.getInstance().undo();
    868867        }
    869868    }
Note: See TracChangeset for help on using the changeset viewer.