Changeset 12880 in josm for trunk/src/org


Ignore:
Timestamp:
2017-09-20T21:33:06+02:00 (7 years ago)
Author:
simon04
Message:

see #15057, see #15264 - Rename OverpassQueryList to UserQueryList

This allows to use it also in the wikipedia plugin without name confusion.

Location:
trunk/src/org/openstreetmap/josm/gui/download
Files:
1 edited
1 moved

Legend:

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

    r12816 r12880  
    9191
    9292        private final JosmTextArea overpassQuery;
    93         private final OverpassQueryList overpassQueryList;
     93        private final UserQueryList overpassQueryList;
    9494
    9595        /**
     
    134134
    135135
    136             this.overpassQueryList = new OverpassQueryList(this, this.overpassQuery);
     136            this.overpassQueryList = new UserQueryList(this, this.overpassQuery, "download.overpass.query");
    137137            this.overpassQueryList.setPreferredSize(new Dimension(350, 300));
    138138
     
    288288
    289289        /**
    290          * Action that delegates snippet creation to {@link OverpassQueryList#createNewItem()}.
     290         * Action that delegates snippet creation to {@link UserQueryList#createNewItem()}.
    291291         */
    292292        private class AddSnippetAction extends AbstractAction {
     
    308308
    309309        /**
    310          * Action that delegates snippet removal to {@link OverpassQueryList#removeSelectedItem()}.
     310         * Action that delegates snippet removal to {@link UserQueryList#removeSelectedItem()}.
    311311         */
    312312        private class RemoveSnippetAction extends AbstractAction implements ListSelectionListener {
     
    341341
    342342        /**
    343          * Action that delegates snippet edit to {@link OverpassQueryList#editSelectedItem()}.
     343         * Action that delegates snippet edit to {@link UserQueryList#editSelectedItem()}.
    344344         */
    345345        private class EditSnippetAction extends AbstractAction implements ListSelectionListener {
  • trunk/src/org/openstreetmap/josm/gui/download/UserQueryList.java

    r12879 r12880  
    5555
    5656/**
    57  * A component to select user saved Overpass queries.
    58  * @since 12574
     57 * A component to select user saved queries.
     58 * @since 12880
     59 * @since 12574 as OverpassQueryList
    5960 */
    60 public final class OverpassQueryList extends SearchTextResultListPanel<OverpassQueryList.SelectorItem> {
     61public final class UserQueryList extends SearchTextResultListPanel<UserQueryList.SelectorItem> {
    6162
    6263    private static final DateTimeFormatter FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss, dd-MM-yyyy");
     
    7980    private static final String QUERY_KEY = "query";
    8081    private static final String LAST_EDIT_KEY = "lastEdit";
    81     private static final String PREFERENCE_ITEMS = "download.overpass.query";
     82    private final String preferenceKey;
    8283
    8384    private static final String TRANSLATED_HISTORY = tr("history");
     
    8788     * @param parent The parent of this component.
    8889     * @param target The text component to which the queries must be added.
    89      */
    90     public OverpassQueryList(Component parent, JTextComponent target) {
     90     * @param preferenceKey The {@linkplain org.openstreetmap.josm.spi.preferences.IPreferences preference} key to store the user queries
     91     */
     92    public UserQueryList(Component parent, JTextComponent target, String preferenceKey) {
    9193        this.target = target;
    9294        this.componentParent = parent;
     95        this.preferenceKey = preferenceKey;
    9396        this.items = restorePreferences();
    9497
    95         OverpassQueryListMouseAdapter mouseHandler = new OverpassQueryListMouseAdapter(lsResult, lsResultModel);
    96         super.lsResult.setCellRenderer(new OverpassQueryCellRendered());
     98        QueryListMouseAdapter mouseHandler = new QueryListMouseAdapter(lsResult, lsResultModel);
     99        super.lsResult.setCellRenderer(new QueryCellRendered());
    97100        super.setDblClickListener(e -> doubleClickEvent());
    98101        super.lsResult.addMouseListener(mouseHandler);
     
    255258        }
    256259
    257         Config.getPref().putListOfMaps(PREFERENCE_ITEMS, toSave);
     260        Config.getPref().putListOfMaps(preferenceKey, toSave);
    258261    }
    259262
     
    262265     * @return A set of the user saved items.
    263266     */
    264     private static Map<String, SelectorItem> restorePreferences() {
     267    private Map<String, SelectorItem> restorePreferences() {
    265268        Collection<Map<String, String>> toRetrieve =
    266                 Config.getPref().getListOfMaps(PREFERENCE_ITEMS, Collections.emptyList());
     269                Config.getPref().getListOfMaps(preferenceKey, Collections.emptyList());
    267270        Map<String, SelectorItem> result = new HashMap<>();
    268271
     
    285288    }
    286289
    287     private class OverpassQueryListMouseAdapter extends MouseAdapter {
     290    private class QueryListMouseAdapter extends MouseAdapter {
    288291
    289292        private final JList<SelectorItem> list;
     
    292295        private final JPopupMenu elementPopup = new JPopupMenu();
    293296
    294         OverpassQueryListMouseAdapter(JList<SelectorItem> list, ResultListModel<SelectorItem> listModel) {
     297        QueryListMouseAdapter(JList<SelectorItem> list, ResultListModel<SelectorItem> listModel) {
    295298            this.list = list;
    296299            this.model = listModel;
     
    372375     * This class defines the way each element is rendered in the list.
    373376     */
    374     private static class OverpassQueryCellRendered extends JLabel implements ListCellRenderer<SelectorItem> {
    375 
    376         OverpassQueryCellRendered() {
     377    private static class QueryCellRendered extends JLabel implements ListCellRenderer<SelectorItem> {
     378
     379        QueryCellRendered() {
    377380            setOpaque(true);
    378381        }
     
    550553    /**
    551554     * This class represents an Overpass query used by the user that can be
    552      * shown within {@link OverpassQueryList}.
     555     * shown within {@link UserQueryList}.
    553556     */
    554557    public static class SelectorItem {
     
    602605
    603606        /**
    604          * Gets the overpass query of this item.
    605          * @return A string representing the overpass query of this item.
     607         * Gets the query of this item.
     608         * @return A string representing the query of this item.
    606609         */
    607610        public String getQuery() {
Note: See TracChangeset for help on using the changeset viewer.