Ignore:
Timestamp:
2016-01-15T19:01:02+01:00 (4 years ago)
Author:
simon04
Message:

fix #8804 - Add version info to conflict dialog

File:
1 edited

Legend:

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

    r9078 r9468  
    1313import java.text.DateFormat;
    1414import java.util.Collections;
     15import java.util.Date;
    1516import java.util.Observable;
    1617import java.util.Observer;
     
    134135    }
    135136
    136     protected String getInfoText() {
    137         HistoryOsmPrimitive primitive = getPrimitive();
    138         if (primitive == null)
    139             return "";
     137    protected String getInfoText(final Date timestamp, final long version, final boolean isLatest) {
    140138        String text;
    141         if (model.isLatest(primitive)) {
     139        if (isLatest) {
    142140            OsmDataLayer editLayer = Main.main.getEditLayer();
    143141            text = tr("<html>Version <strong>{0}</strong> currently edited in layer ''{1}''</html>",
    144                     Long.toString(primitive.getVersion()),
     142                    Long.toString(version),
    145143                    editLayer == null ? tr("unknown") : editLayer.getName()
    146144                    );
    147145        } else {
    148146            String date = "?";
    149             if (primitive.getTimestamp() != null) {
    150                 date = DateUtils.formatDateTime(primitive.getTimestamp(), DateFormat.SHORT, DateFormat.SHORT);
     147            if (timestamp != null) {
     148                date = DateUtils.formatDateTime(timestamp, DateFormat.SHORT, DateFormat.SHORT);
    151149            }
    152150            text = tr(
    153151                    "<html>Version <strong>{0}</strong> created on <strong>{1}</strong></html>",
    154                     Long.toString(primitive.getVersion()), date);
     152                    Long.toString(version), date);
    155153        }
    156154        return text;
     
    190188    @Override
    191189    public void update(Observable o, Object arg) {
    192         lblInfo.setText(getInfoText());
    193 
    194190        HistoryOsmPrimitive primitive = getPrimitive();
    195191        Changeset cs = primitive.getChangeset();
    196 
    197         if (!model.isLatest(primitive)) {
    198             User user = primitive.getUser();
    199             String url = Main.getBaseBrowseUrl() + "/changeset/" + primitive.getChangesetId();
     192        update(cs, model.isLatest(primitive), primitive.getTimestamp(), primitive.getVersion());
     193    }
     194
     195    public void update(final OsmPrimitive primitive, final boolean isLatest) {
     196        update(Changeset.fromPrimitive(primitive), isLatest, primitive.getTimestamp(), primitive.getVersion());
     197    }
     198
     199    public void update(final Changeset cs, final boolean isLatest, final Date timestamp, final long version) {
     200        lblInfo.setText(getInfoText(timestamp, version, isLatest));
     201
     202        if (!isLatest) {
     203            User user = cs.getUser();
     204            String url = Main.getBaseBrowseUrl() + "/changeset/" + cs.getId();
    200205            lblChangeset.setUrl(url);
    201             lblChangeset.setDescription(Long.toString(primitive.getChangesetId()));
    202             changesetDialogAction.setId((int) primitive.getChangesetId());
     206            lblChangeset.setDescription(Long.toString(cs.getId()));
     207            changesetDialogAction.setId(cs.getId());
    203208            changesetButton.setEnabled(true);
    204209
     
    228233        }
    229234
    230         final Changeset oppCs = model.getPointInTime(pointInTimeType.opposite()).getChangeset();
     235        final Changeset oppCs = model != null ? model.getPointInTime(pointInTimeType.opposite()).getChangeset() : null;
    231236        updateText(cs, "comment", texChangesetComment, null, oppCs, texChangesetComment);
    232237        updateText(cs, "source", texChangesetSource, lblSource, oppCs, pnlChangesetSource);
Note: See TracChangeset for help on using the changeset viewer.