Changeset 9485 in josm


Ignore:
Timestamp:
2016-01-16T13:50:05+01:00 (9 years ago)
Author:
simon04
Message:

fix #12384 - Keep history of custom OSM Server URLs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java

    r9353 r9485  
    1616import java.net.MalformedURLException;
    1717import java.net.URL;
     18import java.util.Arrays;
    1819
    1920import javax.swing.AbstractAction;
     
    2829
    2930import org.openstreetmap.josm.Main;
     31import org.openstreetmap.josm.data.preferences.CollectionProperty;
    3032import org.openstreetmap.josm.gui.SideButton;
    3133import org.openstreetmap.josm.gui.help.HelpUtil;
    3234import org.openstreetmap.josm.gui.widgets.AbstractTextComponentValidator;
    33 import org.openstreetmap.josm.gui.widgets.JosmTextField;
     35import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
    3436import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
    3537import org.openstreetmap.josm.io.OsmApi;
     
    4951    private JLabel lblValid;
    5052    private JLabel lblApiUrl;
    51     private JosmTextField tfOsmServerUrl;
     53    private HistoryComboBox tfOsmServerUrl;
    5254    private transient ApiUrlValidator valOsmServerUrl;
    5355    private SideButton btnTest;
    5456    /** indicates whether to use the default OSM URL or not */
    5557    private JCheckBox cbUseDefaultServerUrl;
     58    private final CollectionProperty SERVER_URL_HISTORY = new CollectionProperty("osm-server.url-history", Arrays.asList(
     59            "http://api06.dev.openstreetmap.org/api", "http://master.apis.dev.openstreetmap.org/api"));
    5660
    5761    private transient ApiUrlPropagator propagator;
     
    8791        gc.gridx = 1;
    8892        gc.weightx = 1.0;
    89         add(tfOsmServerUrl = new JosmTextField(), gc);
     93        add(tfOsmServerUrl = new HistoryComboBox(), gc);
    9094        lblApiUrl.setLabelFor(tfOsmServerUrl);
    91         SelectAllOnFocusGainedDecorator.decorate(tfOsmServerUrl);
    92         valOsmServerUrl = new ApiUrlValidator(tfOsmServerUrl);
     95        SelectAllOnFocusGainedDecorator.decorate(tfOsmServerUrl.getEditorComponent());
     96        valOsmServerUrl = new ApiUrlValidator(tfOsmServerUrl.getEditorComponent());
    9397        valOsmServerUrl.validate();
    9498        propagator = new ApiUrlPropagator();
     
    103107        gc.weightx = 0.0;
    104108        ValidateApiUrlAction actTest = new ValidateApiUrlAction();
    105         tfOsmServerUrl.getDocument().addDocumentListener(actTest);
     109        tfOsmServerUrl.getEditorComponent().getDocument().addDocumentListener(actTest);
    106110        add(btnTest = new SideButton(actTest), gc);
    107111    }
     
    128132            propagator.propagate(url);
    129133        }
     134        tfOsmServerUrl.setPossibleItems(SERVER_URL_HISTORY.get());
    130135    }
    131136
     
    142147        } else {
    143148            Main.pref.put("osm-server.url", hmiUrl);
     149            tfOsmServerUrl.addCurrentItemToHistory();
     150            SERVER_URL_HISTORY.put(tfOsmServerUrl.getHistory());
    144151        }
    145152        String newUrl = OsmApi.getOsmApi().getServerUrl();
Note: See TracChangeset for help on using the changeset viewer.