Ignore:
Timestamp:
2017-08-27T17:07:54+02:00 (4 years ago)
Author:
Don-vip
Message:

see #15182 - move ConflictCollection from OsmDataLayer to DataSet. Simplifies some code where a data set is enough, and a layer is not needed

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
5 edited

Legend:

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

    r12643 r12672  
    218218     */
    219219    public void refreshView() {
    220         OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
     220        DataSet editDs = MainApplication.getLayerManager().getEditDataSet();
    221221        synchronized (this) {
    222             conflicts = editLayer == null ? new ConflictCollection() : editLayer.getConflicts();
     222            conflicts = editDs == null ? new ConflictCollection() : editDs.getConflicts();
    223223        }
    224224        GuiHelper.runInEDT(() -> {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java

    r12213 r12672  
    1111import org.openstreetmap.josm.data.coor.EastNorth;
    1212import org.openstreetmap.josm.data.osm.BBox;
     13import org.openstreetmap.josm.data.osm.DataSet;
    1314import org.openstreetmap.josm.data.osm.Node;
    1415import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    1617import org.openstreetmap.josm.data.osm.RelationMember;
    1718import org.openstreetmap.josm.data.osm.Way;
    18 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1919import org.openstreetmap.josm.tools.Geometry;
    2020import org.openstreetmap.josm.tools.date.DateUtils;
     
    2929
    3030    private final StringBuilder s = new StringBuilder();
    31     private final OsmDataLayer layer;
    32 
    33     InspectPrimitiveDataText(OsmDataLayer layer) {
    34         this.layer = layer;
     31    private final DataSet ds;
     32
     33    InspectPrimitiveDataText(DataSet ds) {
     34        this.ds = ds;
    3535    }
    3636
     
    226226
    227227    void addConflicts(OsmPrimitive o) {
    228         Conflict<?> c = layer.getConflicts().getConflictForMy(o);
     228        Conflict<?> c = ds.getConflicts().getConflictForMy(o);
    229229        if (c != null) {
    230230            add(tr("In conflict with: "));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java

    r12663 r12672  
    2222
    2323import org.openstreetmap.josm.Main;
     24import org.openstreetmap.josm.data.osm.DataSet;
    2425import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
    2526import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    2829import org.openstreetmap.josm.gui.MainApplication;
    2930import org.openstreetmap.josm.gui.NavigatableComponent;
    30 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3131import org.openstreetmap.josm.gui.mappaint.Cascade;
    3232import org.openstreetmap.josm.gui.mappaint.ElemStyles;
     
    5353
    5454    protected transient List<OsmPrimitive> primitives;
    55     protected transient OsmDataLayer layer;
    5655    private boolean mappaintTabLoaded;
    5756    private boolean editcountTabLoaded;
     
    6059     * Constructs a new {@code InspectPrimitiveDialog}.
    6160     * @param primitives collection of primitives
    62      * @param layer data layer
     61     * @param data data set
     62     * @since 12672 (signature)
    6363     */
    64     public InspectPrimitiveDialog(final Collection<OsmPrimitive> primitives, OsmDataLayer layer) {
     64    public InspectPrimitiveDialog(final Collection<OsmPrimitive> primitives, DataSet data) {
    6565        super(Main.parent, tr("Advanced object info"), tr("Close"));
    6666        this.primitives = new ArrayList<>(primitives);
    67         this.layer = layer;
    6867        setRememberWindowGeometry(getClass().getName() + ".geometry",
    6968                WindowGeometry.centerInWindow(Main.parent, new Dimension(750, 550)));
     
    7271        final JTabbedPane tabs = new JTabbedPane();
    7372
    74         tabs.addTab(tr("data"), genericMonospacePanel(new JPanel(), buildDataText(layer, this.primitives)));
     73        tabs.addTab(tr("data"), genericMonospacePanel(new JPanel(), buildDataText(data, this.primitives)));
    7574
    7675        final JPanel pMapPaint = new JPanel();
     
    106105    }
    107106
    108     protected static String buildDataText(OsmDataLayer layer, List<OsmPrimitive> primitives) {
    109         InspectPrimitiveDataText dt = new InspectPrimitiveDataText(layer);
     107    protected static String buildDataText(DataSet data, List<OsmPrimitive> primitives) {
     108        InspectPrimitiveDataText dt = new InspectPrimitiveDataText(data);
    110109        primitives.stream()
    111110                .sorted(OsmPrimitiveComparator.orderingWaysRelationsNodes().thenComparing(OsmPrimitiveComparator.comparingNames()))
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationTree.java

    r12636 r12672  
    136136                return;
    137137            }
    138             DataSetMerger visitor = new DataSetMerger(MainApplication.getLayerManager().getEditLayer().data, ds);
     138            DataSet editData = MainApplication.getLayerManager().getEditDataSet();
     139            DataSetMerger visitor = new DataSetMerger(editData, ds);
    139140            visitor.merge();
    140141            if (!visitor.getConflicts().isEmpty()) {
    141                 MainApplication.getLayerManager().getEditLayer().getConflicts().add(visitor.getConflicts());
     142                editData.getConflicts().add(visitor.getConflicts());
    142143            }
    143144            final RelationTreeModel model = (RelationTreeModel) getModel();
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r12671 r12672  
    351351
    352352    /**
    353      * the collection of conflicts detected in this layer
    354      */
    355     private final ConflictCollection conflicts;
    356 
    357     /**
    358353     * a texture for non-downloaded area
    359354     */
     
    407402        this.data = data;
    408403        this.setAssociatedFile(associatedFile);
    409         conflicts = new ConflictCollection();
    410404        data.addDataSetListener(new DataSetListenerAdapter(this));
    411405        data.addDataSetListener(MultipolygonCache.getInstance());
     
    567561        int numNewConflicts = 0;
    568562        for (Conflict<?> c : visitor.getConflicts()) {
    569             if (!conflicts.hasConflict(c)) {
     563            if (!data.getConflicts().hasConflict(c)) {
    570564                numNewConflicts++;
    571                 conflicts.add(c);
     565                data.getConflicts().add(c);
    572566            }
    573567        }
     
    924918     */
    925919    public ConflictCollection getConflicts() {
    926         return conflicts;
     920        return data.getConflicts();
    927921    }
    928922
Note: See TracChangeset for help on using the changeset viewer.