Changeset 16460 in josm


Ignore:
Timestamp:
2020-05-18T09:57:52+02:00 (3 weeks ago)
Author:
GerdP
Message:

see #19254

  • double click on first row did not work
  • allow to use all implementations of PrimitiveId in HistoryDataSet.getHistory()
  • simplify code, correct javadoc
Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryDataSet.java

    r16445 r16460  
    1313
    1414import org.openstreetmap.josm.data.osm.Changeset;
    15 import org.openstreetmap.josm.data.osm.IPrimitive;
    1615import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1716import org.openstreetmap.josm.data.osm.PrimitiveId;
     
    166165     */
    167166    public History getHistory(PrimitiveId pid) {
    168         PrimitiveId key = pid instanceof IPrimitive ? ((IPrimitive) pid).getPrimitiveId()
    169                         : pid instanceof HistoryOsmPrimitive ? ((HistoryOsmPrimitive) pid).getPrimitiveId()
    170                         : pid;
     167        PrimitiveId key = new SimplePrimitiveId(pid.getUniqueId(), pid.getType());
    171168        List<HistoryOsmPrimitive> versions = data.get(Objects.requireNonNull(key, "key"));
    172169        if (versions == null)
  • trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java

    r16459 r16460  
    5656        table.addMouseListener(new ShowHistoryAction.DoubleClickAdapter(e -> {
    5757            int row = table.rowAtPoint(e.getPoint());
    58             return row <= 0 ? null : primitiveIdAtRow(tableModel, row);
     58            return row < 0 ? null : primitiveIdAtRow(tableModel, row);
    5959        }));
    6060        return table;
  • trunk/src/org/openstreetmap/josm/gui/history/RelationMemberListViewer.java

    r16459 r16460  
    3838        table.addMouseListener(new ShowHistoryAction.DoubleClickAdapter(e -> {
    3939            int row = table.rowAtPoint(e.getPoint());
    40             return row <= 0 ? null : (RelationMemberData) tableModel.getValueAt(row, 0).value;
     40            return row < 0 ? null : (RelationMemberData) tableModel.getValueAt(row, 0).value;
    4141        }));
    4242        return table;
  • trunk/src/org/openstreetmap/josm/gui/history/ShowHistoryAction.java

    r16459 r16460  
    77import java.awt.event.MouseAdapter;
    88import java.awt.event.MouseEvent;
     9import java.util.Collections;
    910import java.util.function.Function;
    1011
     
    1213
    1314import org.openstreetmap.josm.data.osm.PrimitiveId;
    14 import org.openstreetmap.josm.data.osm.history.History;
    15 import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
    16 import org.openstreetmap.josm.gui.MainApplication;
    17 import org.openstreetmap.josm.gui.util.GuiHelper;
    1815import org.openstreetmap.josm.tools.ImageProvider;
    1916
    2017/**
    21  * Open a history browser with the history of this node
     18 * Open a history browser with the history of an object.
    2219 */
    2320class ShowHistoryAction extends AbstractAction {
     
    2926    ShowHistoryAction() {
    3027        putValue(NAME, tr("Show history"));
    31         putValue(SHORT_DESCRIPTION, tr("Open a history browser with the history of this node"));
     28        putValue(SHORT_DESCRIPTION, tr("Display the history of the selected object."));
    3229        new ImageProvider("dialogs", "history").getResource().attachImageIcon(this, true);
    3330    }
     
    4643
    4744    public void run() {
    48         if (HistoryDataSet.getInstance().getHistory(primitiveId) == null) {
    49             MainApplication.worker.submit(new HistoryLoadTask().add(primitiveId));
    50         }
    51         MainApplication.worker.submit(() -> {
    52             final History h = HistoryDataSet.getInstance().getHistory(primitiveId);
    53             if (h == null)
    54                 return;
    55             GuiHelper.runInEDT(() -> HistoryBrowserDialogManager.getInstance().show(h));
    56         });
     45        HistoryBrowserDialogManager.getInstance().showHistory(Collections.singleton(primitiveId));
    5746    }
    5847
Note: See TracChangeset for help on using the changeset viewer.