Ignore:
Timestamp:
2018-10-30T23:39:52+01:00 (5 years ago)
Author:
simon04
Message:

fix #16494 - Download dialog: Download as new layer as button

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r14215 r14391  
    6767    private static final StringProperty DOWNLOAD_SOURCE_TAB = new StringProperty("download.source.tab", OSMDownloadSource.SIMPLE_NAME);
    6868    private static final BooleanProperty DOWNLOAD_AUTORUN = new BooleanProperty("download.autorun", false);
    69     private static final BooleanProperty DOWNLOAD_NEWLAYER = new BooleanProperty("download.newlayer", false);
    7069    private static final BooleanProperty DOWNLOAD_ZOOMTODATA = new BooleanProperty("download.zoomtodata", true);
    7170
     
    9796    protected final DownloadSourceTabs downloadSourcesTab = new DownloadSourceTabs();
    9897
    99     protected JCheckBox cbNewLayer;
    10098    protected JCheckBox cbStartup;
    10199    protected JCheckBox cbZoomToDownloadedData;
     
    113111
    114112    protected JButton btnDownload;
     113    protected JButton btnDownloadNewLayer;
    115114    protected JButton btnCancel;
    116115    protected JButton btnHelp;
     
    155154        mainPanel.add(dialogSplit, GBC.eol().fill());
    156155
    157         cbNewLayer = new JCheckBox(tr("Download as new layer"));
    158         cbNewLayer.setToolTipText(tr("<html>Select to download data into a new data layer.<br>"
    159                 +"Unselect to download into the currently active data layer.</html>"));
    160 
    161156        cbStartup = new JCheckBox(tr("Open this dialog on startup"));
    162157        cbStartup.setToolTipText(
     
    168163        cbZoomToDownloadedData.setToolTipText(tr("Select to zoom to entire newly downloaded data."));
    169164
    170         mainPanel.add(cbNewLayer, GBC.std().anchor(GBC.WEST).insets(5, 5, 5, 5));
    171165        mainPanel.add(cbStartup, GBC.std().anchor(GBC.WEST).insets(15, 5, 5, 5));
    172166        mainPanel.add(cbZoomToDownloadedData, GBC.std().anchor(GBC.WEST).insets(15, 5, 5, 5));
     
    189183     */
    190184    protected final JPanel buildButtonPanel() {
    191         btnDownload = new JButton(new DownloadAction());
     185        btnDownload = new JButton(new DownloadAction(false));
     186        btnDownloadNewLayer = new JButton(new DownloadAction(true));
    192187        btnCancel = new JButton(new CancelAction());
    193188        btnHelp = new JButton(
     
    197192
    198193        pnl.add(btnDownload);
     194        pnl.add(btnDownloadNewLayer);
    199195        pnl.add(btnCancel);
    200196        pnl.add(btnHelp);
     
    205201        InputMapUtils.enableEnter(btnHelp);
    206202
    207         InputMapUtils.addEnterActionWhenAncestor(cbNewLayer, btnDownload.getAction());
    208203        InputMapUtils.addEnterActionWhenAncestor(cbStartup, btnDownload.getAction());
    209204        InputMapUtils.addEnterActionWhenAncestor(cbZoomToDownloadedData, btnDownload.getAction());
     
    297292
    298293    /**
    299      * Replies true if the user requires to download into a new layer
    300      *
    301      * @return true if the user requires to download into a new layer
    302      */
    303     public boolean isNewLayerRequired() {
    304         return cbNewLayer.isSelected();
    305     }
    306 
    307     /**
    308294     * Replies true if the user requires to zoom to new downloaded data
    309295     *
     
    368354        downloadSourcesTab.getAllPanels().forEach(AbstractDownloadSourcePanel::rememberSettings);
    369355        downloadSourcesTab.getSelectedPanel().ifPresent(panel -> DOWNLOAD_SOURCE_TAB.put(panel.getSimpleName()));
    370         DOWNLOAD_NEWLAYER.put(cbNewLayer.isSelected());
    371356        DOWNLOAD_ZOOMTODATA.put(cbZoomToDownloadedData.isSelected());
    372357        if (currentBounds != null) {
     
    379364     */
    380365    public void restoreSettings() {
    381         cbNewLayer.setSelected(DOWNLOAD_NEWLAYER.get());
    382366        cbStartup.setSelected(isAutorunEnabled());
    383367        cbZoomToDownloadedData.setSelected(DOWNLOAD_ZOOMTODATA.get());
     
    475459     * the download dialog.
    476460     */
    477     public DownloadSettings getDownloadSettings() {
    478         return new DownloadSettings(currentBounds, isNewLayerRequired(), isZoomToDownloadedDataRequired());
     461    public DownloadSettings getDownloadSettings(boolean newLayer) {
     462        return new DownloadSettings(currentBounds, newLayer, isZoomToDownloadedDataRequired());
    479463    }
    480464
     
    543527     */
    544528    class DownloadAction extends AbstractAction {
    545         DownloadAction() {
    546             putValue(NAME, tr("Download"));
    547             new ImageProvider("download").getResource().attachImageIcon(this);
    548             putValue(SHORT_DESCRIPTION, tr("Click to download the currently selected area"));
     529        final boolean newLayer;
     530        DownloadAction(boolean newLayer) {
     531            this.newLayer = newLayer;
     532            if (!newLayer) {
     533                putValue(NAME, tr("Download"));
     534                putValue(SHORT_DESCRIPTION, tr("Click to download the currently selected area"));
     535                new ImageProvider("download").getResource().attachImageIcon(this);
     536            } else {
     537                putValue(NAME, tr("Download as new layer"));
     538                putValue(SHORT_DESCRIPTION, tr("Click to download the currently selected area into a new data layer"));
     539                new ImageProvider("download_new_layer").getResource().attachImageIcon(this);
     540            }
    549541            setEnabled(!NetworkManager.isOffline(OnlineResource.OSM_API));
    550542        }
     
    557549            rememberSettings();
    558550            downloadSourcesTab.getSelectedPanel().ifPresent(panel -> {
    559                 DownloadSettings downloadSettings = getDownloadSettings();
     551                DownloadSettings downloadSettings = getDownloadSettings(newLayer);
    560552                if (panel.checkDownload(downloadSettings)) {
    561553                    setCanceled(false);
Note: See TracChangeset for help on using the changeset viewer.