Ignore:
Timestamp:
2013-12-06T22:27:39+01:00 (6 years ago)
Author:
simon04
Message:

fix #3626 - Show history for any object in history dialog

If no object is selected, the objects are selected by id via dialog.

File:
1 edited

Legend:

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

    r6316 r6448  
    1717import org.openstreetmap.josm.Main;
    1818import org.openstreetmap.josm.data.osm.OsmPrimitive;
     19import org.openstreetmap.josm.data.osm.PrimitiveId;
    1920import org.openstreetmap.josm.data.osm.history.History;
    2021import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
     
    139140    }
    140141
    141     public void showHistory(final Collection<OsmPrimitive> primitives) {
    142         final Collection<OsmPrimitive> notNewPrimitives = Utils.filter(primitives, notNewPredicate);
     142    public void showHistory(final Collection<? extends PrimitiveId> primitives) {
     143        final Collection<? extends PrimitiveId> notNewPrimitives = Utils.filter(primitives, notNewPredicate);
    143144        if (notNewPrimitives.isEmpty()) {
    144145            JOptionPane.showMessageDialog(
     
    150151        }
    151152
    152         Collection<OsmPrimitive> toLoad = Utils.filter(primitives, unloadedHistoryPredicate);
     153        Collection<PrimitiveId> toLoad = Utils.filter(primitives, unloadedHistoryPredicate);
    153154        if (!toLoad.isEmpty()) {
    154155            HistoryLoadTask task = new HistoryLoadTask();
    155             task.add(notNewPrimitives);
     156            for (PrimitiveId p : notNewPrimitives) {
     157                task.add(p);
     158            }
    156159            Main.worker.submit(task);
    157160        }
     
    162165            public void run() {
    163166                try {
    164                     for (OsmPrimitive p : notNewPrimitives) {
    165                         final History h = HistoryDataSet.getInstance().getHistory(p.getPrimitiveId());
     167                    for (PrimitiveId p : notNewPrimitives) {
     168                        final History h = HistoryDataSet.getInstance().getHistory(p);
    166169                        if (h == null) {
    167170                            continue;
     
    183186    }
    184187
    185     private final Predicate<OsmPrimitive> unloadedHistoryPredicate = new Predicate<OsmPrimitive>() {
     188    private final Predicate<PrimitiveId> unloadedHistoryPredicate = new Predicate<PrimitiveId>() {
    186189
    187190        HistoryDataSet hds = HistoryDataSet.getInstance();
    188191
    189192        @Override
    190         public boolean evaluate(OsmPrimitive p) {
    191             History h = hds.getHistory(p.getPrimitiveId());
     193        public boolean evaluate(PrimitiveId p) {
     194            History h = hds.getHistory(p);
    192195            if (h == null)
    193196                // reload if the history is not in the cache yet
     
    201204    };
    202205
    203     private final Predicate<OsmPrimitive> notNewPredicate = new Predicate<OsmPrimitive>() {
     206    private final Predicate<PrimitiveId> notNewPredicate = new Predicate<PrimitiveId>() {
    204207
    205208        @Override
    206         public boolean evaluate(OsmPrimitive p) {
     209        public boolean evaluate(PrimitiveId p) {
    207210            return !p.isNew();
    208211        }
Note: See TracChangeset for help on using the changeset viewer.