Changeset 18300 in josm


Ignore:
Timestamp:
2021-11-01T18:30:38+01:00 (2 years ago)
Author:
Don-vip
Message:

see #16472 - allow to open geoimages into external viewer, useful for 360 images until we can display them in full resolution

Location:
trunk
Files:
1 added
1 edited

Legend:

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

    r18290 r18300  
    1414import java.awt.event.KeyEvent;
    1515import java.awt.event.WindowEvent;
     16import java.io.IOException;
    1617import java.io.Serializable;
    1718import java.time.ZoneOffset;
     
    5859import org.openstreetmap.josm.tools.ImageProvider;
    5960import org.openstreetmap.josm.tools.Logging;
     61import org.openstreetmap.josm.tools.PlatformManager;
    6062import org.openstreetmap.josm.tools.Shortcut;
    6163import org.openstreetmap.josm.tools.date.DateUtils;
     
    8082    private final ImageLastAction imageLastAction = new ImageLastAction();
    8183    private final ImageCopyPathAction imageCopyPathAction = new ImageCopyPathAction();
     84    private final ImageOpenExternalAction imageOpenExternalAction = new ImageOpenExternalAction();
    8285    private final LayerVisibilityAction visibilityAction = new LayerVisibilityAction(Collections::emptyList,
    8386            () -> Collections.singleton(imageryFilterSettings));
     
    115118    private JButton btnDelete;
    116119    private JButton btnCopyPath;
     120    private JButton btnOpenExternal;
    117121    private JButton btnDeleteFromDisk;
    118122    private JToggleButton tbCentre;
     
    160164        btnDeleteFromDisk = createButton(imageRemoveFromDiskAction, buttonDim);
    161165        btnCopyPath = createButton(imageCopyPathAction, buttonDim);
     166        btnOpenExternal = createButton(imageOpenExternalAction, buttonDim);
    162167
    163168        btnNext = createNavigationButton(imageNextAction, buttonDim);
     
    186191        buttons.add(Box.createRigidArea(new Dimension(7, 0)));
    187192        buttons.add(btnCopyPath);
     193        buttons.add(btnOpenExternal);
    188194        buttons.add(Box.createRigidArea(new Dimension(7, 0)));
    189195        buttons.add(createButton(visibilityAction, buttonDim));
     
    220226        imageCollapseAction.destroy();
    221227        imageCopyPathAction.destroy();
     228        imageOpenExternalAction.destroy();
    222229        imageRemoveAction.destroy();
    223230        imageRemoveFromDiskAction.destroy();
     
    230237    /**
    231238     * This literally exists to silence sonarlint complaints.
     239     * @param <I> the type of the operand and result of the operator
    232240     */
    233241    @FunctionalInterface
     
    494502    }
    495503
     504    private class ImageOpenExternalAction extends JosmAction {
     505        ImageOpenExternalAction() {
     506            super(null, new ImageProvider("external-link"), tr("Open image in external viewer"), null, false, null, false);
     507        }
     508
     509        @Override
     510        public void actionPerformed(ActionEvent e) {
     511            if (currentEntry != null) {
     512                try {
     513                    PlatformManager.getPlatform().openUrl(currentEntry.getFile().toURI().toURL().toExternalForm());
     514                } catch (IOException ex) {
     515                    Logging.error(ex);
     516                }
     517            }
     518        }
     519    }
     520
    496521    /**
    497522     * Enables (or disables) the "Previous" button.
     
    605630        btnDeleteFromDisk.setEnabled(hasMultipleImages);
    606631        btnCopyPath.setEnabled(false);
     632        btnOpenExternal.setEnabled(false);
    607633        if (hasMultipleImages) {
    608634            imgDisplay.setEmptyText(tr("Multiple images selected"));
     
    633659        btnDeleteFromDisk.setEnabled(entry.isDeleteSupported() && entry.isRemoveSupported());
    634660        btnCopyPath.setEnabled(true);
     661        btnOpenExternal.setEnabled(true);
    635662
    636663        setTitle(tr("Geotagged Images") + (!entry.getDisplayName().isEmpty() ? " - " + entry.getDisplayName() : ""));
Note: See TracChangeset for help on using the changeset viewer.