Changeset 27338 in osm for applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap
- Timestamp:
- 2011-12-29T00:02:22+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixAddressesPlugin.java
r25373 r27338 17 17 import org.openstreetmap.josm.gui.IconToggleButton; 18 18 import org.openstreetmap.josm.gui.MapFrame; 19 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 19 20 import org.openstreetmap.josm.plugins.Plugin; 20 21 import org.openstreetmap.josm.plugins.PluginInformation; … … 66 67 } 67 68 68 69 @Override 70 public PreferenceSetting getPreferenceSetting() { 71 // TODO Auto-generated method stub 72 return getPreferences(); 73 } 69 74 70 75 /** -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixAddressesPreferences.java
r25373 r27338 14 14 package org.openstreetmap.josm.plugins.fixAddresses; 15 15 16 import javax.swing.ButtonGroup; 17 import javax.swing.JCheckBox; 18 19 import org.openstreetmap.josm.Main; 16 20 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 17 21 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 18 22 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 23 import static org.openstreetmap.josm.tools.I18n.tr; 19 24 20 // TODO: Implement21 25 public class FixAddressesPreferences implements PreferenceSetting { 22 private boolean selectGuessedObjects = false; 26 private static final String FIX_ADDRESSES_IGNORE_POST_CODE_KEY = "fixAddresses.ignorePostCode"; 27 private static final String FIX_ADDRESSES_SELECT_GUESSED_OBJECTS_KEY = "fixAddresses.selectGuessedObjects"; 28 29 private JCheckBox cbSelectGuessedObjects = new JCheckBox(tr("Include objects used for guesses")); 30 private JCheckBox cbIgnorePostCode = new JCheckBox(); 23 31 32 /** 33 * Internal factory class. Call <code>FixAddressesPreferences.Factory().createPreferenceSetting()</code> to 34 * create the preference setting instance. 35 */ 24 36 public static class Factory implements PreferenceSettingFactory { 25 37 public PreferenceSetting createPreferenceSetting() { … … 27 39 } 28 40 } 41 42 /** 43 * Internal constructor. 44 */ 45 private FixAddressesPreferences() { 46 loadFromPrefs(); 47 } 48 49 /** 50 * Loads the (initial) preference settings. 51 */ 52 private void loadFromPrefs() { 53 @SuppressWarnings("unused") 54 boolean test = Main.pref.getBoolean(FIX_ADDRESSES_IGNORE_POST_CODE_KEY, false); 55 setSelectGuessedObjects(Main.pref.getBoolean(FIX_ADDRESSES_SELECT_GUESSED_OBJECTS_KEY, false)); 56 setIgnorePostCode(Main.pref.getBoolean(FIX_ADDRESSES_IGNORE_POST_CODE_KEY, false)); 57 } 58 59 /** 60 * Save the preference settings. 61 */ 62 private void saveToPrefs() { 63 Main.pref.put(FIX_ADDRESSES_SELECT_GUESSED_OBJECTS_KEY, isSelectGuessedObjects()); 64 Main.pref.put(FIX_ADDRESSES_IGNORE_POST_CODE_KEY, isIgnorePostCode()); 65 } 29 66 67 /* (non-Javadoc) 68 * @see org.openstreetmap.josm.gui.preferences.PreferenceSetting#addGui(org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane) 69 */ 30 70 @Override 31 71 public void addGui(PreferenceTabbedPane gui) { 32 // TODO Auto-generated method stub 33 72 // Import settings 73 ButtonGroup fixAddrOptions = new ButtonGroup(); 74 fixAddrOptions.add(cbSelectGuessedObjects); 75 fixAddrOptions.add(cbIgnorePostCode); 34 76 } 35 77 78 /* (non-Javadoc) 79 * @see org.openstreetmap.josm.gui.preferences.PreferenceSetting#ok() 80 */ 36 81 @Override 37 82 public boolean ok() { 38 // TODO Auto-generated method stub39 return false;83 saveToPrefs(); 84 return true; 40 85 } 41 86 … … 48 93 */ 49 94 public boolean isSelectGuessedObjects() { 50 return selectGuessedObjects;95 return cbSelectGuessedObjects.isSelected(); 51 96 } 52 97 … … 57 102 */ 58 103 void setSelectGuessedObjects(boolean selectGuessedObjects) { 59 this.selectGuessedObjects= selectGuessedObjects;104 cbSelectGuessedObjects.setSelected(selectGuessedObjects); 60 105 } 61 106 107 /** 108 * Checks if invalid post codes should be ignored. If yes, post codes are neither 109 * checked for existence nor for correctness. 110 * @return 111 */ 112 public boolean isIgnorePostCode() { 113 return cbIgnorePostCode.isSelected(); 114 } 62 115 116 public void setIgnorePostCode(boolean ignorePostCode) { 117 cbIgnorePostCode.setSelected(ignorePostCode); 118 } 63 119 64 120 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OSMAddress.java
r27326 r27338 67 67 public boolean isComplete() { 68 68 boolean isComplete = hasCity() && 69 hasHouseNumber() && 70 (hasPostalCode() && 71 PostalCodeChecker.hasValidPostalCode(this)) && 69 hasHouseNumber() && 72 70 hasCity() && 73 71 hasStreetName(); … … 76 74 if (TagUtils.isStateRequired()) { 77 75 isComplete = isComplete && hasState(); 76 } 77 78 // Check, if user checked "ignore post code" 79 if (!FixAddressesPlugin.getPreferences().isIgnorePostCode()) { 80 isComplete = isComplete && 81 hasPostalCode() && 82 PostalCodeChecker.hasValidPostalCode(this); 78 83 } 79 84 -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/TagUtils.java
r25373 r27338 1954 1954 return relMember != null && STREET_RELATION_ROLE.equals(relMember.getRole()); 1955 1955 } 1956 1957 1958 1956 1959 1957 /**
Note:
See TracChangeset
for help on using the changeset viewer.