Ticket #21619: 21619.patch
File 21619.patch, 3.2 KB (added by , 3 years ago) |
---|
-
src/org/openstreetmap/josm/gui/preferences/projection/CustomProjectionChoice.java
16 16 import javax.swing.JComponent; 17 17 import javax.swing.JLabel; 18 18 import javax.swing.JPanel; 19 import javax.swing.plaf.basic.BasicComboBoxEditor;20 19 21 20 import org.openstreetmap.josm.data.projection.CustomProjection; 22 21 import org.openstreetmap.josm.data.projection.Projection; … … 26 25 import org.openstreetmap.josm.gui.widgets.AbstractTextComponentValidator; 27 26 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; 28 27 import org.openstreetmap.josm.gui.widgets.HtmlPanel; 29 import org.openstreetmap.josm.gui.widgets.JosmTextField;30 28 import org.openstreetmap.josm.tools.GBC; 31 29 import org.openstreetmap.josm.tools.ImageProvider; 32 30 import org.openstreetmap.josm.tools.Logging; … … 52 50 53 51 private static class PreferencePanel extends JPanel { 54 52 55 public JosmTextField input;56 53 private HistoryComboBox cbInput; 57 54 58 55 PreferencePanel(String initialText, ActionListener listener) { … … 60 57 } 61 58 62 59 private void build(String initialText, final ActionListener listener) { 63 input = new JosmTextField(30);64 60 cbInput = new HistoryComboBox(); 65 cbInput.setEditor(new BasicComboBoxEditor() { 66 @Override 67 protected JosmTextField createEditorComponent() { 68 return input; 69 } 70 }); 61 cbInput.getEditorComponent().setColumns(30); 71 62 List<String> samples = Arrays.asList( 72 63 "+proj=lonlat +ellps=WGS84 +datum=WGS84 +bounds=-180,-90,180,90", 73 64 "+proj=tmerc +lat_0=0 +lon_0=9 +k_0=1 +x_0=3500000 +y_0=0 +ellps=bessel +nadgrids=BETA2007.gsb"); … … 79 70 final JLabel valStatus = new JLabel(); 80 71 valStatus.setVisible(false); 81 72 82 final AbstractTextComponentValidator val = new AbstractTextComponentValidator( input, false, false, false) {73 final AbstractTextComponentValidator val = new AbstractTextComponentValidator(cbInput.getEditorComponent(), false, false, false) { 83 74 84 75 private String error; 85 76 … … 97 88 public boolean isValid() { 98 89 try { 99 90 CustomProjection test = new CustomProjection(); 100 test.update( input.getText());91 test.update(cbInput.getEditorComponent().getText()); 101 92 } catch (ProjectionConfigurationException ex) { 102 93 Logging.warn(ex); 103 94 error = ex.getMessage(); … … 220 211 throw new IllegalArgumentException("Unsupported panel: "+panel); 221 212 } 222 213 PreferencePanel prefPanel = (PreferencePanel) panel; 223 String pref = prefPanel. input.getText();214 String pref = prefPanel.cbInput.getEditorComponent().getText(); 224 215 prefPanel.rememberHistory(); 225 216 return Collections.singleton(pref); 226 217 }