Ticket #8804: 8804.patch

File 8804.patch, 16.2 KB (added by simon04, 6 years ago)
  • src/org/openstreetmap/josm/data/osm/Changeset.java

    diff --git a/src/org/openstreetmap/josm/data/osm/Changeset.java b/src/org/openstreetmap/josm/data/osm/Changeset.java
    index 5abc6d4..fc1af76 100644
    a b public final class Changeset implements Tagged { 
    8787        }
    8888    }
    8989
     90    public static Changeset fromPrimitive(final OsmPrimitive p) {
     91        final Changeset changeset = new Changeset(p.getChangesetId());
     92        changeset.setUser(p.getUser());
     93        changeset.setCreatedAt(p.getTimestamp()); // not accurate in all cases
     94        return changeset;
     95    }
     96
    9097    public void visit(Visitor v) {
    9198        v.visit(this);
    9299    }
  • src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java

    diff --git a/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java b/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java
    index 03b634c..8e0d2b7 100644
    a b import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    2626import org.openstreetmap.josm.gui.conflict.ConflictColors;
    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
    3132/**
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    4748    private JLabel lblTheirReferrers;
    4849
    4950    private final transient PropertiesMergeModel model;
     51    private final VersionInfoPanel mineVersionInfo = new VersionInfoPanel();
     52    private final VersionInfoPanel theirVersionInfo = new VersionInfoPanel();
    5053
    5154    /**
    5255     * Constructs a new {@code PropertiesMerger}.
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    7780        gc.anchor = GridBagConstraints.CENTER;
    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"));
    8386        add(lblMyVersion, gc);
    8487
    8588        gc.gridx = 3;
    86         gc.gridy = 0;
    8789        JLabel lblMergedVersion = new JLabel(tr("Merged version"));
    8890        lblMergedVersion.setToolTipText(
    8991                tr("Properties in the merged element. They will replace properties in my elements when merge decisions are applied."));
    9092        add(lblMergedVersion, gc);
    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
    99111    protected void buildCoordinateConflictRows() {
    100112        GridBagConstraints gc = new GridBagConstraints();
    101113
    102114        gc.gridx = 0;
    103         gc.gridy = 1;
     115        gc.gridy = 2;
    104116        gc.gridwidth = 1;
    105117        gc.gridheight = 1;
    106118        gc.fill = GridBagConstraints.HORIZONTAL;
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    111123        add(new JLabel(tr("Coordinates:")), gc);
    112124
    113125        gc.gridx = 1;
    114         gc.gridy = 1;
    115126        gc.fill = GridBagConstraints.BOTH;
    116127        gc.anchor = GridBagConstraints.CENTER;
    117128        gc.weightx = 0.33;
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    119130        add(lblMyCoordinates = buildValueLabel("label.mycoordinates"), gc);
    120131
    121132        gc.gridx = 2;
    122         gc.gridy = 1;
    123133        gc.fill = GridBagConstraints.NONE;
    124134        gc.anchor = GridBagConstraints.CENTER;
    125135        gc.weightx = 0.0;
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    131141        add(btnKeepMyCoordinates, gc);
    132142
    133143        gc.gridx = 3;
    134         gc.gridy = 1;
    135144        gc.fill = GridBagConstraints.BOTH;
    136145        gc.anchor = GridBagConstraints.CENTER;
    137146        gc.weightx = 0.33;
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    139148        add(lblMergedCoordinates = buildValueLabel("label.mergedcoordinates"), gc);
    140149
    141150        gc.gridx = 4;
    142         gc.gridy = 1;
    143151        gc.fill = GridBagConstraints.NONE;
    144152        gc.anchor = GridBagConstraints.CENTER;
    145153        gc.weightx = 0.0;
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    150158        add(btnKeepTheirCoordinates, gc);
    151159
    152160        gc.gridx = 5;
    153         gc.gridy = 1;
    154161        gc.fill = GridBagConstraints.BOTH;
    155162        gc.anchor = GridBagConstraints.CENTER;
    156163        gc.weightx = 0.33;
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    159166
    160167        // ---------------------------------------------------
    161168        gc.gridx = 3;
    162         gc.gridy = 2;
     169        gc.gridy = 3;
    163170        gc.fill = GridBagConstraints.NONE;
    164171        gc.anchor = GridBagConstraints.CENTER;
    165172        gc.weightx = 0.0;
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    174181        GridBagConstraints gc = new GridBagConstraints();
    175182
    176183        gc.gridx = 0;
    177         gc.gridy = 3;
     184        gc.gridy = 4;
    178185        gc.gridwidth = 1;
    179186        gc.gridheight = 1;
    180187        gc.fill = GridBagConstraints.BOTH;
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    185192        add(new JLabel(tr("Deleted State:")), gc);
    186193
    187194        gc.gridx = 1;
    188         gc.gridy = 3;
    189195        gc.fill = GridBagConstraints.BOTH;
    190196        gc.anchor = GridBagConstraints.CENTER;
    191197        gc.weightx = 0.33;
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    193199        add(lblMyDeletedState = buildValueLabel("label.mydeletedstate"), gc);
    194200
    195201        gc.gridx = 2;
    196         gc.gridy = 3;
    197202        gc.fill = GridBagConstraints.NONE;
    198203        gc.anchor = GridBagConstraints.CENTER;
    199204        gc.weightx = 0.0;
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    205210        add(btnKeepMyDeletedState, gc);
    206211
    207212        gc.gridx = 3;
    208         gc.gridy = 3;
    209213        gc.fill = GridBagConstraints.BOTH;
    210214        gc.anchor = GridBagConstraints.CENTER;
    211215        gc.weightx = 0.33;
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    213217        add(lblMergedDeletedState = buildValueLabel("label.mergeddeletedstate"), gc);
    214218
    215219        gc.gridx = 4;
    216         gc.gridy = 3;
    217220        gc.fill = GridBagConstraints.NONE;
    218221        gc.anchor = GridBagConstraints.CENTER;
    219222        gc.weightx = 0.0;
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    225228        add(btnKeepTheirDeletedState, gc);
    226229
    227230        gc.gridx = 5;
    228         gc.gridy = 3;
    229231        gc.fill = GridBagConstraints.BOTH;
    230232        gc.anchor = GridBagConstraints.CENTER;
    231233        gc.weightx = 0.33;
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    234236
    235237        // ---------------------------------------------------
    236238        gc.gridx = 3;
    237         gc.gridy = 4;
     239        gc.gridy = 5;
    238240        gc.fill = GridBagConstraints.NONE;
    239241        gc.anchor = GridBagConstraints.CENTER;
    240242        gc.weightx = 0.0;
    public class PropertiesMerger extends JPanel implements Observer, IConflictResol 
    506508    @Override
    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}
  • src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java

    diff --git a/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java b/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java
    index a7cfcf5..8b6fa24 100644
    a b import org.openstreetmap.josm.data.conflict.Conflict; 
    3030import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3131import org.openstreetmap.josm.gui.conflict.pair.IConflictResolver;
    3232import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
     33import org.openstreetmap.josm.gui.history.VersionInfoPanel;
    3334import org.openstreetmap.josm.tools.ImageProvider;
    3435
    3536/**
    public class TagMerger extends JPanel implements IConflictResolver { 
    4243    private JTable mergedTable;
    4344    private JTable theirTable;
    4445    private final TagMergeModel model;
     46    private final VersionInfoPanel mineVersionInfo = new VersionInfoPanel();
     47    private final VersionInfoPanel theirVersionInfo = new VersionInfoPanel();
    4548    private transient AdjustmentSynchronizer adjustmentSynchronizer;
    4649
    4750    /**
    public class TagMerger extends JPanel implements IConflictResolver { 
    130133        gc.anchor = GridBagConstraints.CENTER;
    131134        gc.weightx = 0.0;
    132135        gc.weighty = 0.0;
    133         gc.insets = new Insets(10, 0, 10, 0);
     136        gc.insets = new Insets(10, 0, 0, 0);
    134137        JLabel lblMy = new JLabel(tr("My version (local dataset)"));
    135138        add(lblMy, gc);
    136139
    public class TagMerger extends JPanel implements IConflictResolver { 
    153156        gc.anchor = GridBagConstraints.CENTER;
    154157        gc.weightx = 0.0;
    155158        gc.weighty = 0.0;
    156         gc.insets = new Insets(0, 0, 0, 0);
    157159        JLabel lblTheir = new JLabel(tr("Their version (server dataset)"));
    158160        add(lblTheir, gc);
    159161
    160162        gc.gridx = 0;
    161163        gc.gridy = 1;
     164        gc.fill = GridBagConstraints.HORIZONTAL;
     165        gc.anchor = GridBagConstraints.FIRST_LINE_START;
     166        gc.insets = new Insets(0, 0, 20, 0);
     167        add(mineVersionInfo, gc);
     168
     169        gc.gridx = 4;
     170        gc.gridy = 1;
     171        gc.fill = GridBagConstraints.HORIZONTAL;
     172        gc.anchor = GridBagConstraints.FIRST_LINE_START;
     173        add(theirVersionInfo, gc);
     174
     175        gc.gridx = 0;
     176        gc.gridy = 2;
    162177        gc.gridwidth = 1;
    163178        gc.gridheight = 1;
    164179        gc.fill = GridBagConstraints.BOTH;
    165180        gc.anchor = GridBagConstraints.FIRST_LINE_START;
    166181        gc.weightx = 0.3;
    167182        gc.weighty = 1.0;
     183        gc.insets = new Insets(0, 0, 0, 0);
    168184        JScrollPane tabMy = buildMineTagTable();
    169185        lblMy.setLabelFor(tabMy);
    170186        add(tabMy, gc);
    171187
    172188        gc.gridx = 1;
    173         gc.gridy = 1;
     189        gc.gridy = 2;
    174190        gc.gridwidth = 1;
    175191        gc.gridheight = 1;
    176192        gc.fill = GridBagConstraints.NONE;
    public class TagMerger extends JPanel implements IConflictResolver { 
    184200        add(btnKeepMine, gc);
    185201
    186202        gc.gridx = 2;
    187         gc.gridy = 1;
     203        gc.gridy = 2;
    188204        gc.gridwidth = 1;
    189205        gc.gridheight = 1;
    190206        gc.fill = GridBagConstraints.BOTH;
    public class TagMerger extends JPanel implements IConflictResolver { 
    196212        add(tabMerge, gc);
    197213
    198214        gc.gridx = 3;
    199         gc.gridy = 1;
     215        gc.gridy = 2;
    200216        gc.gridwidth = 1;
    201217        gc.gridheight = 1;
    202218        gc.fill = GridBagConstraints.NONE;
    public class TagMerger extends JPanel implements IConflictResolver { 
    209225        add(btnKeepTheir, gc);
    210226
    211227        gc.gridx = 4;
    212         gc.gridy = 1;
     228        gc.gridy = 2;
    213229        gc.gridwidth = 1;
    214230        gc.gridheight = 1;
    215231        gc.fill = GridBagConstraints.BOTH;
    public class TagMerger extends JPanel implements IConflictResolver { 
    441457            int index = table.getRowCount() > 0 ? 0 : -1;
    442458            table.getSelectionModel().setSelectionInterval(index, index);
    443459        }
     460        mineVersionInfo.update(conflict.getMy(), true);
     461        theirVersionInfo.update(conflict.getTheir(), false);
    444462    }
    445463}
  • src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java

    diff --git a/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java b/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java
    index 1f3ec85..2199452 100644
    a b import java.awt.Insets; 
    1212import java.awt.event.ActionEvent;
    1313import java.text.DateFormat;
    1414import java.util.Collections;
     15import java.util.Date;
    1516import java.util.Observable;
    1617import java.util.Observer;
    1718
    public class VersionInfoPanel extends JPanel implements Observer { 
    133134        return model.getPointInTime(pointInTimeType);
    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;
    157155    }
    public class VersionInfoPanel extends JPanel implements Observer { 
    189187
    190188    @Override
    191189    public void update(Observable o, Object arg) {
    192         lblInfo.setText(getInfoText());
    193 
    194190        HistoryOsmPrimitive primitive = getPrimitive();
    195191        Changeset cs = primitive.getChangeset();
     192        update(cs, model.isLatest(primitive), primitive.getTimestamp(), primitive.getVersion());
     193    }
    196194
    197         if (!model.isLatest(primitive)) {
    198             User user = primitive.getUser();
    199             String url = Main.getBaseBrowseUrl() + "/changeset/" + primitive.getChangesetId();
     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
    205210            String username = "";
    public class VersionInfoPanel extends JPanel implements Observer { 
    227232            changesetButton.setEnabled(false);
    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);
    233238        updateText(cs, "imagery_used", texChangesetImageryUsed, lblImageryUsed, oppCs, pnlChangesetImageryUsed);