Ticket #10812: patch10812.patch

File patch10812.patch, 5.5 KB (added by amenk, 11 years ago)

Patch implementing a copy path functionality

  • src/org/openstreetmap/josm/gui/MainApplication.java

     
    6868import org.openstreetmap.josm.tools.PlatformHookWindows;
    6969import org.openstreetmap.josm.tools.Utils;
    7070
     71
     72import org.openstreetmap.gui.jmapviewer.tilesources.BingAerialTileSource;
     73import org.openstreetmap.josm.data.imagery.ImageryInfo;
     74
     75import org.openstreetmap.josm.gui.layer.TMSLayer;
     76import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
     77
     78
     79
    7180/**
    7281 * Main window class application.
    7382 *
     
    278287     * Main application Startup
    279288     * @param argArray Command-line arguments
    280289     */
    281     public static void main(final String[] argArray) {
     290    public static void main(final String[] argArray) throws Exception {
     291
     292
     293
    282294        I18n.init();
    283295        Main.checkJavaVersion();
    284296
  • src/org/openstreetmap/josm/gui/layer/TMSLayer.java

     
    321321        class BingAttributionData extends CacheCustomContent<IOException> {
    322322
    323323            public BingAttributionData() {
    324                 super("bing.attribution.xml", CacheCustomContent.INTERVAL_HOURLY);
     324                super("bing.attribution.xml", CacheCustomContent.INTERVAL_NEVER);
    325325            }
    326326
    327327            @Override
  • src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

     
    1515import java.awt.event.MouseAdapter;
    1616import java.awt.event.MouseEvent;
    1717import java.awt.image.BufferedImage;
     18import java.awt.datatransfer.*;
     19import java.awt.Toolkit;
    1820import java.beans.PropertyChangeEvent;
    1921import java.beans.PropertyChangeListener;
    2022import java.io.File;
     
    755757        }
    756758    }
    757759
     760    public void copyCurrentPhotoPath() {
     761        ImageEntry toCopy = null;
     762        if (data != null && data.size() > 0 && currentPhoto >= 0 && currentPhoto < data.size()) {
     763            toCopy = data.get(currentPhoto);
     764            String copyString = toCopy.getFile().toString();
     765                        StringSelection stringSelection = new StringSelection(copyString);
     766                        Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard ();
     767                        clpbrd.setContents (stringSelection, null);
     768                }
     769        }
     770       
    758771    /**
    759772     * Removes a photo from the list of images by index.
    760773     * @param idx Image index
  • src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java

     
    4242    private static final String COMMAND_COLLAPSE = "collapse";
    4343    private static final String COMMAND_FIRST = "first";
    4444    private static final String COMMAND_LAST = "last";
     45    private static final String COMMAND_COPY_PATH = "copypath";
    4546
    4647    private ImageDisplay imgDisplay = new ImageDisplay();
    4748    private boolean centerView = false;
     
    111112        btnDeleteFromDisk.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(scDeleteFromDisk.getKeyStroke(), ADELFROMDISK);
    112113        btnDeleteFromDisk.getActionMap().put(ADELFROMDISK, delFromDiskAction);
    113114
     115        ImageAction copyPathAction = new ImageAction(COMMAND_COPY_PATH, ImageProvider.get("", "copy"), tr("Copy image path"));
     116        JButton btnCopyPath = new JButton(copyPathAction);
     117        btnCopyPath.setPreferredSize(buttonDim);
     118        Shortcut scCopyPath = Shortcut.registerShortcut(
     119                "geoimage:copypath", tr("Geoimage: {0}", tr("Copy image path")), KeyEvent.VK_C, Shortcut.CTRL_SHIFT);
     120        final String ACOPYPATH = "Copy image path";
     121        Main.registerActionShortcut(copyPathAction, scCopyPath);
     122        btnDeleteFromDisk.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(scCopyPath.getKeyStroke(), ACOPYPATH);
     123        btnDeleteFromDisk.getActionMap().put(ADELFROMDISK, copyPathAction);
     124
    114125        ImageAction nextAction = new ImageAction(COMMAND_NEXT, ImageProvider.get("dialogs", "next"), tr("Next"));
    115126        btnNext = new JButton(nextAction);
    116127        btnNext.setPreferredSize(buttonDim);
     
    152163        buttons.add(Box.createRigidArea(new Dimension(14, 0)));
    153164        buttons.add(btnDelete);
    154165        buttons.add(btnDeleteFromDisk);
     166        buttons.add(Box.createRigidArea(new Dimension(14, 0)));
     167        buttons.add(btnCopyPath);
    155168
    156169        JPanel bottomPane = new JPanel();
    157170        bottomPane.setLayout(new GridBagLayout());
     
    221234                if (currentLayer != null) {
    222235                    currentLayer.removeCurrentPhotoFromDisk();
    223236                }
     237            } else if (COMMAND_COPY_PATH.equals(action)) {
     238                if (currentLayer != null) {
     239                    currentLayer.copyCurrentPhotoPath();
     240                }
    224241            } else if (COMMAND_COLLAPSE.equals(action)) {
    225242                collapseButtonClicked = true;
    226243                detachedDialog.getToolkit().getSystemEventQueue().postEvent(new WindowEvent(detachedDialog, WindowEvent.WINDOW_CLOSING));