Changeset 9468 in josm for trunk/src


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

fix #8804 - Add version info to conflict dialog

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

Legend:

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

    r9371 r9468  
    8989    }
    9090
     91    /**
     92     * Creates a changeset with the data obtained from the given preset, i.e.,
     93     * the {@link AbstractPrimitive#getChangesetId() changeset id}, {@link AbstractPrimitive#getUser() user}, and
     94     * {@link AbstractPrimitive#getTimestamp() timestamp}.
     95     * @param primitive the primitive to use
     96     * @return the created changeset
     97     */
     98    public static Changeset fromPrimitive(final OsmPrimitive primitive) {
     99        final Changeset changeset = new Changeset(primitive.getChangesetId());
     100        changeset.setUser(primitive.getUser());
     101        changeset.setCreatedAt(primitive.getTimestamp()); // not accurate in all cases
     102        return changeset;
     103    }
     104
    91105    public void visit(Visitor v) {
    92106        v.visit(this);
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java

    r9440 r9468  
    2727import org.openstreetmap.josm.gui.conflict.pair.IConflictResolver;
    2828import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
     29import org.openstreetmap.josm.gui.history.VersionInfoPanel;
    2930import org.openstreetmap.josm.tools.ImageProvider;
    3031
     
    4849
    4950    private final transient PropertiesMergeModel model;
     51    private final VersionInfoPanel mineVersionInfo = new VersionInfoPanel();
     52    private final VersionInfoPanel theirVersionInfo = new VersionInfoPanel();
    5053
    5154    /**
     
    7881        gc.weightx = 0.0;
    7982        gc.weighty = 0.0;
    80         gc.insets = new Insets(10, 0, 10, 0);
     83        gc.insets = new Insets(10, 0, 0, 0);
    8184        JLabel lblMyVersion = new JLabel(tr("My version"));
    8285        lblMyVersion.setToolTipText(tr("Properties in my dataset, i.e. the local dataset"));
     
    8487
    8588        gc.gridx = 3;
    86         gc.gridy = 0;
    8789        JLabel lblMergedVersion = new JLabel(tr("Merged version"));
    8890        lblMergedVersion.setToolTipText(
     
    9193
    9294        gc.gridx = 5;
    93         gc.gridy = 0;
    9495        JLabel lblTheirVersion = new JLabel(tr("Their version"));
    9596        lblTheirVersion.setToolTipText(tr("Properties in their dataset, i.e. the server dataset"));
    9697        add(lblTheirVersion, gc);
     98
     99        gc.gridx = 1;
     100        gc.gridy = 1;
     101        gc.fill = GridBagConstraints.HORIZONTAL;
     102        gc.anchor = GridBagConstraints.LINE_START;
     103        gc.insets = new Insets(0, 0, 20, 0);
     104        add(mineVersionInfo, gc);
     105
     106        gc.gridx = 5;
     107        add(theirVersionInfo, gc);
     108
    97109    }
    98110
     
    101113
    102114        gc.gridx = 0;
    103         gc.gridy = 1;
     115        gc.gridy = 2;
    104116        gc.gridwidth = 1;
    105117        gc.gridheight = 1;
     
    112124
    113125        gc.gridx = 1;
    114         gc.gridy = 1;
    115126        gc.fill = GridBagConstraints.BOTH;
    116127        gc.anchor = GridBagConstraints.CENTER;
     
    120131
    121132        gc.gridx = 2;
    122         gc.gridy = 1;
    123133        gc.fill = GridBagConstraints.NONE;
    124134        gc.anchor = GridBagConstraints.CENTER;
     
    132142
    133143        gc.gridx = 3;
    134         gc.gridy = 1;
    135144        gc.fill = GridBagConstraints.BOTH;
    136145        gc.anchor = GridBagConstraints.CENTER;
     
    140149
    141150        gc.gridx = 4;
    142         gc.gridy = 1;
    143151        gc.fill = GridBagConstraints.NONE;
    144152        gc.anchor = GridBagConstraints.CENTER;
     
    151159
    152160        gc.gridx = 5;
    153         gc.gridy = 1;
    154161        gc.fill = GridBagConstraints.BOTH;
    155162        gc.anchor = GridBagConstraints.CENTER;
     
    160167        // ---------------------------------------------------
    161168        gc.gridx = 3;
    162         gc.gridy = 2;
     169        gc.gridy = 3;
    163170        gc.fill = GridBagConstraints.NONE;
    164171        gc.anchor = GridBagConstraints.CENTER;
     
    175182
    176183        gc.gridx = 0;
    177         gc.gridy = 3;
     184        gc.gridy = 4;
    178185        gc.gridwidth = 1;
    179186        gc.gridheight = 1;
     
    186193
    187194        gc.gridx = 1;
    188         gc.gridy = 3;
    189195        gc.fill = GridBagConstraints.BOTH;
    190196        gc.anchor = GridBagConstraints.CENTER;
     
    194200
    195201        gc.gridx = 2;
    196         gc.gridy = 3;
    197202        gc.fill = GridBagConstraints.NONE;
    198203        gc.anchor = GridBagConstraints.CENTER;
     
    206211
    207212        gc.gridx = 3;
    208         gc.gridy = 3;
    209213        gc.fill = GridBagConstraints.BOTH;
    210214        gc.anchor = GridBagConstraints.CENTER;
     
    214218
    215219        gc.gridx = 4;
    216         gc.gridy = 3;
    217220        gc.fill = GridBagConstraints.NONE;
    218221        gc.anchor = GridBagConstraints.CENTER;
     
    226229
    227230        gc.gridx = 5;
    228         gc.gridy = 3;
    229231        gc.fill = GridBagConstraints.BOTH;
    230232        gc.anchor = GridBagConstraints.CENTER;
     
    235237        // ---------------------------------------------------
    236238        gc.gridx = 3;
    237         gc.gridy = 4;
     239        gc.gridy = 5;
    238240        gc.fill = GridBagConstraints.NONE;
    239241        gc.anchor = GridBagConstraints.CENTER;
     
    507509    public void populate(Conflict<? extends OsmPrimitive> conflict) {
    508510        model.populate(conflict);
     511        mineVersionInfo.update(conflict.getMy(), true);
     512        theirVersionInfo.update(conflict.getTheir(), false);
    509513    }
    510514
  • 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.