Changeset 2985 in josm for trunk


Ignore:
Timestamp:
2010-02-14T16:47:44+01:00 (15 years ago)
Author:
jttt
Message:

Make DataChangedListener deprecated (replaced by DatasetListener), remove remaining listeners

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/data

    • Property svn:ignore set to
      elemstyles.xml
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java

    r2842 r2985  
    274274            Main.main.undoRedo.add(cmd);
    275275            RelationDialogManager.getRelationDialogManager().close(layer, toDelete);
    276             layer.fireDataChange();
    277276        }
    278277    }
  • trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java

    r2935 r2985  
    2424
    2525    /** the collection of conflicts created during merging */
    26     private ConflictCollection conflicts;
     26    private final ConflictCollection conflicts;
    2727
    2828    /** the target dataset for merging */
     
    3535     * Key is the primitive id in their dataset, the value is the id in my dataset
    3636     */
    37     private Map<Long, Long> mergedMap;
     37    private final Map<Long, Long> mergedMap;
    3838    /** a set of primitive ids for which we have to fix references (to nodes and
    3939     * to relation members) after the first phase of merging
    4040     */
    41     private Set<PrimitiveId> objectsWithChildrenToMerge;
    42     private Set<OsmPrimitive> deletedObjectsToUnlink;
     41    private final Set<PrimitiveId> objectsWithChildrenToMerge;
     42    private final Set<OsmPrimitive> deletedObjectsToUnlink;
    4343
    4444    /**
  • trunk/src/org/openstreetmap/josm/data/osm/Filters.java

    r2854 r2985  
    11package org.openstreetmap.josm.data.osm;
    22
    3 import static org.openstreetmap.josm.tools.I18n.tr;
    43import static org.openstreetmap.josm.tools.I18n.trc;
    54
  • trunk/src/org/openstreetmap/josm/data/osm/event/DataSetListener.java

    r2711 r2985  
    2424/**
    2525 * A listener listening for all DataSet changes.
    26  * INCOMPLETE (missing relation-related events)!
    2726 *
     27 * @see DataSetListenerAdapter
    2828 * @author nenik
    2929 */
  • trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java

    r2869 r2985  
    2626import org.openstreetmap.josm.data.osm.Filter;
    2727import org.openstreetmap.josm.data.osm.Filters;
    28 import org.openstreetmap.josm.gui.MapView;
     28import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent;
     29import org.openstreetmap.josm.data.osm.event.DataSetListener;
     30import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter;
     31import org.openstreetmap.josm.data.osm.event.DatasetEventManager;
     32import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter.Listener;
     33import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
    2934import org.openstreetmap.josm.gui.SideButton;
    30 import org.openstreetmap.josm.gui.layer.DataChangeListener;
    31 import org.openstreetmap.josm.gui.layer.Layer;
    32 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3335import org.openstreetmap.josm.tools.Shortcut;
    3436
     
    3739 * @author Petr_Dlouhý
    3840 */
    39 public class FilterDialog extends ToggleDialog implements DataChangeListener, MapView.LayerChangeListener, TableModelListener {
     41public class FilterDialog extends ToggleDialog implements Listener , TableModelListener {
     42
    4043    private JTable userTable;
    4144    private Filters filters = new Filters();
     
    4649    private SideButton downButton;
    4750
     51    private final DataSetListener listenerAdapter = new DataSetListenerAdapter(this);
     52
    4853    public FilterDialog(){
    4954        super(tr("Filter"), "filter", tr("Filter objects and hide/disable them."),
     
    5459    @Override
    5560    public void showNotify() {
    56         MapView.addLayerChangeListener(this);
     61        DatasetEventManager.getInstance().addDatasetListener(listenerAdapter, FireMode.IN_EDT_CONSOLIDATED);
    5762    }
    5863
    5964    @Override
    6065    public void hideNotify() {
    61         MapView.removeLayerChangeListener(this);
     66        DatasetEventManager.getInstance().removeDatasetListener(listenerAdapter);
    6267    }
    6368
     
    182187    }
    183188
    184     public void layerRemoved(Layer a) {
    185         if (a instanceof OsmDataLayer) {
    186             ((OsmDataLayer)a).listenerDataChanged.remove(this);
    187         }
    188     }
    189 
    190     public void layerAdded(Layer a) {
    191         if (a instanceof OsmDataLayer) {
    192             ((OsmDataLayer)a).listenerDataChanged.add(this);
    193         }
    194     }
    195 
    196     public void activeLayerChange(Layer oldLayer, Layer newLayer) {
    197         filters.filter();
    198     }
    199 
    200     public void dataChanged(OsmDataLayer l){
     189    public void processDatasetEvent(AbstractDatasetChangedEvent event) {
    201190        filters.filter();
    202191    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationMemberTask.java

    r2789 r2985  
    100100                        public void run() {
    101101                            curLayer.mergeFrom(dataSet);
    102                             curLayer.fireDataChange();
    103102                            curLayer.onPostDownloadFromServer();
    104103                        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationTask.java

    r2847 r2985  
    100100                        public void run() {
    101101                            layer.mergeFrom(allDownloads);
    102                             layer.fireDataChange();
    103102                            layer.onPostDownloadFromServer();
    104103                            Main.map.repaint();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r2974 r2985  
    115115        DataSet.selListeners.add(memberTableModel);
    116116        getLayer().data.addDataSetListener(memberTableModel);
    117         getLayer().listenerDataChanged.add(memberTableModel);
    118117        selectionTableModel = new SelectionTableModel(getLayer());
    119118        DataSet.selListeners.add(selectionTableModel);
     
    10311030            //
    10321031            getLayer().data.fireSelectionChanged();
    1033             getLayer().fireDataChange();
    10341032            GenericRelationEditor.this.setRelation(newRelation);
    10351033            RelationDialogManager.getRelationDialogManager().updateContext(
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java

    r2886 r2985  
    4343import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
    4444import org.openstreetmap.josm.gui.dialogs.relation.WayConnectionType.Direction;
    45 import org.openstreetmap.josm.gui.layer.DataChangeListener;
    4645import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    4746
    48 public class MemberTableModel extends AbstractTableModel implements TableModelListener, SelectionChangedListener, DataChangeListener, DataSetListener{
     47public class MemberTableModel extends AbstractTableModel implements TableModelListener, SelectionChangedListener, DataSetListener {
    4948
    5049    /**
     
    8382    }
    8483
    85     /* --------------------------------------------------------------------------- */
    86     /* Interface DataChangeListener                                                */
    87     /* --------------------------------------------------------------------------- */
    88     public void dataChanged(OsmDataLayer l) {
    89         if (l != this.layer) return;
    90         // just trigger a repaint
    91         Collection<RelationMember> sel = getSelectedMembers();
    92         fireTableDataChanged();
    93         setSelectedMembers(sel);
    94     }
    9584    /* --------------------------------------------------------------------------- */
    9685    /* Interface DataSetListener                                                   */
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r2850 r2985  
    3737import org.openstreetmap.josm.gui.MapView;
    3838import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    39 import org.openstreetmap.josm.gui.layer.DataChangeListener;
    4039import org.openstreetmap.josm.gui.layer.Layer;
    4140import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    6766 * @see HistoryBrowser
    6867 */
    69 public class HistoryBrowserModel extends Observable implements LayerChangeListener, DataSetListener, DataChangeListener {
     68public class HistoryBrowserModel extends Observable implements LayerChangeListener, DataSetListener {
    7069    //private static Logger logger = Logger.getLogger(HistoryBrowserModel.class.getName());
    7170
     
    102101        if (getEditLayer() != null) {
    103102            getEditLayer().data.addDataSetListener(this);
    104             getEditLayer().listenerDataChanged.add(this);
    105103        }
    106104        MapView.addLayerChangeListener(this);
     
    822820
    823821    public void dataChanged(DataChangedEvent event) {
    824         dataChanged(getEditLayer());
    825     }
    826 
    827     public void otherDatasetChange(AbstractDatasetChangedEvent event) {
    828         // Irrelevant
    829     }
    830 
    831     /* ---------------------------------------------------------------------- */
    832     /* DataChangeListener                                                     */
    833     /* ---------------------------------------------------------------------- */
    834     public void dataChanged(OsmDataLayer l) {
    835         if (l != getEditLayer()) return;
    836         OsmPrimitive primitive = l.data.getPrimitiveById(history.getId(), history.getType());
     822        OsmPrimitive primitive = event.getDataset().getPrimitiveById(history.getId(), history.getType());
    837823        HistoryOsmPrimitive latest;
    838824        if (canShowAsLatest(primitive)) {
     
    843829        setLatest(latest);
    844830        fireModelChange();
     831    }
     832
     833    public void otherDatasetChange(AbstractDatasetChangedEvent event) {
     834        // Irrelevant
    845835    }
    846836
     
    861851        OsmDataLayer l = (OsmDataLayer)newLayer;
    862852        l.data.addDataSetListener(this);
    863         l.listenerDataChanged.add(this);
    864853        OsmPrimitive primitive = l.data.getPrimitiveById(history.getId(), history.getType());
    865854        HistoryOsmPrimitive latest;
  • trunk/src/org/openstreetmap/josm/gui/layer/DataChangeListener.java

    r1169 r2985  
    22package org.openstreetmap.josm.gui.layer;
    33
     4import org.openstreetmap.josm.data.osm.event.DataSetListener;
     5
     6/**
     7 *
     8 *
     9 * @deprecated Use {@link DataSetListener} instead
     10 */
     11@Deprecated
    412public interface DataChangeListener {
    513
     14    @Deprecated
    615    public void dataChanged(OsmDataLayer l);
    716
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r2982 r2985  
    159159    private ConflictCollection conflicts;
    160160
     161    /**
     162     * @deprecated Use {@link DataSet#addDataSetListener(org.openstreetmap.josm.data.osm.event.DataSetListener)} instead
     163     * @see DataSetListener, DatasetEventManager
     164     */
     165    @Deprecated
    161166    public final LinkedList<DataChangeListener> listenerDataChanged = new LinkedList<DataChangeListener>();
    162167
Note: See TracChangeset for help on using the changeset viewer.