Changeset 5102 in josm for trunk


Ignore:
Timestamp:
2012-03-18T14:03:12+01:00 (8 years ago)
Author:
xeen
Message:

fix broken way segment highlighting introduced in @5101

File:
1 edited

Legend:

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

    r5101 r5102  
    5858     */
    5959    private Set<OsmPrimitive> oldHighlights = new HashSet<OsmPrimitive>();
     60    private WaySegment oldHighlightedWaySegment = null;
    6061
    6162    private boolean drawTargetHighlight;
     
    194195
    195196        Set<OsmPrimitive> newHighlights = new HashSet<OsmPrimitive>();
    196 
    197197        DeleteParameters parameters = getDeleteParameters(e, modifiers);
    198198
     
    200200            // deleting segments is the only action not working on OsmPrimitives
    201201            // so we have to handle them separately.
    202             DataSet ds = getCurrentDataSet();
    203             if(ds != null) {
    204                 ds.setHighlightedWaySegments(Collections.singleton(parameters.nearestSegment));
    205             }
     202            repaintIfRequired(newHighlights, parameters.nearestSegment);
    206203        } else {
    207204            // don't call buildDeleteCommands for DeleteMode.segment because it doesn't support
    208205            // silent operation and SplitWayAction will show dialogs. A lot.
    209206            Command delCmd = buildDeleteCommands(e, modifiers, true);
    210             if(delCmd == null) {
    211                 repaintIfRequired(newHighlights);
    212                 return;
    213             }
    214 
    215             // all other cases delete OsmPrimitives directly, so we can
    216             // safely do the following
    217             for(OsmPrimitive osm : delCmd.getParticipatingPrimitives()) {
    218                 newHighlights.add(osm);
    219             }
    220         }
    221         repaintIfRequired(newHighlights);
    222     }
    223 
    224     private void repaintIfRequired(Set<OsmPrimitive> newHighlights) {
     207            if(delCmd != null) {
     208                // all other cases delete OsmPrimitives directly, so we can
     209                // safely do the following
     210                for(OsmPrimitive osm : delCmd.getParticipatingPrimitives()) {
     211                    newHighlights.add(osm);
     212                }
     213            }
     214            repaintIfRequired(newHighlights, null);
     215        }
     216    }
     217
     218    private void repaintIfRequired(Set<OsmPrimitive> newHighlights, WaySegment newHighlightedWaySegment) {
    225219        boolean needsRepaint = false;
     220        DataSet ds = getCurrentDataSet();
     221
     222        if(newHighlightedWaySegment == null && oldHighlightedWaySegment != null) {
     223            if(ds != null) {
     224                ds.clearHighlightedWaySegments();
     225                needsRepaint = true;
     226            }
     227            oldHighlightedWaySegment = null;
     228        } else if(newHighlightedWaySegment != null && !newHighlightedWaySegment.equals(oldHighlightedWaySegment)) {
     229            if(ds != null) {
     230                ds.setHighlightedWaySegments(Collections.singleton(newHighlightedWaySegment));
     231                needsRepaint = true;
     232            }
     233            oldHighlightedWaySegment = newHighlightedWaySegment;
     234        }
     235
    226236        for(OsmPrimitive x : newHighlights) {
    227237            if(oldHighlights.contains(x)) {
Note: See TracChangeset for help on using the changeset viewer.