Changeset 9242 in josm for trunk/src


Ignore:
Timestamp:
2016-01-01T19:42:27+01:00 (9 years ago)
Author:
simon04
Message:

fix #7670 - Add Overpass settings to main preference

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
4 edited

Legend:

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

    r9241 r9242  
    1515import java.awt.event.KeyEvent;
    1616import java.util.ArrayList;
    17 import java.util.Arrays;
    1817import java.util.Collection;
    1918import java.util.Collections;
     
    4140import org.openstreetmap.josm.data.preferences.CollectionProperty;
    4241import org.openstreetmap.josm.data.preferences.IntegerProperty;
    43 import org.openstreetmap.josm.data.preferences.StringProperty;
    4442import org.openstreetmap.josm.gui.HelpAwareOptionPane;
    4543import org.openstreetmap.josm.gui.download.DownloadDialog;
     44import org.openstreetmap.josm.gui.preferences.server.OverpassServerPreference;
    4645import org.openstreetmap.josm.gui.util.GuiHelper;
    4746import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
     
    5857 */
    5958public class OverpassDownloadAction extends JosmAction {
    60 
    61     /**
    62      * The {@link StringProperty property} of the currently selected Overpass server.
    63      *
    64      * @since 9241
    65      */
    66     public static final StringProperty OVERPASS_SERVER = new StringProperty("download.overpass.server", "http://overpass-api.de/api/");
    6759
    6860    /**
     
    8880            DownloadOsmTask task = new DownloadOsmTask();
    8981            Future<?> future = task.download(
    90                     new OverpassDownloadReader(area, dialog.getOverpassServer(), dialog.getOverpassQuery()),
     82                    new OverpassDownloadReader(area, OverpassServerPreference.getOverpassServer(), dialog.getOverpassQuery()),
    9183                    dialog.isNewLayerRequired(), area, null);
    9284            Main.worker.submit(new PostDownloadHandler(task, future));
     
    124116    private static final class OverpassDownloadDialog extends DownloadDialog {
    125117
    126         private HistoryComboBox overpassServer;
    127118        private HistoryComboBox overpassWizard;
    128119        private JosmTextArea overpassQuery;
    129120        private static OverpassDownloadDialog instance;
    130         private static final CollectionProperty OVERPASS_SERVER_HISTORY = new CollectionProperty("download.overpass.servers",
    131                 Arrays.asList("http://overpass-api.de/api/", "http://overpass.osm.rambler.ru/cgi/"));
    132121        private static final CollectionProperty OVERPASS_WIZARD_HISTORY = new CollectionProperty("download.overpass.wizard",
    133122                new ArrayList<String>());
     
    203192            pnl.add(pane, gbc);
    204193
    205             overpassServer = new HistoryComboBox();
    206             overpassServer.getEditor().getEditorComponent().addFocusListener(disableActionsFocusListener);
    207             pnl.add(new JLabel(tr("Overpass server: ")), GBC.std().insets(5, 5, 5, 5));
    208             pnl.add(overpassServer, GBC.eol().fill(GBC.HORIZONTAL));
    209         }
    210 
    211         public String getOverpassServer() {
    212             return overpassServer.getText();
    213194        }
    214195
     
    224205        public void restoreSettings() {
    225206            super.restoreSettings();
    226             overpassServer.setPossibleItems(OVERPASS_SERVER_HISTORY.get());
    227             overpassServer.setText(OVERPASS_SERVER.get());
    228207            overpassWizard.setPossibleItems(OVERPASS_WIZARD_HISTORY.get());
    229208        }
     
    233212            super.rememberSettings();
    234213            overpassWizard.addCurrentItemToHistory();
    235             OVERPASS_SERVER.put(getOverpassServer());
    236             OVERPASS_SERVER_HISTORY.put(overpassServer.getHistory());
    237214            OVERPASS_WIZARD_HISTORY.put(overpassWizard.getHistory());
    238215            OverpassQueryHistoryPopup.addToHistory(getOverpassQuery());
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java

    r9239 r9242  
    5252import org.openstreetmap.josm.gui.preferences.remotecontrol.RemoteControlPreference;
    5353import org.openstreetmap.josm.gui.preferences.server.AuthenticationPreference;
     54import org.openstreetmap.josm.gui.preferences.server.OverpassServerPreference;
    5455import org.openstreetmap.josm.gui.preferences.server.ProxyPreference;
    5556import org.openstreetmap.josm.gui.preferences.server.ServerAccessPreference;
     
    561562        settingsFactories.add(new AuthenticationPreference.Factory());
    562563        settingsFactories.add(new ProxyPreference.Factory());
     564        settingsFactories.add(new OverpassServerPreference.Factory());
    563565        settingsFactories.add(new MapPreference.Factory());
    564566        settingsFactories.add(new ProjectionPreference.Factory());
  • trunk/src/org/openstreetmap/josm/io/MultiFetchOverpassObjectReader.java

    r9241 r9242  
    22package org.openstreetmap.josm.io;
    33
    4 import org.openstreetmap.josm.actions.OverpassDownloadAction;
    54import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     5import org.openstreetmap.josm.gui.preferences.server.OverpassServerPreference;
    66import org.openstreetmap.josm.tools.Utils;
    77
     
    2929    @Override
    3030    protected String getBaseUrl() {
    31         return OverpassDownloadAction.OVERPASS_SERVER.get();
     31        return OverpassServerPreference.getOverpassServer();
    3232    }
    3333}
  • trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java

    r9241 r9242  
    3535import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
    3636import org.openstreetmap.josm.data.osm.Way;
     37import org.openstreetmap.josm.gui.preferences.server.OverpassServerPreference;
    3738import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    3839import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    8586    /**
    8687     * Creates a new instance of {@link MultiFetchServerObjectReader} or {@link MultiFetchOverpassObjectReader}
    87      * depending on the {@code download.overpass.for-multi-fetch} preference.
     88     * depending on the {@link OverpassServerPreference#useForMultiFetch preference}.
    8889     *
    8990     * @return a new instance
     
    9192     */
    9293    public static MultiFetchServerObjectReader create() {
    93         return create(Main.pref.getBoolean("download.overpass.for-multi-fetch", false));
     94        return create(OverpassServerPreference.useForMultiFetch());
    9495    }
    9596
Note: See TracChangeset for help on using the changeset viewer.