Ticket #10812: patch10812-v2.patch

File patch10812-v2.patch, 4.0 KB (added by amenk, 9 years ago)

revised patch

  • 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.Clipboard;
     19import java.awt.datatransfer.StringSelection;
     20import java.awt.Toolkit;
    1821import java.beans.PropertyChangeEvent;
    1922import java.beans.PropertyChangeListener;
    2023import java.io.File;
     
    755758        }
    756759    }
    757760
     761    public void copyCurrentPhotoPath() {
     762        ImageEntry toCopy = null;
     763        if (data != null && data.size() > 0 && currentPhoto >= 0 && currentPhoto < data.size()) {
     764            toCopy = data.get(currentPhoto);
     765            String copyString = toCopy.getFile().toString();
     766            StringSelection stringSelection = new StringSelection(copyString);
     767            Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard ();
     768            clpbrd.setContents (stringSelection, null);
     769        }
     770    }
     771   
    758772    /**
    759773     * Removes a photo from the list of images by index.
    760774     * @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.ALT_CTRL_SHIFT);
     120        final String ACOPYPATH = "Copy image path";
     121        Main.registerActionShortcut(copyPathAction, scCopyPath);
     122        btnCopyPath.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(scCopyPath.getKeyStroke(), ACOPYPATH);
     123        btnCopyPath.getActionMap().put(ACOPYPATH, 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));