Changeset 6456 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2013-12-07T23:32:40+01:00 (11 years ago)
Author:
simon04
Message:

fix #5256 - geoimage: select first/last image with Home/End key

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r6450 r6456  
    677677    }
    678678
     679    public void showFirstPhoto() {
     680        if (data != null && data.size() > 0) {
     681            currentPhoto = 0;
     682            ImageViewerDialog.showImage(this, data.get(currentPhoto));
     683        } else {
     684            currentPhoto = -1;
     685        }
     686        Main.map.repaint();
     687    }
     688
     689    public void showLastPhoto() {
     690        if (data != null && data.size() > 0) {
     691            currentPhoto = data.size() - 1;
     692            ImageViewerDialog.showImage(this, data.get(currentPhoto));
     693        } else {
     694            currentPhoto = -1;
     695        }
     696        Main.map.repaint();
     697    }
     698
    679699    public void checkPreviousNextButtons() {
    680700        ImageViewerDialog.setNextEnabled(currentPhoto < data.size() - 1);
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java

    r6450 r6456  
    3737    private static final String COMMAND_PREVIOUS = "previous";
    3838    private static final String COMMAND_COLLAPSE = "collapse";
     39    private static final String COMMAND_FIRST = "first";
     40    private static final String COMMAND_LAST = "last";
    3941
    4042    private ImageDisplay imgDisplay = new ImageDisplay();
     
    116118        btnNext.getActionMap().put(ANEXT, nextAction);
    117119
     120        Main.registerActionShortcut(
     121                new ImageAction(COMMAND_FIRST, null, null),
     122                Shortcut.registerShortcut(
     123                        "geoimage:first", tr("Geoimage: {0}", tr("Show first Image")), KeyEvent.VK_HOME, Shortcut.DIRECT)
     124        );
     125        Main.registerActionShortcut(
     126                new ImageAction(COMMAND_LAST, null, null),
     127                Shortcut.registerShortcut(
     128                        "geoimage:last", tr("Geoimage: {0}", tr("Show last Image")), KeyEvent.VK_END, Shortcut.DIRECT)
     129        );
     130
    118131        JToggleButton tbCentre = new JToggleButton(new ImageAction(COMMAND_CENTERVIEW, ImageProvider.get("dialogs", "centreview"), tr("Center view")));
    119132        tbCentre.setPreferredSize(buttonDim);
     
    174187                    currentLayer.showPreviousPhoto();
    175188                }
     189            } else if (COMMAND_FIRST.equals(action) && currentLayer != null) {
     190                currentLayer.showFirstPhoto();
     191            } else if (COMMAND_LAST.equals(action) && currentLayer != null) {
     192                currentLayer.showLastPhoto();
    176193
    177194            } else if (COMMAND_CENTERVIEW.equals(action)) {
Note: See TracChangeset for help on using the changeset viewer.