Ignore:
Timestamp:
2018-02-18T16:51:54+01:00 (21 months ago)
Author:
Don-vip
Message:

fix #15967 - proper loading of notes layers

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/importexport/NoteImporter.java

    r13352 r13437  
    6868            throws SAXException, IOException {
    6969        final List<Note> fileNotes = new NoteReader(in).parse();
    70         List<NoteLayer> noteLayers = null;
    71         if (MainApplication.getMap() != null) {
    72             noteLayers = MainApplication.getLayerManager().getLayersOfType(NoteLayer.class);
    73         }
    74         final NoteLayer layer;
    75         if (noteLayers != null && !noteLayers.isEmpty()) {
    76             layer = noteLayers.get(0);
     70        NoteLayer layer = MainApplication.getLayerManager().getNoteLayer();
     71        if (layer != null) {
    7772            layer.getNoteData().addNotes(fileNotes);
    7873        } else {
  • trunk/src/org/openstreetmap/josm/gui/layer/MainLayerManager.java

    r13435 r13437  
    421421            return null;
    422422        }
     423    }
     424
     425    /**
     426     * Returns the unique note layer, if present.
     427     * @return the unique note layer, or null
     428     * @since 13437
     429     */
     430    public NoteLayer getNoteLayer() {
     431        List<NoteLayer> col = getLayersOfType(NoteLayer.class);
     432        return col.isEmpty() ? null : col.get(0);
    423433    }
    424434
  • trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java

    r13206 r13437  
    349349    @Override
    350350    public String getToolTipText() {
    351         return trn("{0} note", "{0} notes", noteData.getNotes().size(), noteData.getNotes().size());
     351        int size = noteData.getNotes().size();
     352        return trn("{0} note", "{0} notes", size, size);
    352353    }
    353354
    354355    @Override
    355356    public void mergeFrom(Layer from) {
    356         throw new UnsupportedOperationException("Notes layer does not support merging yet");
     357        if (from instanceof NoteLayer && this != from) {
     358            noteData.mergeFrom(((NoteLayer) from).noteData);
     359        }
    357360    }
    358361
Note: See TracChangeset for help on using the changeset viewer.