Changeset 12871 in josm for trunk/src/org


Ignore:
Timestamp:
2017-09-17T12:44:57+02:00 (7 years ago)
Author:
simon04
Message:

fix #14578 - Open external history viewers

Popup menu is added to version info of history dialog and changeset manager.

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

Legend:

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

    r12636 r12871  
    2323import javax.swing.AbstractAction;
    2424import javax.swing.BorderFactory;
     25import javax.swing.JButton;
    2526import javax.swing.JLabel;
    2627import javax.swing.JOptionPane;
     
    3839import org.openstreetmap.josm.gui.MainApplication;
    3940import org.openstreetmap.josm.gui.help.HelpUtil;
     41import org.openstreetmap.josm.gui.history.OpenChangesetPopupMenu;
    4042import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
    4143import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
     
    6365    private final JosmTextField tfClosedOn  = new JosmTextField(20);
    6466
     67    private final OpenChangesetPopupMenuAction   actOpenChangesetPopupMenu   = new OpenChangesetPopupMenuAction();
    6568    private final DownloadChangesetContentAction actDownloadChangesetContent = new DownloadChangesetContentAction(this);
    6669    private final UpdateChangesetAction          actUpdateChangesets         = new UpdateChangesetAction();
     
    6972    private final ZoomInCurrentLayerAction       actZoomInCurrentLayerAction = new ZoomInCurrentLayerAction();
    7073    // CHECKSTYLE.ON: SingleSpaceSeparator
     74   
     75    private JButton btnOpenChangesetPopupMenu;
    7176
    7277    private transient Changeset currentChangeset;
     
    7782        JToolBar tb = new JToolBar(JToolBar.VERTICAL);
    7883        tb.setFloatable(false);
     84
     85        // -- display changeset
     86        btnOpenChangesetPopupMenu = tb.add(actOpenChangesetPopupMenu);
     87        actOpenChangesetPopupMenu.initProperties(currentChangeset);
    7988
    8089        // -- remove from cache action
     
    259268            updateView(cs);
    260269        }
     270        actOpenChangesetPopupMenu.initProperties(currentChangeset);
    261271        actDownloadChangesetContent.initProperties();
    262272        actUpdateChangesets.initProperties(currentChangeset);
     
    322332        public void initProperties(Changeset cs) {
    323333            setEnabled(cs != null && !Main.isOffline(OnlineResource.OSM_API));
     334        }
     335    }
     336
     337    /**
     338     * The action for opening {@link OpenChangesetPopupMenu}
     339     */
     340    class OpenChangesetPopupMenuAction extends AbstractAction {
     341        OpenChangesetPopupMenuAction() {
     342            putValue(NAME, tr("View changeset"));
     343            new ImageProvider("help/internet").getResource().attachImageIcon(this);
     344        }
     345
     346        @Override
     347        public void actionPerformed(ActionEvent evt) {
     348            if (currentChangeset != null)
     349                new OpenChangesetPopupMenu(currentChangeset.getId()).show(btnOpenChangesetPopupMenu);
     350        }
     351
     352        void initProperties(Changeset cs) {
     353            setEnabled(cs != null);
    324354        }
    325355    }
  • trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java

    r12743 r12871  
    1616
    1717import javax.swing.AbstractAction;
     18import javax.swing.AbstractButton;
    1819import javax.swing.JButton;
    1920import javax.swing.JComponent;
     
    2324import javax.swing.event.ChangeEvent;
    2425import javax.swing.event.ChangeListener;
     26import javax.swing.plaf.basic.BasicArrowButton;
    2527
    2628import org.openstreetmap.josm.Main;
     
    109111        pnlUserAndChangeset.add(lblUser, GBC.eol().insets(5, 0, 0, 0).weight(1, 0));
    110112
     113        final JPanel changesetPanel = new JPanel(new BorderLayout());
    111114        changesetButton.setMargin(new Insets(0, 0, 0, 2));
    112         pnlUserAndChangeset.add(changesetButton, GBC.std().fill().weight(0, 0));
     115        changesetPanel.add(changesetButton, BorderLayout.CENTER);
     116        final BasicArrowButton arrowButton = new BasicArrowButton(BasicArrowButton.SOUTH);
     117        arrowButton.addActionListener(action -> {
     118            final OpenChangesetPopupMenu popupMenu = new OpenChangesetPopupMenu(changesetDialogAction.id);
     119            popupMenu.insert(changesetDialogAction, 0);
     120            ((AbstractButton) popupMenu.getComponent(0)).setText(tr("Open Changeset Manager"));
     121            popupMenu.show(arrowButton);
     122        });
     123        changesetPanel.add(arrowButton, BorderLayout.EAST);
     124        pnlUserAndChangeset.add(changesetPanel, GBC.std().fill().weight(0, 0));
    113125
    114126        lblChangeset = new UrlLabel("", 2);
Note: See TracChangeset for help on using the changeset viewer.