Changeset 7536 in josm for trunk/src/org
- Timestamp:
- 2014-09-14T21:43:59+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r7315 r7536 78 78 * 79 79 * @author imi 80 * @since 74 80 81 */ 81 82 public class Preferences { … … 1660 1661 1661 1662 String[] obsolete = { 1662 "downloadAlong.downloadAlongTrack.distance", // 07/2013 - can be removed mid-2014. Replaced by downloadAlongWay.distance1663 "downloadAlong.downloadAlongTrack.area", // 07/2013 - can be removed mid-2014. Replaced by downloadAlongWay.area1664 "gpxLayer.downloadAlongTrack.distance", // 07/2013 - can be removed mid-2014. Replaced by downloadAlongTrack.distance1665 "gpxLayer.downloadAlongTrack.area", // 07/2013 - can be removed mid-2014. Replaced by downloadAlongTrack.area1666 "gpxLayer.downloadAlongTrack.near", // 07/2013 - can be removed mid-2014. Replaced by downloadAlongTrack.near1667 1663 "validator.tests", // 01/2014 - can be removed end-2014. Replaced by validator.skip 1668 1664 "validator.testsBeforeUpload", // 01/2014 - can be removed end-2014. Replaced by validator.skipBeforeUpload … … 1681 1677 } 1682 1678 1683 public static boolean isEqual(Setting<?> a, Setting<?> b) {1684 if (a == null) return b == null;1685 return a.equals(b);1686 }1687 1688 1679 /** 1689 1680 * Enables or not the preferences file auto-save mechanism (save each time a setting is changed). -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongPanel.java
r7005 r7536 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Dimension; 6 7 import java.awt.GridBagLayout; 7 8 … … 11 12 import javax.swing.JOptionPane; 12 13 import javax.swing.JPanel; 14 import javax.swing.JSpinner; 15 import javax.swing.SpinnerNumberModel; 13 16 import javax.swing.event.ChangeEvent; 14 17 import javax.swing.event.ChangeListener; … … 25 28 */ 26 29 public class DownloadAlongPanel extends JPanel { 27 30 28 31 // Preferences keys 29 32 private final String prefOsm; … … 37 40 private final JCheckBox cbDownloadGpxData; 38 41 39 // Legacy list of values 40 private static final Integer[] dist = { 5000, 500, 50 }; 41 private static final Integer[] area = { 20, 10, 5, 1 }; 42 43 private final JList<String> buffer; 44 private final JList<String> maxRect; 42 private final JSpinner buffer; 43 private final JSpinner maxRect; 45 44 private final JList<String> downloadNear; 46 45 47 46 /** 48 47 * Constructs a new {@code DownloadPanel}. … … 55 54 public DownloadAlongPanel(String prefOsm, String prefGps, String prefDist, String prefArea, String prefNear) { 56 55 super(new GridBagLayout()); 57 56 58 57 this.prefOsm = prefOsm; 59 58 this.prefGps = prefGps; … … 64 63 cbDownloadOsmData = new JCheckBox(tr("OpenStreetMap data"), Main.pref.getBoolean(prefOsm, true)); 65 64 cbDownloadOsmData.setToolTipText(tr("Select to download OSM data.")); 66 add(cbDownloadOsmData, 65 add(cbDownloadOsmData, GBC.std().insets(1,5,1,5)); 67 66 cbDownloadGpxData = new JCheckBox(tr("Raw GPS data"), Main.pref.getBoolean(prefGps, false)); 68 67 cbDownloadGpxData.setToolTipText(tr("Select to download GPS traces.")); 69 add(cbDownloadGpxData, GBC.eol().insets(5,5,1,5)); 70 71 add(new JLabel(tr("Download everything within:")), GBC.eol()); 72 String[] s = new String[dist.length]; 73 for (int i = 0; i < dist.length; ++i) { 74 s[i] = tr("{0} meters", dist[i]); 75 } 76 buffer = new JList<>(s); 77 78 double distanceValue = Main.pref.getDouble(prefDist, dist[0]); 79 int distanceLegacyIndex = 0; 80 for (int i = 0; i < dist.length; i++) { 81 if (dist[i] == (int)distanceValue) { 82 distanceLegacyIndex = i; 83 break; 68 add(cbDownloadGpxData, GBC.eol().insets(5,5,1,5)); 69 70 add(new JLabel(tr("Download everything within:")), GBC.std()); 71 buffer = new JSpinner(new SpinnerNumberModel(50.0, 10.0, 5000.0, 1.0)); 72 add(buffer, GBC.std().insets(5,5,5,5)); 73 add(new JLabel(tr("meters")), GBC.eol()); 74 75 add(new JLabel(tr("Maximum area per request:")), GBC.std()); 76 maxRect = new JSpinner(new SpinnerNumberModel(20.0, 1.0, 25.0, 1.0)) { 77 @Override 78 public Dimension getPreferredSize() { 79 return buffer.getPreferredSize(); 84 80 } 85 } 86 87 buffer.setSelectedIndex(distanceLegacyIndex); 88 add(buffer, GBC.eol()); 81 }; 82 add(maxRect, GBC.std().insets(5,5,5,5)); 83 add(new JLabel(tr("sq km")), GBC.eol()); 89 84 90 add(new JLabel(tr("Maximum area per request:")), GBC.eol());91 s = new String[area.length];92 for (int i = 0; i < area.length; ++i) {93 s[i] = tr("{0} sq km", area[i]);94 }95 maxRect = new JList<>(s);96 97 double areaValue = Main.pref.getDouble(prefArea, area[0]);98 int areaLegacyIndex = 0;99 for (int i = 0; i < area.length; i++) {100 if (area[i] == (int)areaValue) {101 areaLegacyIndex = i;102 break;103 }104 }105 106 maxRect.setSelectedIndex(areaLegacyIndex);107 add(maxRect, GBC.eol());108 109 85 if (prefNear != null) { 110 86 add(new JLabel(tr("Download near:")), GBC.eol()); … … 116 92 } 117 93 } 118 94 119 95 /** 120 96 * Gets the maximum distance in meters … … 122 98 */ 123 99 public final double getDistance() { 124 return dist[buffer.getSelectedIndex()];100 return (double) buffer.getValue(); 125 101 } 126 102 … … 130 106 */ 131 107 public final double getArea() { 132 return area[maxRect.getSelectedIndex()];108 return (double) maxRect.getValue(); 133 109 } 134 110 135 111 /** 136 112 * Gets the "download near" choosen value … … 140 116 return downloadNear.getSelectedIndex(); 141 117 } 142 118 143 119 /** 144 120 * Replies true if the user selected to download OSM data … … 158 134 return cbDownloadGpxData.isSelected(); 159 135 } 160 136 161 137 /** 162 138 * Remembers the current settings in the download panel … … 171 147 } 172 148 } 173 149 174 150 /** 175 151 * Adds a change listener to comboboxes … … 202 178 ) 203 179 }; 204 180 205 181 addChangeListener(new ChangeListener() { 206 182 @Override public void stateChanged(ChangeEvent e) { -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java
r7027 r7536 17 17 import java.util.Map; 18 18 import java.util.Map.Entry; 19 import java.util.Objects; 19 20 20 21 import javax.swing.AbstractAction; … … 287 288 PrefEntry en = new PrefEntry(e.getKey(), value, def, false); 288 289 // after changes we have nondefault value. Value is changed if is not equal to old value 289 if ( !Preferences.isEqual(old, value)) {290 if (!Objects.equals(old, value)) { 290 291 en.markAsChanged(); 291 292 }
Note:
See TracChangeset
for help on using the changeset viewer.