Changeset 13832 in josm


Ignore:
Timestamp:
2018-05-25T21:05:36+02:00 (8 weeks ago)
Author:
Don-vip
Message:

fix #5603, see #5256, see #15240 - add first/last buttons for geoimage dialog. Fixed shortcuts. Switch to SVG icons taken from https://commons.wikimedia.org/wiki/GNOME_Desktop_icons#Navigation

Location:
trunk
Files:
6 added
4 deleted
2 edited

Legend:

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

    r13795 r13832  
    2727import javax.swing.ButtonGroup;
    2828import javax.swing.ImageIcon;
     29import javax.swing.InputMap;
    2930import javax.swing.JButton;
    3031import javax.swing.JCheckBoxMenuItem;
     
    222223        splitPane.setUI(new NoBorderSplitPaneUI());
    223224
    224         // JSplitPane supports F6 and F8 shortcuts by default, but we need them for Audio actions
    225         splitPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), new Object());
    226         splitPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0), new Object());
     225        // JSplitPane supports F6, F8, Home and End shortcuts by default, but we need them for Audio and Image Mapping actions
     226        InputMap splitInputMap = splitPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
     227        splitInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), new Object());
     228        splitInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0), new Object());
     229        splitInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), new Object());
     230        splitInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), new Object());
    227231
    228232        add(splitPane, BorderLayout.CENTER);
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java

    r13289 r13832  
    7575    }
    7676
     77    private JButton btnLast;
    7778    private JButton btnNext;
    7879    private JButton btnPrevious;
     80    private JButton btnFirst;
    7981    private JButton btnCollapse;
    8082    private JToggleButton tbCentre;
     
    8890    }
    8991
     92    private static JButton createNavigationButton(JosmAction action, Dimension buttonDim) {
     93        JButton btn = new JButton(action);
     94        btn.setPreferredSize(buttonDim);
     95        btn.setEnabled(false);
     96        return btn;
     97    }
     98
    9099    private void build() {
    91100        JPanel content = new JPanel(new BorderLayout());
     
    95104        Dimension buttonDim = new Dimension(26, 26);
    96105
    97         btnPrevious = new JButton(imagePreviousAction);
    98         btnPrevious.setPreferredSize(buttonDim);
    99         btnPrevious.setEnabled(false);
     106        btnFirst = createNavigationButton(imageFirstAction, buttonDim);
     107        btnPrevious = createNavigationButton(imagePreviousAction, buttonDim);
    100108
    101109        JButton btnDelete = new JButton(imageRemoveAction);
     
    108116        btnCopyPath.setPreferredSize(buttonDim);
    109117
    110         btnNext = new JButton(imageNextAction);
    111         btnNext.setPreferredSize(buttonDim);
    112         btnNext.setEnabled(false);
     118        btnNext = createNavigationButton(imageNextAction, buttonDim);
     119        btnLast = createNavigationButton(imageLastAction, buttonDim);
    113120
    114121        tbCentre = new JToggleButton(imageCenterViewAction);
     
    123130
    124131        JPanel buttons = new JPanel();
     132        buttons.add(btnFirst);
    125133        buttons.add(btnPrevious);
    126134        buttons.add(btnNext);
     135        buttons.add(btnLast);
    127136        buttons.add(Box.createRigidArea(new Dimension(7, 0)));
    128137        buttons.add(tbCentre);
     
    204213    private class ImageFirstAction extends JosmAction {
    205214        ImageFirstAction() {
    206             super(null, (ImageProvider) null, null, Shortcut.registerShortcut(
     215            super(null, new ImageProvider("dialogs", "first"), tr("First"), Shortcut.registerShortcut(
    207216                    "geoimage:first", tr("Geoimage: {0}", tr("Show first Image")), KeyEvent.VK_HOME, Shortcut.DIRECT),
    208217                  false, null, false);
     
    219228    private class ImageLastAction extends JosmAction {
    220229        ImageLastAction() {
    221             super(null, (ImageProvider) null, null, Shortcut.registerShortcut(
     230            super(null, new ImageProvider("dialogs", "last"), tr("Last"), Shortcut.registerShortcut(
    222231                    "geoimage:last", tr("Geoimage: {0}", tr("Show last Image")), KeyEvent.VK_END, Shortcut.DIRECT),
    223232                  false, null, false);
     
    319328    }
    320329
     330    /**
     331     * Displays image for the given layer.
     332     * @param layer geo image layer
     333     * @param entry image entry
     334     */
    321335    public static void showImage(GeoImageLayer layer, ImageEntry entry) {
    322336        getInstance().displayImage(layer, entry);
     
    334348     */
    335349    public static void setPreviousEnabled(boolean value) {
     350        getInstance().btnFirst.setEnabled(value);
    336351        getInstance().btnPrevious.setEnabled(value);
    337352    }
     
    343358    public static void setNextEnabled(boolean value) {
    344359        getInstance().btnNext.setEnabled(value);
     360        getInstance().btnLast.setEnabled(value);
    345361    }
    346362
     
    361377    private transient ImageEntry currentEntry;
    362378
     379    /**
     380     * Displays image for the given layer.
     381     * @param layer geo image layer
     382     * @param entry image entry
     383     */
    363384    public void displayImage(GeoImageLayer layer, ImageEntry entry) {
    364385        boolean imageChanged;
Note: See TracChangeset for help on using the changeset viewer.