Changeset 8932 in josm


Ignore:
Timestamp:
2015-10-23T12:12:50+02:00 (9 years ago)
Author:
Don-vip
Message:

fix #11971 - -/=`key in Overpass Download changes map size

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

Legend:

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

    r8756 r8932  
    1111import java.awt.event.ActionEvent;
    1212import java.awt.event.ActionListener;
     13import java.awt.event.FocusEvent;
     14import java.awt.event.FocusListener;
    1315import java.awt.event.KeyEvent;
    1416import java.util.ArrayList;
     
    2123
    2224import javax.swing.AbstractAction;
     25import javax.swing.Action;
     26import javax.swing.ActionMap;
    2327import javax.swing.JButton;
    2428import javax.swing.JComponent;
     
    8387    }
    8488
    85     static final class OverpassDownloadDialog extends DownloadDialog {
    86 
    87         protected HistoryComboBox overpassServer;
    88         protected HistoryComboBox overpassWizard;
    89         protected JosmTextArea overpassQuery;
     89    private static final class DisableActionsFocusListener implements FocusListener {
     90
     91        private final ActionMap actionMap;
     92
     93        private DisableActionsFocusListener(ActionMap actionMap) {
     94            this.actionMap = actionMap;
     95        }
     96
     97        @Override
     98        public void focusGained(FocusEvent e) {
     99            enableActions(false);
     100        }
     101
     102        @Override
     103        public void focusLost(FocusEvent e) {
     104            enableActions(true);
     105        }
     106
     107        private void enableActions(boolean enabled) {
     108            for (Object key : actionMap.allKeys()) {
     109                Action action = actionMap.get(key);
     110                if (action != null) {
     111                    action.setEnabled(enabled);
     112                }
     113            }
     114        }
     115    }
     116
     117    private static final class OverpassDownloadDialog extends DownloadDialog {
     118
     119        private HistoryComboBox overpassServer;
     120        private HistoryComboBox overpassWizard;
     121        private JosmTextArea overpassQuery;
    90122        private static OverpassDownloadDialog instance;
    91         static final StringProperty OVERPASS_SERVER = new StringProperty("download.overpass.server", "http://overpass-api.de/api/");
    92         static final CollectionProperty OVERPASS_SERVER_HISTORY = new CollectionProperty("download.overpass.servers",
     123        private static final StringProperty OVERPASS_SERVER = new StringProperty("download.overpass.server", "http://overpass-api.de/api/");
     124        private static final CollectionProperty OVERPASS_SERVER_HISTORY = new CollectionProperty("download.overpass.servers",
    93125                Arrays.asList("http://overpass-api.de/api/", "http://overpass.osm.rambler.ru/cgi/"));
    94         static final CollectionProperty OVERPASS_WIZARD_HISTORY = new CollectionProperty("download.overpass.wizard", new ArrayList<String>());
     126        private static final CollectionProperty OVERPASS_WIZARD_HISTORY = new CollectionProperty("download.overpass.wizard",
     127                new ArrayList<String>());
    95128
    96129        private OverpassDownloadDialog(Component parent) {
     
    113146        protected void buildMainPanelAboveDownloadSelections(JPanel pnl) {
    114147
     148            DisableActionsFocusListener disableActionsFocusListener =
     149                    new DisableActionsFocusListener(slippyMapChooser.getNavigationComponentActionMap());
     150
    115151            pnl.add(new JLabel(), GBC.eol()); // needed for the invisible checkboxes cbDownloadGpxData, cbDownloadNotes
    116152
     
    118154            overpassWizard = new HistoryComboBox();
    119155            overpassWizard.setToolTipText(tooltip);
     156            overpassWizard.getEditor().getEditorComponent().addFocusListener(disableActionsFocusListener);
    120157            final JButton buildQuery = new JButton(tr("Build query"));
    121158            buildQuery.addActionListener(new AbstractAction() {
     
    143180            overpassQuery = new JosmTextArea("", 8, 80);
    144181            overpassQuery.setFont(GuiHelper.getMonospacedFont(overpassQuery));
     182            overpassQuery.addFocusListener(disableActionsFocusListener);
    145183            JScrollPane scrollPane = new JScrollPane(overpassQuery);
    146184            final JPanel pane = new JPanel(new BorderLayout());
     
    160198
    161199            overpassServer = new HistoryComboBox();
     200            overpassServer.getEditor().getEditorComponent().addFocusListener(disableActionsFocusListener);
    162201            pnl.add(new JLabel(tr("Overpass server: ")), GBC.std().insets(5, 5, 5, 5));
    163202            pnl.add(overpassServer, GBC.eol().fill(GBC.HORIZONTAL));
    164 
    165203        }
    166204
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r8840 r8932  
    117117        pnl.add(cbDownloadNotes, GBC.eol().insets(50, 5, 1, 5));
    118118
     119        // must be created before hook
     120        slippyMapChooser = new SlippyMapChooser();
     121
    119122        // hook for subclasses
    120123        buildMainPanelAboveDownloadSelections(pnl);
    121 
    122         slippyMapChooser = new SlippyMapChooser();
    123124
    124125        // predefined download selections
  • trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java

    r8510 r8932  
    99import java.beans.PropertyChangeListener;
    1010
     11import javax.swing.ActionMap;
    1112import javax.swing.JPanel;
    1213
     
    1617
    1718/**
    18  * JComponent that displays the slippy map tiles
     19 * JComponent that displays the slippy map tiles.
    1920 *
    2021 * @author Tim Haussmann
    21  *
     22 * @since 1390
    2223 */
    2324public class SlippyMapChooser extends JPanel implements DownloadSelection, PropertyChangeListener {
    2425
    2526    private DownloadDialog iGui;
    26     private SlippyMapBBoxChooser pnlSlippyMapBBoxChooser;
     27    private final SlippyMapBBoxChooser pnlSlippyMapBBoxChooser;
    2728    // standard dimension
    2829    private Dimension iDownloadDialogDimension;
     
    8788        }
    8889    }
     90
     91    /**
     92     * Returns the action map of the underlying navigation component.
     93     * @return the action map of the underlying navigation component
     94     * @since 8932
     95     */
     96    public final ActionMap getNavigationComponentActionMap() {
     97        return pnlSlippyMapBBoxChooser.getActionMap();
     98    }
    8999}
Note: See TracChangeset for help on using the changeset viewer.