Changeset 12373 in josm for trunk/src


Ignore:
Timestamp:
2017-06-09T21:31:00+02:00 (7 years ago)
Author:
michael2402
Message:

Fix listener leak in ChangesetDialog and migrate ChangesetInSelectionListModel to new dataset listeners.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java

    r12297 r12373  
    4343import org.openstreetmap.josm.data.osm.event.DatasetEventManager;
    4444import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
     45import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
    4546import org.openstreetmap.josm.gui.SideButton;
    4647import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager;
     
    113114        // let the model for changesets in the current selection listen to various events
    114115        ChangesetCache.getInstance().addChangesetCacheListener(inSelectionModel);
    115         Main.getLayerManager().addActiveLayerChangeListener(inSelectionModel);
    116         DataSet.addSelectionListener(inSelectionModel);
     116        SelectionEventManager.getInstance().addSelectionListener(inSelectionModel);
    117117
    118118        // let the model for changesets in the current layer listen to various
     
    140140        // remove the list model for the changesets in the current selection as
    141141        // listener
    142         //
    143         Main.getLayerManager().removeActiveLayerChangeListener(inSelectionModel);
    144         DataSet.removeSelectionListener(inSelectionModel);
     142        SelectionEventManager.getInstance().removeSelectionListener(inSelectionModel);
     143        ChangesetCache.getInstance().removeChangesetCacheListener(inSelectionModel);
    145144    }
    146145
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetInSelectionListModel.java

    r12371 r12373  
    22package org.openstreetmap.josm.gui.dialogs.changeset;
    33
    4 import java.util.Collection;
    5 
    64import javax.swing.DefaultListSelectionModel;
    75
    8 import org.openstreetmap.josm.data.SelectionChangedListener;
    9 import org.openstreetmap.josm.data.osm.DataSet;
    10 import org.openstreetmap.josm.data.osm.OsmPrimitive;
    11 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
    12 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
     6import org.openstreetmap.josm.data.osm.DataSelectionListener;
    137
    148/**
    159 * A table of changesets that displays the ones that are used by the primitives in the current selection.
    1610 */
    17 public class ChangesetInSelectionListModel extends ChangesetListModel implements SelectionChangedListener, ActiveLayerChangeListener {
     11public class ChangesetInSelectionListModel extends ChangesetListModel implements DataSelectionListener {
    1812
    1913    /**
     
    2620
    2721    /* ---------------------------------------------------------------------------- */
    28     /* Interface SelectionChangeListener                                            */
     22    /* Interface DataSelectionListener                                              */
    2923    /* ---------------------------------------------------------------------------- */
     24
    3025    @Override
    31     public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    32         initFromPrimitives(newSelection);
    33     }
    34 
    35     /* ---------------------------------------------------------------------------- */
    36     /* Interface LayerChangeListener                                                */
    37     /* ---------------------------------------------------------------------------- */
    38     @Override
    39     public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
    40         DataSet newData = e.getSource().getEditDataSet();
    41         if (newData == null) {
    42             setChangesets(null);
    43         } else {
    44             initFromPrimitives(newData.getAllSelected());
    45         }
     26    public void selectionChanged(SelectionChangeEvent event) {
     27        initFromPrimitives(event.getSelection());
    4628    }
    4729}
Note: See TracChangeset for help on using the changeset viewer.