Ignore:
Timestamp:
2016-08-23T22:07:06+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #13429 - Clean validator tree and use listener to find changes (patch by michael2402) - gsoc-core

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/ValidatorLayer.java

    r10507 r10880  
    4141 */
    4242public class ValidatorLayer extends Layer implements LayerChangeListener {
    43 
    44     private int updateCount = -1;
     43    private final Runnable invalidator = this::invalidate;
    4544
    4645    /**
     
    5049        super(tr("Validation errors"));
    5150        Main.getLayerManager().addLayerChangeListener(this);
     51        Main.map.validatorDialog.tree.addInvalidationListener(invalidator);
    5252    }
    5353
     
    6868    @Override
    6969    public void paint(final Graphics2D g, final MapView mv, Bounds bounds) {
    70         updateCount = Main.map.validatorDialog.tree.getUpdateCount();
    7170        DefaultMutableTreeNode root = Main.map.validatorDialog.tree.getRoot();
    7271        if (root == null || root.getChildCount() == 0)
     
    124123
    125124    @Override
    126     public boolean isChanged() {
    127         return updateCount != Main.map.validatorDialog.tree.getUpdateCount();
    128     }
    129 
    130     @Override
    131125    public void visitBoundingBox(BoundingXYVisitor v) {
    132126        // Do nothing
     
    168162            e.scheduleRemoval(Collections.singleton(this));
    169163        } else if (e.getRemovedLayer() == this) {
    170             Main.getLayerManager().removeLayerChangeListener(this);
    171164            OsmValidator.errorLayer = null;
    172165        }
     
    177170        return LayerPositionStrategy.IN_FRONT;
    178171    }
     172
     173    @Override
     174    public void destroy() {
     175        Main.map.validatorDialog.tree.removeInvalidationListener(invalidator);
     176        Main.getLayerManager().removeLayerChangeListener(this);
     177        super.destroy();
     178    }
    179179}
Note: See TracChangeset for help on using the changeset viewer.