Ignore:
Timestamp:
2016-06-24T00:30:42+02:00 (9 years ago)
Author:
Don-vip
Message:

fix #13037 - Small fixes for unit tests (patch by michael2402) - gsoc-core

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
15 edited

Legend:

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

    r10382 r10467  
    6666        Main.main.undoRedo.add(new AddCommand(nnew));
    6767        getLayerManager().getEditDataSet().setSelected(nnew);
    68         if (Main.map.mapView.getRealBounds().contains(nnew.getCoor())) {
    69             Main.map.mapView.repaint();
    70         } else {
    71             AutoScaleAction.zoomTo(Collections.<OsmPrimitive>singleton(nnew));
     68        if (Main.map.mapView != null) {
     69            if (Main.map.mapView.getRealBounds().contains(nnew.getCoor())) {
     70                Main.map.mapView.repaint();
     71            } else {
     72                AutoScaleAction.zoomTo(Collections.<OsmPrimitive>singleton(nnew));
     73            }
    7274        }
    7375    }
  • trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java

    r10383 r10467  
    284284
    285285        Main.main.undoRedo.add(new SequenceCommand(tr("Align Nodes in Circle"), cmds));
    286         Main.map.repaint();
    287286    }
    288287
  • trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java

    r10463 r10467  
    205205            // Do it!
    206206            Main.main.undoRedo.add(cmd);
    207             Main.map.repaint();
    208207
    209208        } catch (InvalidSelection except) {
  • trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java

    r10409 r10467  
    241241
    242242        Main.main.undoRedo.add(new SequenceCommand(tr("Create Circle"), cmds));
    243         Main.map.repaint();
    244243    }
    245244
  • trunk/src/org/openstreetmap/josm/actions/DistributeAction.java

    r10409 r10467  
    9898        // Do it!
    9999        Main.main.undoRedo.add(new SequenceCommand(tr("Distribute Nodes"), cmds));
    100         Main.map.repaint();
    101100    }
    102101
  • trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java

    r10292 r10467  
    137137            }
    138138            kev.consume();
    139             Main.map.repaint();
    140139        }
    141140    }
     
    164163            offsetDialog.updateOffset();
    165164        }
    166         Main.map.repaint();
    167165        prevEastNorth = eastNorth;
    168166    }
  • trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java

    r10409 r10467  
    160160        if (cmds.isEmpty()) return;
    161161        Main.main.undoRedo.add(new SequenceCommand(getValue(NAME).toString(), cmds));
    162         Main.map.repaint();
    163162    }
    164163
  • trunk/src/org/openstreetmap/josm/actions/MirrorAction.java

    r10409 r10467  
    8181
    8282        Main.main.undoRedo.add(new SequenceCommand(tr("Mirror"), cmds));
    83         Main.map.repaint();
    8483    }
    8584
  • trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java

    r10463 r10467  
    113113                if (!commands.isEmpty()) {
    114114                    Main.main.undoRedo.add(new SequenceCommand(tr("Orthogonalize / Undo"), commands));
    115                     Main.map.repaint();
    116115                } else {
    117116                    throw new InvalidUserInputException("Commands are empty");
     
    153152            final SequenceCommand command = orthogonalize(sel);
    154153            Main.main.undoRedo.add(new SequenceCommand(tr("Orthogonalize"), command));
    155             Main.map.repaint();
    156154        } catch (InvalidUserInputException ex) {
    157155            Main.debug(ex);
  • trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java

    r10463 r10467  
    103103        }
    104104        Main.main.undoRedo.add(new SequenceCommand(tr("Reverse ways"), c));
     105        // FIXME: This should be handled by undoRedo.
    105106        if (propertiesUpdated) {
    106107            ds.fireSelectionChanged();
    107108        }
    108         Main.map.repaint();
    109109    }
    110110
  • trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java

    r10409 r10467  
    124124            ds.endUpdate();
    125125        }
    126         Main.map.repaint();
    127126    }
    128127
  • trunk/src/org/openstreetmap/josm/actions/UnJoinNodeWayAction.java

    r10409 r10467  
    9191        // I'm sure there's a better way to handle this
    9292        Main.main.undoRedo.add(new RemoveNodesCommand(selectedWay, selectedNodes));
    93         Main.map.repaint();
    9493    }
    9594
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java

    r10306 r10467  
    122122                    public void run() {
    123123                        targetLayer.onPostDownloadFromServer();
    124                         if (Main.map != null)
    125                             Main.map.mapView.repaint();
    126124                    }
    127125                }
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java

    r10448 r10467  
    134134     */
    135135    public static void doActionPerformed(ActionEvent e) {
    136         if (!Main.map.mapView.isActiveLayerDrawable())
    137             return;
     136        MainLayerManager lm = Main.getLayerManager();
     137        OsmDataLayer editLayer = lm.getEditLayer();
     138        if (editLayer == null) {
     139            return;
     140        }
     141
    138142        boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0;
    139143        boolean alt = (e.getModifiers() & (ActionEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK)) != 0;
    140144
    141         MainLayerManager lm = Main.getLayerManager();
    142145        Command c;
    143146        if (ctrl) {
    144             c = DeleteCommand.deleteWithReferences(lm.getEditLayer(), lm.getEditDataSet().getSelected());
     147            c = DeleteCommand.deleteWithReferences(editLayer, lm.getEditDataSet().getSelected());
    145148        } else {
    146             c = DeleteCommand.delete(lm.getEditLayer(), lm.getEditDataSet().getSelected(), !alt /* also delete nodes in way */);
     149            c = DeleteCommand.delete(editLayer, lm.getEditDataSet().getSelected(), !alt /* also delete nodes in way */);
    147150        }
    148151        // if c is null, an error occurred or the user aborted. Don't do anything in that case.
    149152        if (c != null) {
    150153            Main.main.undoRedo.add(c);
     154            //FIXME: This should not be required, DeleteCommand should update the selection, otherwise undo/redo won't work.
    151155            lm.getEditDataSet().setSelected();
    152             Main.map.repaint();
    153156        }
    154157    }
     
    213216    private void repaintIfRequired(Set<OsmPrimitive> newHighlights, WaySegment newHighlightedWaySegment) {
    214217        boolean needsRepaint = false;
    215         DataSet ds = getLayerManager().getEditDataSet();
     218        OsmDataLayer editLayer = getLayerManager().getEditLayer();
    216219
    217220        if (newHighlightedWaySegment == null && oldHighlightedWaySegment != null) {
    218             if (ds != null) {
    219                 ds.clearHighlightedWaySegments();
     221            if (editLayer != null) {
     222                editLayer.data.clearHighlightedWaySegments();
    220223                needsRepaint = true;
    221224            }
    222225            oldHighlightedWaySegment = null;
    223226        } else if (newHighlightedWaySegment != null && !newHighlightedWaySegment.equals(oldHighlightedWaySegment)) {
    224             if (ds != null) {
    225                 ds.setHighlightedWaySegments(Collections.singleton(newHighlightedWaySegment));
     227            if (editLayer != null) {
     228                editLayer.data.setHighlightedWaySegments(Collections.singleton(newHighlightedWaySegment));
    226229                needsRepaint = true;
    227230            }
     
    229232        }
    230233        needsRepaint |= highlightHelper.highlightOnly(newHighlights);
    231         if (needsRepaint) {
    232             Main.map.mapView.repaint();
     234        if (needsRepaint && editLayer != null) {
     235            editLayer.invalidate();
    233236        }
    234237    }
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r10446 r10467  
    185185
    186186        // update selection to reflect which way being modified
    187         DataSet currentDataSet = getLayerManager().getEditDataSet();
    188         if (getCurrentBaseNode() != null && currentDataSet != null && !currentDataSet.selectionEmpty()) {
     187        OsmDataLayer editLayer = getLayerManager().getEditLayer();
     188        if (getCurrentBaseNode() != null && editLayer != null && !editLayer.data.selectionEmpty()) {
     189            DataSet currentDataSet = editLayer.data;
    189190            Way continueFrom = getWayForNode(getCurrentBaseNode());
    190191            if (alt && continueFrom != null && (!getCurrentBaseNode().isSelected() || continueFrom.isSelected())) {
     
    197198        }
    198199
    199         if (needsRepaint) {
    200             Main.map.mapView.repaint();
     200        if (needsRepaint && editLayer != null) {
     201            editLayer.invalidate();
    201202        }
    202203        return needsRepaint;
     
    917918    @Override
    918919    public void mouseExited(MouseEvent e) {
    919         if (!Main.map.mapView.isActiveLayerDrawable())
     920        OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     921        if (editLayer == null)
    920922            return;
    921923        mousePos = e.getPoint();
     
    925927        // caused one already, don’t do it again.
    926928        if (!repaintIssued) {
    927             Main.map.mapView.repaint();
     929            editLayer.invalidate();
    928930        }
    929931    }
Note: See TracChangeset for help on using the changeset viewer.