Ignore:
Timestamp:
2015-04-23T21:26:41+02:00 (4 years ago)
Author:
simon04
Message:

see #10789 - History dialog: add button to open changeset dialog

File:
1 edited

Legend:

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

    r8226 r8254  
    55
    66import java.awt.BorderLayout;
     7import java.awt.Dimension;
    78import java.awt.GridBagConstraints;
    89import java.awt.GridBagLayout;
    910import java.awt.GridLayout;
     11import java.awt.Insets;
     12import java.awt.event.ActionEvent;
    1013import java.io.UnsupportedEncodingException;
    1114import java.net.URLEncoder;
    1215import java.text.DateFormat;
     16import java.util.Collections;
    1317import java.util.Observable;
    1418import java.util.Observer;
    1519
     20import javax.swing.AbstractAction;
     21import javax.swing.JButton;
    1622import javax.swing.JComponent;
    1723import javax.swing.JLabel;
     
    2531import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive;
    2632import org.openstreetmap.josm.gui.JosmUserIdentityManager;
     33import org.openstreetmap.josm.gui.dialogs.ChangesetDialog;
    2734import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2835import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
     
    3037import org.openstreetmap.josm.tools.CheckParameterUtil;
    3138import org.openstreetmap.josm.tools.GBC;
     39import org.openstreetmap.josm.tools.ImageProvider;
    3240import org.openstreetmap.josm.tools.Utils;
    3341import org.openstreetmap.josm.tools.date.DateUtils;
     
    4452    private UrlLabel lblUser;
    4553    private UrlLabel lblChangeset;
     54    private final OpenChangesetDialogAction changesetDialogAction = new OpenChangesetDialogAction();
     55    private final JButton changesetButton = new JButton(changesetDialogAction);
    4656    private JPanel pnlChangesetSource;
    4757    private JPanel pnlChangesetImageryUsed;
     
    8797        pnlUserAndChangeset.add(new JLabel(tr("User:")));
    8898        pnlUserAndChangeset.add(lblUser);
    89         pnlUserAndChangeset.add(new JLabel(tr("Changeset:")));
     99        changesetButton.setMargin(new Insets(0, 0, 0, 0));
     100        pnlUserAndChangeset.add(changesetButton);
    90101        lblChangeset = new UrlLabel("", 2);
    91102        pnlUserAndChangeset.add(lblChangeset);
     
    191202            lblChangeset.setUrl(url);
    192203            lblChangeset.setDescription(Long.toString(primitive.getChangesetId()));
     204            changesetDialogAction.setId((int) primitive.getChangesetId());
     205            changesetButton.setEnabled(true);
    193206
    194207            String username = "";
     
    223236            lblChangeset.setDescription(tr("none"));
    224237            lblChangeset.setUrl(null);
     238            changesetDialogAction.setId(null);
     239            changesetButton.setEnabled(false);
    225240        }
    226241
     
    241256        container.setVisible(text != null || (oppCs != null && oppCs.get(attr) != null));
    242257    }
     258
     259    static class OpenChangesetDialogAction extends AbstractAction {
     260        private Integer id;
     261
     262        public OpenChangesetDialogAction() {
     263            super(tr("Changeset"), new ImageProvider("dialogs/changeset", "changesetmanager").resetMaxSize(new Dimension(16, 16)).get());
     264            putValue(SHORT_DESCRIPTION, tr("Opens the Changeset Manager window for the selected changesets"));
     265        }
     266
     267        public void setId(Integer id) {
     268            this.id = id;
     269        }
     270
     271        @Override
     272        public void actionPerformed(ActionEvent e) {
     273            ChangesetDialog.LaunchChangesetManager.displayChangesets(Collections.singleton(id));
     274        }
     275    }
    243276}
Note: See TracChangeset for help on using the changeset viewer.