Ignore:
Timestamp:
2009-07-08T21:50:32+02:00 (15 years ago)
Author:
Gubaer
Message:

new: replaced global conflict list by conflict list per layer, similar to datasets

File:
1 edited

Legend:

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

    r1690 r1750  
    1919import java.awt.event.ActionEvent;
    2020import java.awt.geom.Area;
    21 import java.awt.geom.Rectangle2D;
    2221import java.awt.image.BufferedImage;
    2322import java.io.File;
     
    4241import org.openstreetmap.josm.actions.SaveAction;
    4342import org.openstreetmap.josm.actions.SaveAsAction;
     43import org.openstreetmap.josm.data.conflict.Conflict;
     44import org.openstreetmap.josm.data.conflict.ConflictCollection;
    4445import org.openstreetmap.josm.data.coor.EastNorth;
    4546import org.openstreetmap.josm.data.coor.LatLon;
     
    6061import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;
    6162import org.openstreetmap.josm.gui.MapView;
    62 import org.openstreetmap.josm.gui.dialogs.ConflictDialog;
    6363import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
    6464import org.openstreetmap.josm.gui.dialogs.LayerListPopup;
     
    7474 */
    7575public class OsmDataLayer extends Layer {
     76
     77    /** the global counter for created data layers */
     78    static private int dataLayerCounter = 0;
     79
     80    /**
     81     * Replies a new unique name for a data layer
     82     *
     83     * @return a new unique name for a data layer
     84     */
     85    static public String createNewName() {
     86        dataLayerCounter++;
     87        return tr("Data Layer {0}", dataLayerCounter);
     88    }
    7689
    7790    public final static class DataCountVisitor extends AbstractVisitor {
     
    114127     */
    115128    public final DataSet data;
     129
     130    /**
     131     * the collection of conflicts detected in this layer
     132     */
     133    private ConflictCollection conflicts;
    116134
    117135    /**
     
    159177        this.data = data;
    160178        this.setAssociatedFile(associatedFile);
     179        conflicts = new ConflictCollection();
    161180    }
    162181
     
    177196        boolean active = Main.map.mapView.getActiveLayer() == this;
    178197        boolean inactive = !active && Main.pref.getBoolean("draw.data.inactive_color", true);
    179         boolean virtual = !inactive && Main.map.mapView.useVirtualNodes();
     198        boolean virtual = !inactive && Main.map.mapView.isVirtualNodesEnabled();
    180199
    181200        // draw the hatched area for non-downloaded region. only draw if we're the active
     
    271290        Main.map.mapView.repaint();
    272291
    273         if (visitor.getConflicts().isEmpty())
    274             return;
    275         final ConflictDialog dlg = Main.map.conflictDialog;
    276         dlg.add(visitor.getConflicts());
    277         JOptionPane.showMessageDialog(Main.parent,tr("There were {0} conflicts during import.", visitor.getConflicts().size()));
    278         if (!dlg.isVisible()) {
    279             dlg.action.actionPerformed(new ActionEvent(this, 0, ""));
     292        int numNewConflicts = 0;
     293        for (Conflict c : visitor.getConflicts()) {
     294            if (!conflicts.hasConflict(c)) {
     295                numNewConflicts++;
     296                conflicts.add(c);
     297            }
     298        }
     299        if (numNewConflicts > 0) {
     300            JOptionPane.showMessageDialog(Main.parent,tr("There were {0} conflicts during import.", numNewConflicts));
    280301        }
    281302    }
     
    510531        return layer_bounds_point;
    511532    }
     533
     534    /**
     535     * replies the set of conflicts currently managed in this layer
     536     *
     537     * @return the set of conflicts currently managed in this layer
     538     */
     539    public ConflictCollection getConflicts() {
     540        return conflicts;
     541    }
    512542}
Note: See TracChangeset for help on using the changeset viewer.