Ignore:
Timestamp:
2009-12-12T20:21:36+01:00 (10 years ago)
Author:
jttt
Message:

Dataset changed events refactored - DatasetEventManager now allows to register listeners to current dataset (no need to reregister when activeLayer is changed, events from current dataset are always returned), possibility to automatically receive events in EDT

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r2621 r2622  
    55
    66import java.util.ArrayList;
    7 import java.util.Collection;
    87import java.util.Collections;
    98import java.util.HashSet;
    109import java.util.Observable;
    11 import java.util.logging.Logger;
    1210
    1311import javax.swing.table.DefaultTableModel;
    1412
    1513import org.openstreetmap.josm.Main;
    16 import org.openstreetmap.josm.data.osm.DataSetListener;
    1714import org.openstreetmap.josm.data.osm.Node;
    1815import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    2320import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
    2421import org.openstreetmap.josm.data.osm.Way;
     22import org.openstreetmap.josm.data.osm.event.DataChangedEvent;
     23import org.openstreetmap.josm.data.osm.event.DataSetListener;
     24import org.openstreetmap.josm.data.osm.event.NodeMovedEvent;
     25import org.openstreetmap.josm.data.osm.event.PrimitivesAddedEvent;
     26import org.openstreetmap.josm.data.osm.event.PrimitivesRemovedEvent;
     27import org.openstreetmap.josm.data.osm.event.RelationMembersChangedEvent;
     28import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;
     29import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
    2530import org.openstreetmap.josm.data.osm.history.History;
    2631import org.openstreetmap.josm.data.osm.history.HistoryNode;
     
    3035import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
    3136import org.openstreetmap.josm.gui.MapView;
     37import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    3238import org.openstreetmap.josm.gui.layer.DataChangeListener;
    3339import org.openstreetmap.josm.gui.layer.Layer;
     
    5965 * @see HistoryBrowser
    6066 */
    61 public class HistoryBrowserModel extends Observable implements MapView.LayerChangeListener, DataSetListener, DataChangeListener {
    62 
    63     private static Logger logger = Logger.getLogger(HistoryBrowserModel.class.getName());
     67public class HistoryBrowserModel extends Observable implements LayerChangeListener, DataSetListener, DataChangeListener {
     68    //private static Logger logger = Logger.getLogger(HistoryBrowserModel.class.getName());
    6469
    6570    /** the history of an OsmPrimitive */
     
    777782    /* DataSetListener                                                        */
    778783    /* ---------------------------------------------------------------------- */
    779     public void nodeMoved(Node node) {
     784    public void nodeMoved(NodeMovedEvent event) {
     785        Node node = event.getNode();
    780786        if (!node.isNew() && node.getId() == history.getId()) {
    781787            setLatest(new HistoryPrimitiveBuilder().build(node));
     
    783789    }
    784790
    785     public void primtivesAdded(Collection<? extends OsmPrimitive> added) {
    786         if (added == null || added.isEmpty()) return;
    787         for (OsmPrimitive p: added) {
     791    public void primtivesAdded(PrimitivesAddedEvent event) {
     792        for (OsmPrimitive p: event.getPrimitives()) {
    788793            if (canShowAsLatest(p)) {
    789794                setLatest(new HistoryPrimitiveBuilder().build(p));
     
    792797    }
    793798
    794     public void primtivesRemoved(Collection<? extends OsmPrimitive> removed) {
    795         if (removed == null || removed.isEmpty()) return;
    796         for (OsmPrimitive p: removed) {
     799    public void primtivesRemoved(PrimitivesRemovedEvent event) {
     800        for (OsmPrimitive p: event.getPrimitives()) {
    797801            if (!p.isNew() && p.getId() == history.getId()) {
    798802                setLatest(null);
     
    801805    }
    802806
    803     public void relationMembersChanged(Relation r) {
     807    public void relationMembersChanged(RelationMembersChangedEvent event) {
     808        Relation r = event.getRelation();
    804809        if (!r.isNew() && r.getId() == history.getId()) {
    805810            setLatest(new HistoryPrimitiveBuilder().build(r));
     
    807812    }
    808813
    809     public void tagsChanged(OsmPrimitive prim) {
     814    public void tagsChanged(TagsChangedEvent event) {
     815        OsmPrimitive prim = event.getPrimitive();
    810816        if (!prim.isNew() && prim.getId() == history.getId()) {
    811817            setLatest(new HistoryPrimitiveBuilder().build(prim));
     
    813819    }
    814820
    815     public void wayNodesChanged(Way way) {
     821    public void wayNodesChanged(WayNodesChangedEvent event) {
     822        Way way = event.getChangedWay();
    816823        if (!way.isNew() && way.getId() == history.getId()) {
    817824            setLatest(new HistoryPrimitiveBuilder().build(way));
     
    819826    }
    820827
    821     public void dataChanged() {
     828    public void dataChanged(DataChangedEvent event) {
    822829        dataChanged(getEditLayer());
    823830    }
    824831
    825832    /* ---------------------------------------------------------------------- */
    826     /* DataChangeListener                                                    */
     833    /* DataChangeListener                                                     */
    827834    /* ---------------------------------------------------------------------- */
    828835    public void dataChanged(OsmDataLayer l) {
Note: See TracChangeset for help on using the changeset viewer.