Changeset 8932 in josm
- Timestamp:
- 2015-10-23T12:12:50+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OverpassDownloadAction.java
r8756 r8932 11 11 import java.awt.event.ActionEvent; 12 12 import java.awt.event.ActionListener; 13 import java.awt.event.FocusEvent; 14 import java.awt.event.FocusListener; 13 15 import java.awt.event.KeyEvent; 14 16 import java.util.ArrayList; … … 21 23 22 24 import javax.swing.AbstractAction; 25 import javax.swing.Action; 26 import javax.swing.ActionMap; 23 27 import javax.swing.JButton; 24 28 import javax.swing.JComponent; … … 83 87 } 84 88 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; 90 122 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", 93 125 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>()); 95 128 96 129 private OverpassDownloadDialog(Component parent) { … … 113 146 protected void buildMainPanelAboveDownloadSelections(JPanel pnl) { 114 147 148 DisableActionsFocusListener disableActionsFocusListener = 149 new DisableActionsFocusListener(slippyMapChooser.getNavigationComponentActionMap()); 150 115 151 pnl.add(new JLabel(), GBC.eol()); // needed for the invisible checkboxes cbDownloadGpxData, cbDownloadNotes 116 152 … … 118 154 overpassWizard = new HistoryComboBox(); 119 155 overpassWizard.setToolTipText(tooltip); 156 overpassWizard.getEditor().getEditorComponent().addFocusListener(disableActionsFocusListener); 120 157 final JButton buildQuery = new JButton(tr("Build query")); 121 158 buildQuery.addActionListener(new AbstractAction() { … … 143 180 overpassQuery = new JosmTextArea("", 8, 80); 144 181 overpassQuery.setFont(GuiHelper.getMonospacedFont(overpassQuery)); 182 overpassQuery.addFocusListener(disableActionsFocusListener); 145 183 JScrollPane scrollPane = new JScrollPane(overpassQuery); 146 184 final JPanel pane = new JPanel(new BorderLayout()); … … 160 198 161 199 overpassServer = new HistoryComboBox(); 200 overpassServer.getEditor().getEditorComponent().addFocusListener(disableActionsFocusListener); 162 201 pnl.add(new JLabel(tr("Overpass server: ")), GBC.std().insets(5, 5, 5, 5)); 163 202 pnl.add(overpassServer, GBC.eol().fill(GBC.HORIZONTAL)); 164 165 203 } 166 204 -
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r8840 r8932 117 117 pnl.add(cbDownloadNotes, GBC.eol().insets(50, 5, 1, 5)); 118 118 119 // must be created before hook 120 slippyMapChooser = new SlippyMapChooser(); 121 119 122 // hook for subclasses 120 123 buildMainPanelAboveDownloadSelections(pnl); 121 122 slippyMapChooser = new SlippyMapChooser();123 124 124 125 // predefined download selections -
trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java
r8510 r8932 9 9 import java.beans.PropertyChangeListener; 10 10 11 import javax.swing.ActionMap; 11 12 import javax.swing.JPanel; 12 13 … … 16 17 17 18 /** 18 * JComponent that displays the slippy map tiles 19 * JComponent that displays the slippy map tiles. 19 20 * 20 21 * @author Tim Haussmann 21 * 22 * @since 1390 22 23 */ 23 24 public class SlippyMapChooser extends JPanel implements DownloadSelection, PropertyChangeListener { 24 25 25 26 private DownloadDialog iGui; 26 private SlippyMapBBoxChooser pnlSlippyMapBBoxChooser;27 private final SlippyMapBBoxChooser pnlSlippyMapBBoxChooser; 27 28 // standard dimension 28 29 private Dimension iDownloadDialogDimension; … … 87 88 } 88 89 } 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 } 89 99 }
Note:
See TracChangeset
for help on using the changeset viewer.