Changeset 8254 in josm for trunk


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

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java

    r7861 r8254  
    206206        // -- launch changeset manager action
    207207        launchChangesetManagerAction = new LaunchChangesetManagerAction();
    208         cbInSelectionOnly.addItemListener(launchChangesetManagerAction);
    209208
    210209        popupMenu = new ChangesetDialogPopup(lstInActiveDataLayer, lstInSelection);
     
    462461     *
    463462     */
    464     class LaunchChangesetManagerAction extends AbstractAction implements ListSelectionListener, ItemListener {
     463    class LaunchChangesetManagerAction extends AbstractAction {
    465464        public LaunchChangesetManagerAction() {
    466465            putValue(NAME, tr("Details"));
     
    469468        }
    470469
    471         protected void launchChangesetManager(Collection<Integer> toSelect) {
     470        @Override
     471        public void actionPerformed(ActionEvent arg0) {
     472            ChangesetListModel model = getCurrentChangesetListModel();
     473            Set<Integer> sel = model.getSelectedChangesetIds();
     474            LaunchChangesetManager.displayChangesets(sel);
     475        }
     476    }
     477
     478    /**
     479     * A utility class to fetch changesets and display the changeset dialog.
     480     */
     481    public static class LaunchChangesetManager {
     482
     483        protected static void launchChangesetManager(Collection<Integer> toSelect) {
    472484            ChangesetCacheManager cm = ChangesetCacheManager.getInstance();
    473485            if (cm.isVisible()) {
     
    483495        }
    484496
    485         @Override
    486         public void actionPerformed(ActionEvent arg0) {
    487             ChangesetListModel model = getCurrentChangesetListModel();
    488             Set<Integer> sel = model.getSelectedChangesetIds();
     497        /**
     498         * Fetches changesets and display the changeset dialog.
     499         * @param sel the changeset ids to fetch and display.
     500         */
     501        public static void displayChangesets(final Set<Integer> sel) {
    489502            final Set<Integer> toDownload = new HashSet<>();
    490503            if (!Main.isOffline(OnlineResource.OSM_API)) {
     
    534547                        @Override
    535548                        public void run() {
    536                             launchChangesetManager(toDownload);
     549                            launchChangesetManager(sel);
    537550                        }
    538551                    });
     
    540553            };
    541554            Main.worker.submit(r);
    542         }
    543 
    544         @Override
    545         public void itemStateChanged(ItemEvent arg0) {
    546         }
    547 
    548         @Override
    549         public void valueChanged(ListSelectionEvent e) {
    550555        }
    551556    }
  • 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.