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


Ignore:
Timestamp:
2017-12-30T00:17:44+01:00 (7 years ago)
Author:
Don-vip
Message:

Open Location: new expert combobox to choose whether to zoom on downloaded data (like in download dialog) + remember window geometry (no i18n impact)

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java

    r13206 r13261  
    4343import org.openstreetmap.josm.gui.MainApplication;
    4444import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor;
     45import org.openstreetmap.josm.gui.util.WindowGeometry;
    4546import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
    4647import org.openstreetmap.josm.spi.preferences.Config;
     
    5960     * true if the URL needs to be opened in a new layer, false otherwise
    6061     */
    61     private static final BooleanProperty USE_NEW_LAYER = new BooleanProperty("download.newlayer", false);
     62    private static final BooleanProperty USE_NEW_LAYER = new BooleanProperty("download.location.newlayer", false);
     63    /**
     64     * true to zoom to entire newly downloaded data, false otherwise
     65     */
     66    private static final BooleanProperty DOWNLOAD_ZOOMTODATA = new BooleanProperty("download.location.zoomtodata", true);
    6267    /**
    6368     * the list of download tasks
     
    139144        all.add(layer, GBC.eop().fill(GBC.BOTH));
    140145
     146        // zoom to downloaded data
     147        JCheckBox zoom = new JCheckBox(tr("Zoom to downloaded data"));
     148        zoom.setToolTipText(tr("Select to zoom to entire newly downloaded data."));
     149        zoom.setSelected(DOWNLOAD_ZOOMTODATA.get());
     150        all.add(zoom, GBC.eop().fill(GBC.BOTH));
     151
     152        ExpertToggleAction.addVisibilitySwitcher(zoom);
     153
    141154        ExtendedDialog dialog = new ExtendedDialog(Main.parent,
    142155                tr("Download Location"),
     
    148161                tr("Close dialog and cancel downloading"))
    149162            .configureContextsensitiveHelp("/Action/OpenLocation", true /* show help button */);
     163        dialog.setupDialog();
     164        dialog.pack();
     165        dialog.setRememberWindowGeometry(getClass().getName() + ".geometry",
     166                    WindowGeometry.centerInWindow(Main.parent, dialog.getPreferredSize()));
    150167        if (dialog.showDialog().getValue() == 1) {
    151168            USE_NEW_LAYER.put(layer.isSelected());
     169            DOWNLOAD_ZOOMTODATA.put(zoom.isSelected());
    152170            remindUploadAddressHistory(uploadAddresses);
    153171            openUrl(Utils.strip(uploadAddresses.getText()));
     
    207225     */
    208226    public List<Future<?>> openUrl(boolean newLayer, String url) {
    209         return realOpenUrl(newLayer, url);
     227        return openUrl(newLayer, DOWNLOAD_ZOOMTODATA.get(), url);
    210228    }
    211229
     
    217235     */
    218236    public List<Future<?>> openUrl(String url) {
    219         return realOpenUrl(USE_NEW_LAYER.get(), url);
    220     }
    221 
    222     private List<Future<?>> realOpenUrl(boolean newLayer, String url) {
     237        return openUrl(USE_NEW_LAYER.get(), DOWNLOAD_ZOOMTODATA.get(), url);
     238    }
     239
     240    /**
     241     * Open the given URL.
     242     * @param newLayer true if the URL needs to be opened in a new layer, false otherwise
     243     * @param zoomToData true to zoom to entire newly downloaded data, false otherwise
     244     * @param url The URL to open
     245     * @return the list of tasks that have been started successfully (can be empty).
     246     * @since 13261
     247     */
     248    public List<Future<?>> openUrl(boolean newLayer, boolean zoomToData, String url) {
    223249        Collection<DownloadTask> tasks = findDownloadTasks(url, false);
    224250
     
    235261        for (final DownloadTask task : tasks) {
    236262            try {
     263                task.setZoomAfterDownload(zoomToData);
    237264                result.add(MainApplication.worker.submit(new PostDownloadHandler(task, task.loadUrl(newLayer, url, monitor))));
    238265            } catch (IllegalArgumentException e) {
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/AbstractDownloadTask.java

    r11774 r13261  
    7979    }
    8080
    81     /**
    82      * Sets whether the map view will zoom to download area after download
    83      * @param zoomAfterDownload if true, the map view will zoom to download area after download
    84      * @since 11658
    85      */
     81    @Override
    8682    public final void setZoomAfterDownload(boolean zoomAfterDownload) {
    8783        this.zoomAfterDownload = zoomAfterDownload;
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTask.java

    r12634 r13261  
    128128     */
    129129    String getConfirmationMessage(URL url);
     130
     131    /**
     132     * Sets whether the map view will zoom to download area after download
     133     * @param zoomAfterDownload if true, the map view will zoom to download area after download
     134     * @since 13261
     135     */
     136    void setZoomAfterDownload(boolean zoomAfterDownload);
    130137}
Note: See TracChangeset for help on using the changeset viewer.