Changeset 4406 in josm for trunk/src/org


Ignore:
Timestamp:
2011-09-07T23:56:18+02:00 (13 years ago)
Author:
simon04
Message:

fix #6776 - sensible pre-selection of versions in history dialog

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

Legend:

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

    r3083 r4406  
    3030    private CoordinateInfoViewer coordinateInfoViewer;
    3131    private JTabbedPane tpViewers;
     32    private VersionTable versionTable;
    3233
    3334    /**
     
    5354        pnl.setLayout(new BorderLayout());
    5455
    55         VersionTable tbl = new VersionTable(model);
    56         pnl.add(embeddInScrollPane(tbl), BorderLayout.CENTER);
     56        versionTable = new VersionTable(model);
     57        pnl.add(embeddInScrollPane(versionTable), BorderLayout.CENTER);
    5758        return pnl;
    5859    }
     
    126127    public void populate(History history) {
    127128        model.setHistory(history);
     129        versionTable.updateSelection();
    128130
    129131        tpViewers.removeAll();
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r4339 r4406  
    174174        this.history = history;
    175175        if (history.getNumVersions() > 0) {
    176             current = history.getEarliest();
    177             reference = history.getEarliest();
    178             setLatest(null);
     176            HistoryOsmPrimitive newLatest = null;
    179177            if (getEditLayer() != null) {
    180178                OsmPrimitive p = getEditLayer().data.getPrimitiveById(history.getId(), history.getType());
    181179                if (canShowAsLatest(p)) {
    182                     HistoryOsmPrimitive latest = new HistoryPrimitiveBuilder().build(p);
    183                     setLatest(latest);
     180                    newLatest = new HistoryPrimitiveBuilder().build(p);
    184181                }
    185182            }
     183            if (newLatest == null) {
     184                current = history.getLatest();
     185                int prevIndex = history.getNumVersions() - 2;
     186                reference = prevIndex < 0 ? history.getEarliest() : history.get(prevIndex);
     187            } else {
     188                reference = history.getLatest();
     189                current = newLatest;
     190            }
     191            setLatest(newLatest);
    186192        }
    187193        initTagTableModels();
  • trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java

    r4191 r4406  
    9595    }
    9696
     97    public void updateSelection() {
     98        final int row = getVersionTableModel().getRowCount() - 1;
     99        setRowSelectionInterval(row, row);
     100    }
     101
    97102    class PopupMenuTrigger extends MouseAdapter {
    98103        @Override
Note: See TracChangeset for help on using the changeset viewer.