Changeset 30775 in osm
- Timestamp:
- 2014-10-29T01:42:56+01:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/HouseNumberTaggingTool
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/HouseNumberTaggingTool/.project
r29853 r30775 13 13 </buildSpec> 14 14 <natures> 15 <nature>org.sonar.ide.eclipse.core.sonarNature</nature> 15 16 <nature>org.eclipse.jdt.core.javanature</nature> 16 17 </natures> -
applications/editors/josm/plugins/HouseNumberTaggingTool/.settings/org.eclipse.jdt.core.prefs
r30736 r30775 7 7 org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled 8 8 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 9 org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 9 10 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 10 12 org.eclipse.jdt.core.compiler.compliance=1.7 13 org.eclipse.jdt.core.compiler.debug.lineNumber=generate 14 org.eclipse.jdt.core.compiler.debug.localVariable=generate 15 org.eclipse.jdt.core.compiler.debug.sourceFile=generate 16 org.eclipse.jdt.core.compiler.doc.comment.support=enabled 11 17 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning 12 18 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error … … 32 38 org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning 33 39 org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore 40 org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning 41 org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled 42 org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled 43 org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled 44 org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public 34 45 org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore 35 46 org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning … … 38 49 org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled 39 50 org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore 51 org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning 52 org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled 53 org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public 54 org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag 55 org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning 56 org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled 57 org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled 58 org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public 40 59 org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore 41 60 org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled 42 org.eclipse.jdt.core.compiler.problem.missingSerialVersion= warning61 org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore 43 62 org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore 44 63 org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -
applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/Dto.java
r30048 r30775 6 6 * @author Oliver Raupach 18.01.2012 <http://www.oliver-raupach.de> 7 7 */ 8 public class Dto implements Serializable 9 { 8 public class Dto implements Serializable { 10 9 11 private static final long serialVersionUID = 5226513739078369787L; 10 private static final long serialVersionUID = 5226513739078369787L; 12 11 13 private boolean saveBuilding = true; 14 private boolean saveCountry = true; 15 private boolean saveState = true; 16 private boolean saveCity = true; 17 private boolean savePostcode = true; 18 private boolean saveStreet = true; 19 private boolean saveHousenumber = true; 12 private boolean saveBuilding = true; 13 private boolean saveCountry = true; 14 private boolean saveState = true; 15 private boolean saveCity = true; 16 private boolean savePostcode = true; 17 private boolean saveStreet = true; 18 private boolean saveHousenumber = true; 20 19 21 private boolean tagStreet = true; // use tag addr:street or addr:place 20 private boolean tagStreet = true; // use tag addr:street or addr:place 22 21 23 private String building = "yes"; 24 private String country; 25 private String state; 26 private String city; 27 private String postcode; 28 private String street; 29 private String place; 30 private String housenumber; 31 private int housenumberChangeValue = 0; 22 private String building = "yes"; 23 private String country; 24 private String state; 25 private String city; 26 private String postcode; 27 private String street; 28 private String place; 29 private String housenumber; 30 private int housenumberChangeValue = 0; 32 31 33 public boolean isSaveBuilding() 34 { 35 return saveBuilding; 36 } 32 public boolean isSaveBuilding() { 33 return saveBuilding; 34 } 37 35 38 public void setSaveBuilding(boolean saveBuilding) 39 { 40 this.saveBuilding = saveBuilding; 41 } 36 public void setSaveBuilding(boolean saveBuilding) { 37 this.saveBuilding = saveBuilding; 38 } 42 39 43 public boolean isSaveCountry() 44 { 45 return saveCountry; 46 } 40 public boolean isSaveCountry() { 41 return saveCountry; 42 } 47 43 48 public void setSaveCountry(boolean saveCountry) 49 { 50 this.saveCountry = saveCountry; 51 } 44 public void setSaveCountry(boolean saveCountry) { 45 this.saveCountry = saveCountry; 46 } 52 47 53 public boolean isSaveCity() 54 { 55 return saveCity; 56 } 48 public boolean isSaveCity() { 49 return saveCity; 50 } 57 51 58 public void setSaveCity(boolean saveCity) 59 { 60 this.saveCity = saveCity; 61 } 52 public void setSaveCity(boolean saveCity) { 53 this.saveCity = saveCity; 54 } 62 55 63 public boolean isSavePostcode() 64 { 65 return savePostcode; 66 } 56 public boolean isSavePostcode() { 57 return savePostcode; 58 } 67 59 68 public void setSavePostcode(boolean savePostcode) 69 { 70 this.savePostcode = savePostcode; 71 } 60 public void setSavePostcode(boolean savePostcode) { 61 this.savePostcode = savePostcode; 62 } 72 63 73 public boolean isSaveStreet() 74 { 75 return saveStreet; 76 } 64 public boolean isSaveStreet() { 65 return saveStreet; 66 } 77 67 78 public void setSaveStreet(boolean saveStreet) 79 { 80 this.saveStreet = saveStreet; 81 } 68 public void setSaveStreet(boolean saveStreet) { 69 this.saveStreet = saveStreet; 70 } 82 71 83 public boolean isSaveHousenumber() 84 { 85 return saveHousenumber; 86 } 72 public boolean isSaveHousenumber() { 73 return saveHousenumber; 74 } 87 75 88 public void setSaveHousenumber(boolean saveHousenumber) 89 { 90 this.saveHousenumber = saveHousenumber; 91 } 76 public void setSaveHousenumber(boolean saveHousenumber) { 77 this.saveHousenumber = saveHousenumber; 78 } 92 79 93 public String getCountry() 94 { 95 return country; 96 } 80 public String getCountry() { 81 return country; 82 } 97 83 98 public void setCountry(String country) 99 { 100 this.country = country; 101 } 84 public void setCountry(String country) { 85 this.country = country; 86 } 102 87 103 public String getCity() 104 { 105 return city; 106 } 88 public String getCity() { 89 return city; 90 } 107 91 108 public void setCity(String city) 109 { 110 this.city = city; 111 } 92 public void setCity(String city) { 93 this.city = city; 94 } 112 95 113 public String getPostcode() 114 { 115 return postcode; 116 } 96 public String getPostcode() { 97 return postcode; 98 } 117 99 118 public void setPostcode(String postcode) 119 { 120 this.postcode = postcode; 121 } 100 public void setPostcode(String postcode) { 101 this.postcode = postcode; 102 } 122 103 123 public String getStreet() 124 { 125 return street; 126 } 104 public String getStreet() { 105 return street; 106 } 127 107 128 public void setStreet(String street) 129 { 130 this.street = street; 131 } 108 public void setStreet(String street) { 109 this.street = street; 110 } 132 111 133 public String getHousenumber() 134 { 135 return housenumber; 136 } 112 public String getHousenumber() { 113 return housenumber; 114 } 137 115 138 public void setHousenumber(String housenumber) 139 { 140 this.housenumber = housenumber; 141 } 116 public void setHousenumber(String housenumber) { 117 this.housenumber = housenumber; 118 } 142 119 143 public String getState() 144 { 145 return state; 146 } 120 public String getState() { 121 return state; 122 } 147 123 148 public void setState(String state) 149 { 150 this.state = state; 151 } 124 public void setState(String state) { 125 this.state = state; 126 } 152 127 153 public boolean isSaveState() 154 { 155 return saveState; 156 } 128 public boolean isSaveState() { 129 return saveState; 130 } 157 131 158 public void setSaveState(boolean saveState) 159 { 160 this.saveState = saveState; 161 } 132 public void setSaveState(boolean saveState) { 133 this.saveState = saveState; 134 } 162 135 163 public int getHousenumberChangeValue() 164 { 165 return housenumberChangeValue; 166 } 136 public int getHousenumberChangeValue() { 137 return housenumberChangeValue; 138 } 167 139 168 public void setHousenumberChangeValue(int housenumberChangeValue) 169 { 170 this.housenumberChangeValue = housenumberChangeValue; 171 } 140 public void setHousenumberChangeValue(int housenumberChangeValue) { 141 this.housenumberChangeValue = housenumberChangeValue; 142 } 172 143 173 public String getBuilding() 174 { 175 return building; 176 } 144 public String getBuilding() { 145 return building; 146 } 177 147 178 public void setBuilding(String building) 179 { 180 this.building = building; 181 } 148 public void setBuilding(String building) { 149 this.building = building; 150 } 182 151 183 public boolean isTagStreet() 184 { 185 return tagStreet; 186 } 152 public boolean isTagStreet() { 153 return tagStreet; 154 } 187 155 188 public void setTagStreet(boolean tagStreet) 189 { 190 this.tagStreet = tagStreet; 191 } 156 public void setTagStreet(boolean tagStreet) { 157 this.tagStreet = tagStreet; 158 } 192 159 193 public String getPlace() 194 { 195 return place; 196 } 160 public String getPlace() { 161 return place; 162 } 197 163 198 public void setPlace(String place) 199 { 200 this.place = place; 201 } 164 public void setPlace(String place) { 165 this.place = place; 166 } 202 167 } -
applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/HouseNumberTaggingToolPlugin.java
r29778 r30775 6 6 import org.openstreetmap.josm.plugins.PluginInformation; 7 7 8 /** 9 * Simple tool to tag house numbers. Select house and press 'k'. Select your addr-tags and press OK. 10 */ 8 11 public class HouseNumberTaggingToolPlugin extends Plugin { 9 LaunchAction action; 12 private final LaunchAction action; 10 13 11 /** 12 * constructor 13 */ 14 public HouseNumberTaggingToolPlugin(PluginInformation info) { 15 super(info); 16 action = new LaunchAction(getPluginDir()); 17 MainMenu.add(Main.main.menu.dataMenu, action, false,0); 18 } 14 /** 15 * constructor 16 * @param info plugin info 17 */ 18 public HouseNumberTaggingToolPlugin(PluginInformation info) { 19 super(info); 20 action = new LaunchAction(getPluginDir()); 21 MainMenu.add(Main.main.menu.dataMenu, action, false,0); 22 } 19 23 } -
applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/LaunchAction.java
r29778 r30775 11 11 import org.openstreetmap.josm.tools.Shortcut; 12 12 13 public class LaunchAction extends JosmAction implements SelectionChangedListener 14 { 13 public class LaunchAction extends JosmAction implements SelectionChangedListener { 15 14 16 private static final long serialVersionUID = -3508864293222033185L; 17 private OsmPrimitive selection = null; 15 private OsmPrimitive selection = null; 18 16 19 private String pluginDir; 17 private String pluginDir; 20 18 21 public LaunchAction(String pluginDir) 22 { 23 super("HouseNumberTaggingTool", 24 "home-icon32", 25 "Launches the HouseNumberTaggingTool dialog", 26 Shortcut.registerShortcut("edit:housenumbertaggingtool", "HouseNumberTaggingTool", KeyEvent.VK_K, Shortcut.DIRECT), 27 true); 19 public LaunchAction(String pluginDir) { 20 super("HouseNumberTaggingTool", 21 "home-icon32", 22 "Launches the HouseNumberTaggingTool dialog", 23 Shortcut.registerShortcut("edit:housenumbertaggingtool", "HouseNumberTaggingTool", KeyEvent.VK_K, Shortcut.DIRECT), 24 true); 28 25 29 this.pluginDir = pluginDir; 30 DataSet.addSelectionListener(this); 31 setEnabled(false); 26 this.pluginDir = pluginDir; 27 DataSet.addSelectionListener(this); 28 setEnabled(false); 29 } 30 31 /** 32 * launch the editor 33 */ 34 protected void launchEditor() { 35 if (!isEnabled()) { 36 return; 37 } 32 38 33 } 39 TagDialog dialog = new TagDialog(pluginDir, selection); 40 dialog.showDialog(); 41 } 34 42 35 /** 36 * launch the editor 37 */ 38 protected void launchEditor() 39 { 40 if (!isEnabled()) 41 { 42 return; 43 } 44 45 TagDialog dialog = new TagDialog(pluginDir, selection); 46 dialog.showDialog(); 43 @Override 44 public void actionPerformed(ActionEvent e) { 45 launchEditor(); 46 } 47 47 48 } 49 50 @Override 51 public void actionPerformed(ActionEvent e) 52 { 53 launchEditor(); 54 } 55 56 @Override 57 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) 58 { 59 if ((newSelection != null && newSelection.size() == 1)) 60 { 61 setEnabled(true); 62 selection = newSelection.iterator().next(); 63 } 64 else 65 { 66 setEnabled(false); 67 selection = null; 68 } 69 70 } 48 @Override 49 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 50 if (newSelection != null && newSelection.size() == 1) { 51 setEnabled(true); 52 selection = newSelection.iterator().next(); 53 } else { 54 setEnabled(false); 55 selection = null; 56 } 57 } 71 58 } -
applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/TagDialog.java
r30738 r30775 18 18 import java.util.Arrays; 19 19 import java.util.Collection; 20 import java.util.List; 21 import java.util.Set; 20 22 import java.util.TreeSet; 21 23 import java.util.logging.Level; … … 46 48 * @author Victor Kropp 10.03.2012 <http://victor.kropp.name> 47 49 */ 48 public class TagDialog extends ExtendedDialog 49 { 50 private static final String APPLY_CHANGES = tr("Apply Changes"); 51 private static final String TAG_STREET_OR_PLACE = tr("Use tag ''addr:street'' or ''addr:place''"); 52 53 public static final String TAG_BUILDING = "building"; 54 public static final String TAG_ADDR_COUNTRY = "addr:country"; 55 public static final String TAG_ADDR_STATE = "addr:state"; 56 public static final String TAG_ADDR_CITY = "addr:city"; 57 public static final String TAG_ADDR_POSTCODE = "addr:postcode"; 58 public static final String TAG_ADDR_HOUSENUMBER = "addr:housenumber"; 59 public static final String TAG_ADDR_STREET = "addr:street"; 60 public static final String TAG_ADDR_PLACE = "addr:place"; 61 62 public static final String[] buildingStrings = {"yes", "apartments", "chapel", "church", "commercial", "dormitory", "hotel", "house", "residential", "terrace", "industrial", "retail", "warehouse", "cathedral", "civic", "hospital", "school", "train_station", "transportation", "university", "public", "bridge", "bunker", "cabin", "construction", "farm_auxiliary", "garage", "garages" , "greenhouse", "hangar", "hut", "roof", "shed", "stable" }; 63 64 private static final int FPS_MIN = -2; 65 private static final int FPS_MAX = 2; 66 67 private static final long serialVersionUID = 6414385452106276923L; 68 69 static private final Logger logger = Logger.getLogger(TagDialog.class.getName()); 70 71 private String pluginDir; 72 private AutoCompletionManager acm; 73 private OsmPrimitive selection; 74 75 public static final String TEMPLATE_DATA = "/template.data"; 76 77 private AutoCompletingComboBox country; 78 private AutoCompletingComboBox state; 79 private AutoCompletingComboBox city; 80 private AutoCompletingComboBox postcode; 81 private AutoCompletingComboBox street; 82 private JTextField housnumber; 83 private JCheckBox buildingEnabled; 84 private JCheckBox countryEnabled; 85 private JCheckBox stateEnabled; 86 private JCheckBox cityEnabled; 87 private JCheckBox zipEnabled; 88 private JCheckBox streetEnabled; 89 private JCheckBox housenumberEnabled; 90 private JSlider housenumberChangeSequence; 91 private JComboBox<String> building; 92 private JRadioButton streetRadio; 93 private JRadioButton placeRadio; 94 95 public TagDialog(String pluginDir, OsmPrimitive p_selection) 96 { 97 super(Main.parent, tr("House Number Editor"), new String[] { tr("OK"), tr("Cancel") }, true); 98 this.pluginDir = pluginDir; 99 this.selection = p_selection; 100 101 JPanel editPanel = createContentPane(); 102 103 setContent(editPanel); 104 setButtonIcons(new String[] { "ok.png", "cancel.png" }); 105 setDefaultButton(1); 106 setupDialog(); 107 getRootPane().setDefaultButton(defaultButton); 108 109 // middle of the screen 110 setLocationRelativeTo(null); 111 112 SwingUtilities.invokeLater(new Runnable() { 113 @Override 114 public void run() { 115 housnumber.requestFocus(); 116 housnumber.selectAll(); 117 } 118 }); 119 } 120 121 private JPanel createContentPane() { 122 acm = selection.getDataSet().getAutoCompletionManager(); 123 124 Dto dto = loadDto(); 125 126 JPanel editPanel = new JPanel(new GridBagLayout()); 127 GridBagConstraints c = new GridBagConstraints(); 128 129 buildingEnabled = new JCheckBox(TAG_BUILDING); 130 buildingEnabled.setFocusable(false); 131 buildingEnabled.setSelected(dto.isSaveBuilding()); 132 buildingEnabled.setToolTipText(APPLY_CHANGES); 133 c.fill = GridBagConstraints.HORIZONTAL; 134 c.gridx = 0; 135 c.gridy = 0; 136 c.weightx = 0; 137 c.gridwidth = 3; 138 editPanel.add(buildingEnabled, c); 139 140 Arrays.sort(buildingStrings); 141 building = new JComboBox<>(buildingStrings); 142 building.setSelectedItem(dto.getBuilding()); 143 building.setMaximumRowCount(50); 144 c.gridx = 3; 145 c.gridy = 0; 146 c.weightx = 1; 147 c.gridwidth = 1; 148 editPanel.add(building, c); 149 150 // country 151 countryEnabled = new JCheckBox(TAG_ADDR_COUNTRY); 152 countryEnabled.setFocusable(false); 153 countryEnabled.setSelected(dto.isSaveCountry()); 154 countryEnabled.setToolTipText(APPLY_CHANGES); 155 c = new GridBagConstraints(); 156 c.fill = GridBagConstraints.HORIZONTAL; 157 c.gridx = 0; 158 c.gridy = 1; 159 c.weightx = 0; 160 c.gridwidth = 3; 161 editPanel.add(countryEnabled, c); 162 163 country = new AutoCompletingComboBox(); 164 country.setPossibleACItems(acm.getValues(TAG_ADDR_COUNTRY)); 165 country.setPreferredSize(new Dimension(200, 24)); 166 country.setEditable(true); 167 country.setSelectedItem(dto.getCountry()); 168 c.fill = GridBagConstraints.HORIZONTAL; 169 c.gridx = 3; 170 c.gridy = 1; 171 c.weightx = 1; 172 c.gridwidth = 1; 173 editPanel.add(country, c); 174 175 // state 176 stateEnabled = new JCheckBox(TAG_ADDR_STATE); 177 stateEnabled.setFocusable(false); 178 stateEnabled.setSelected(dto.isSaveState()); 179 stateEnabled.setToolTipText(APPLY_CHANGES); 180 c = new GridBagConstraints(); 181 c.fill = GridBagConstraints.HORIZONTAL; 182 c.gridx = 0; 183 c.gridy = 2; 184 c.weightx = 0; 185 c.gridwidth = 3; 186 editPanel.add(stateEnabled, c); 187 188 state = new AutoCompletingComboBox(); 189 state.setPossibleACItems(acm.getValues(TAG_ADDR_STATE)); 190 state.setPreferredSize(new Dimension(200, 24)); 191 state.setEditable(true); 192 state.setSelectedItem(dto.getState()); 193 c.fill = GridBagConstraints.HORIZONTAL; 194 c.gridx = 3; 195 c.gridy = 2; 196 c.weightx = 1; 197 c.gridwidth = 1; 198 editPanel.add(state, c); 199 200 // city 201 cityEnabled = new JCheckBox(TAG_ADDR_CITY); 202 cityEnabled.setFocusable(false); 203 cityEnabled.setSelected(dto.isSaveCity()); 204 cityEnabled.setToolTipText(APPLY_CHANGES); 205 c.fill = GridBagConstraints.HORIZONTAL; 206 c.gridx = 0; 207 c.gridy = 3; 208 c.weightx = 0; 209 c.gridwidth = 3; 210 editPanel.add(cityEnabled, c); 211 212 city = new AutoCompletingComboBox(); 213 city.setPossibleACItems(acm.getValues(TAG_ADDR_CITY)); 214 city.setPreferredSize(new Dimension(200, 24)); 215 city.setEditable(true); 216 city.setSelectedItem(dto.getCity()); 217 c.fill = GridBagConstraints.HORIZONTAL; 218 c.gridx = 3; 219 c.gridy = 3; 220 c.weightx = 1; 221 c.gridwidth = 1; 222 editPanel.add(city, c); 223 224 // postcode 225 zipEnabled = new JCheckBox(TAG_ADDR_POSTCODE); 226 zipEnabled.setFocusable(false); 227 zipEnabled.setSelected(dto.isSavePostcode()); 228 zipEnabled.setToolTipText(APPLY_CHANGES); 229 c.fill = GridBagConstraints.HORIZONTAL; 230 c.gridx = 0; 231 c.gridy = 4; 232 c.weightx = 0; 233 c.gridwidth = 3; 234 editPanel.add(zipEnabled, c); 235 236 postcode = new AutoCompletingComboBox(); 237 postcode.setPossibleACItems(acm.getValues(TAG_ADDR_POSTCODE)); 238 postcode.setPreferredSize(new Dimension(200, 24)); 239 postcode.setEditable(true); 240 postcode.setSelectedItem(dto.getPostcode()); 241 c.fill = GridBagConstraints.HORIZONTAL; 242 c.gridx = 3; 243 c.gridy = 4; 244 c.weightx = 1; 245 c.gridwidth = 1; 246 editPanel.add(postcode, c); 247 248 // street 249 streetEnabled = new JCheckBox(); 250 streetEnabled.setFocusable(false); 251 streetEnabled.setSelected(dto.isSaveStreet()); 252 streetEnabled.setToolTipText(APPLY_CHANGES); 253 c.fill = GridBagConstraints.HORIZONTAL; 254 c.gridx = 0; 255 c.gridy = 5; 256 c.weightx = 0; 257 c.gridwidth = 1; 258 editPanel.add(streetEnabled, c); 259 260 261 streetRadio = new JRadioButton(TAG_ADDR_STREET); 262 streetRadio.setToolTipText(TAG_STREET_OR_PLACE); 263 streetRadio.setSelected(dto.isTagStreet()); 264 streetRadio.addItemListener(new RadioChangeListener()); 265 c.fill = GridBagConstraints.HORIZONTAL; 266 c.gridx = 1; 267 c.gridy = 5; 268 c.weightx = 0; 269 c.gridwidth = 1; 270 editPanel.add(streetRadio, c); 271 272 placeRadio = new JRadioButton("addr:place"); 273 placeRadio.setToolTipText(TAG_STREET_OR_PLACE); 274 placeRadio.setSelected(!dto.isTagStreet()); 275 placeRadio.addItemListener(new RadioChangeListener()); 276 c.fill = GridBagConstraints.HORIZONTAL; 277 c.gridx = 2; 278 c.gridy = 5; 279 c.weightx = 0; 280 c.gridwidth = 1; 281 editPanel.add(placeRadio, c); 282 283 ButtonGroup g = new ButtonGroup(); 284 g.add( streetRadio ); 285 g.add( placeRadio ); 286 287 street = new AutoCompletingComboBox(); 288 if (dto.isTagStreet()) 289 { 290 street.setPossibleItems(getPossibleStreets()); 291 } 292 else 293 { 294 street.setPossibleACItems(acm.getValues(TAG_ADDR_PLACE)); 295 } 296 street.setPreferredSize(new Dimension(200, 24)); 297 street.setEditable(true); 298 street.setSelectedItem(dto.getStreet()); 299 c.fill = GridBagConstraints.HORIZONTAL; 300 c.gridx = 3; 301 c.gridy = 5; 302 c.weightx = 1; 303 c.gridwidth = 1; 304 editPanel.add(street, c); 305 306 // housenumber 307 housenumberEnabled = new JCheckBox(TAG_ADDR_HOUSENUMBER); 308 housenumberEnabled.setFocusable(false); 309 housenumberEnabled.setSelected(dto.isSaveHousenumber()); 310 housenumberEnabled.setToolTipText(APPLY_CHANGES); 311 c.fill = GridBagConstraints.HORIZONTAL; 312 c.gridx = 0; 313 c.gridy = 6; 314 c.weightx = 0; 315 c.gridwidth = 3; 316 editPanel.add(housenumberEnabled, c); 317 318 housnumber = new JTextField(); 319 housnumber.setPreferredSize(new Dimension(200, 24)); 320 321 int number = 0; 322 try { 323 number = Integer.valueOf(dto.getHousenumber()) + dto.getHousenumberChangeValue(); 324 } 325 catch (NumberFormatException e) { } 326 if (number > 0) { 327 housnumber.setText(String.valueOf(number)); 328 } 329 330 331 c.fill = GridBagConstraints.HORIZONTAL; 332 c.gridx = 3; 333 c.gridy = 6; 334 c.weightx = 1; 335 c.gridwidth = 1; 336 editPanel.add(housnumber, c); 337 338 JLabel seqLabel = new JLabel(tr("House number increment:")); 339 c.fill = GridBagConstraints.HORIZONTAL; 340 c.gridx = 0; 341 c.gridy = 7; 342 c.weightx = 0; 343 c.gridwidth = 3; 344 editPanel.add(seqLabel, c); 345 346 housenumberChangeSequence = new JSlider(JSlider.HORIZONTAL, FPS_MIN, FPS_MAX, dto.getHousenumberChangeValue()); 347 housenumberChangeSequence.setPaintTicks(true); 348 housenumberChangeSequence.setMajorTickSpacing(1); 349 housenumberChangeSequence.setMinorTickSpacing(1); 350 housenumberChangeSequence.setPaintLabels(true); 351 housenumberChangeSequence.setSnapToTicks(true); 352 c.gridx = 3; 353 c.gridy = 7; 354 c.weightx = 1; 355 c.gridwidth = 1; 356 editPanel.add(housenumberChangeSequence, c); 357 358 return editPanel; 359 } 360 361 @Override 362 protected void buttonAction(int buttonIndex, ActionEvent evt) 363 { 364 if (buttonIndex == 0) { 365 Dto dto = new Dto(); 366 dto.setSaveBuilding(buildingEnabled.isSelected()); 367 dto.setSaveCity(cityEnabled.isSelected()); 368 dto.setSaveCountry(countryEnabled.isSelected()); 369 dto.setSaveState(stateEnabled.isSelected()); 370 dto.setSaveHousenumber(housenumberEnabled.isSelected()); 371 dto.setSavePostcode(zipEnabled.isSelected()); 372 dto.setSaveStreet(streetEnabled.isSelected()); 373 dto.setTagStreet(streetRadio.isSelected()); 374 375 dto.setBuilding((String) building.getSelectedItem()); 376 dto.setCity(getAutoCompletingComboBoxValue(city)); 377 dto.setCountry(getAutoCompletingComboBoxValue(country)); 378 dto.setHousenumber(housnumber.getText()); 379 dto.setPostcode(getAutoCompletingComboBoxValue(postcode)); 380 dto.setStreet(getAutoCompletingComboBoxValue(street)); 381 dto.setState(getAutoCompletingComboBoxValue(state)); 382 dto.setHousenumberChangeValue(housenumberChangeSequence.getValue()); 383 384 updateJOSMSelection(selection, dto); 385 saveDto(dto); 386 } 387 setVisible(false); 388 } 389 390 private String getAutoCompletingComboBoxValue(AutoCompletingComboBox box) 391 { 392 Object item = box.getSelectedItem(); 393 if (item != null) { 394 if (item instanceof String) { 395 return (String) item; 396 } 397 if (item instanceof AutoCompletionListItem) { 398 return ((AutoCompletionListItem) item).getValue(); 399 } 400 return item.toString(); 401 } else { 402 return ""; 403 } 404 } 405 406 protected void saveDto(Dto dto) 407 { 408 File path = new File(pluginDir); 409 File fileName = new File(pluginDir + TagDialog.TEMPLATE_DATA); 410 411 try { 412 path.mkdirs(); 413 try ( 414 FileOutputStream file = new FileOutputStream(fileName); 415 ObjectOutputStream o = new ObjectOutputStream(file) 416 ) { 417 o.writeObject(dto); 418 } 419 } catch (Exception ex) { 420 logger.log(Level.SEVERE, ex.getMessage()); 421 fileName.delete(); 422 } 423 } 424 425 protected void updateJOSMSelection(OsmPrimitive selection, Dto dto) 426 { 427 ArrayList<Command> commands = new ArrayList<>(); 428 429 if (dto.isSaveBuilding()) { 430 String value = selection.get(TagDialog.TAG_BUILDING); 431 if (value == null || (value != null && !value.equals(dto.getBuilding()))) { 432 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_BUILDING, dto.getBuilding()); 433 commands.add(command); 434 } 435 } 436 437 if (dto.isSaveCity()) { 438 String value = selection.get(TagDialog.TAG_ADDR_CITY); 439 if (value == null || (value != null && !value.equals(dto.getCity()))) { 440 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_CITY, dto.getCity()); 441 commands.add(command); 442 } 443 } 444 445 if (dto.isSaveCountry()) { 446 String value = selection.get(TagDialog.TAG_ADDR_COUNTRY); 447 if (value == null || (value != null && !value.equals(dto.getCountry()))) 448 { 449 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_COUNTRY, dto.getCountry()); 450 commands.add(command); 451 } 452 } 453 454 if (dto.isSaveHousenumber()) { 455 String value = selection.get(TagDialog.TAG_ADDR_HOUSENUMBER); 456 if (value == null || (value != null && !value.equals(dto.getHousenumber()))) { 457 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_HOUSENUMBER, dto.getHousenumber()); 458 commands.add(command); 459 } 460 } 461 462 if (dto.isSavePostcode()) { 463 String value = selection.get(TagDialog.TAG_ADDR_POSTCODE); 464 if (value == null || (value != null && !value.equals(dto.getPostcode()))) { 465 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_POSTCODE, dto.getPostcode()); 466 commands.add(command); 467 } 468 } 469 470 if (dto.isSaveStreet()) 471 { 472 if (dto.isTagStreet()) 473 { 50 public class TagDialog extends ExtendedDialog { 51 private static final String APPLY_CHANGES = tr("Apply Changes"); 52 private static final String TAG_STREET_OR_PLACE = tr("Use tag ''addr:street'' or ''addr:place''"); 53 54 private static final String TAG_BUILDING = "building"; 55 private static final String TAG_ADDR_COUNTRY = "addr:country"; 56 private static final String TAG_ADDR_STATE = "addr:state"; 57 private static final String TAG_ADDR_CITY = "addr:city"; 58 private static final String TAG_ADDR_POSTCODE = "addr:postcode"; 59 private static final String TAG_ADDR_HOUSENUMBER = "addr:housenumber"; 60 private static final String TAG_ADDR_STREET = "addr:street"; 61 private static final String TAG_ADDR_PLACE = "addr:place"; 62 63 private static final String[] BUILDING_STRINGS = { 64 "yes", "apartments", "chapel", "church", "commercial", "dormitory", "hotel", "house", "residential", "terrace", 65 "industrial", "retail", "warehouse", "cathedral", "civic", "hospital", "school", "train_station", "transportation", 66 "university", "public", "bridge", "bunker", "cabin", "construction", "farm_auxiliary", "garage", "garages", 67 "greenhouse", "hangar", "hut", "roof", "shed", "stable"}; 68 69 private static final int FPS_MIN = -2; 70 private static final int FPS_MAX = 2; 71 72 private static final Logger LOGGER = Logger.getLogger(TagDialog.class.getName()); 73 74 private String pluginDir; 75 private AutoCompletionManager acm; 76 private OsmPrimitive selection; 77 78 private static final String TEMPLATE_DATA = "/template.data"; 79 80 private AutoCompletingComboBox country; 81 private AutoCompletingComboBox state; 82 private AutoCompletingComboBox city; 83 private AutoCompletingComboBox postcode; 84 private AutoCompletingComboBox street; 85 private JTextField housnumber; 86 private JCheckBox buildingEnabled; 87 private JCheckBox countryEnabled; 88 private JCheckBox stateEnabled; 89 private JCheckBox cityEnabled; 90 private JCheckBox zipEnabled; 91 private JCheckBox streetEnabled; 92 private JCheckBox housenumberEnabled; 93 private JSlider housenumberChangeSequence; 94 private JComboBox<String> building; 95 private JRadioButton streetRadio; 96 private JRadioButton placeRadio; 97 98 public TagDialog(String pluginDir, OsmPrimitive selection) { 99 super(Main.parent, tr("House Number Editor"), new String[] { tr("OK"), tr("Cancel") }, true); 100 this.pluginDir = pluginDir; 101 this.selection = selection; 102 103 JPanel editPanel = createContentPane(); 104 105 setContent(editPanel); 106 setButtonIcons(new String[] { "ok.png", "cancel.png" }); 107 setDefaultButton(1); 108 setupDialog(); 109 getRootPane().setDefaultButton(defaultButton); 110 111 // middle of the screen 112 setLocationRelativeTo(null); 113 114 SwingUtilities.invokeLater(new Runnable() { 115 @Override 116 public void run() { 117 housnumber.requestFocus(); 118 housnumber.selectAll(); 119 } 120 }); 121 } 122 123 private JPanel createContentPane() { 124 acm = selection.getDataSet().getAutoCompletionManager(); 125 126 Dto dto = loadDto(); 127 128 JPanel editPanel = new JPanel(new GridBagLayout()); 129 GridBagConstraints c = new GridBagConstraints(); 130 131 buildingEnabled = new JCheckBox(TAG_BUILDING); 132 buildingEnabled.setFocusable(false); 133 buildingEnabled.setSelected(dto.isSaveBuilding()); 134 buildingEnabled.setToolTipText(APPLY_CHANGES); 135 c.fill = GridBagConstraints.HORIZONTAL; 136 c.gridx = 0; 137 c.gridy = 0; 138 c.weightx = 0; 139 c.gridwidth = 3; 140 editPanel.add(buildingEnabled, c); 141 142 Arrays.sort(BUILDING_STRINGS); 143 building = new JComboBox<>(BUILDING_STRINGS); 144 building.setSelectedItem(dto.getBuilding()); 145 building.setMaximumRowCount(50); 146 c.gridx = 3; 147 c.gridy = 0; 148 c.weightx = 1; 149 c.gridwidth = 1; 150 editPanel.add(building, c); 151 152 // country 153 countryEnabled = new JCheckBox(TAG_ADDR_COUNTRY); 154 countryEnabled.setFocusable(false); 155 countryEnabled.setSelected(dto.isSaveCountry()); 156 countryEnabled.setToolTipText(APPLY_CHANGES); 157 c = new GridBagConstraints(); 158 c.fill = GridBagConstraints.HORIZONTAL; 159 c.gridx = 0; 160 c.gridy = 1; 161 c.weightx = 0; 162 c.gridwidth = 3; 163 editPanel.add(countryEnabled, c); 164 165 country = new AutoCompletingComboBox(); 166 country.setPossibleACItems(acm.getValues(TAG_ADDR_COUNTRY)); 167 country.setPreferredSize(new Dimension(200, 24)); 168 country.setEditable(true); 169 country.setSelectedItem(dto.getCountry()); 170 c.fill = GridBagConstraints.HORIZONTAL; 171 c.gridx = 3; 172 c.gridy = 1; 173 c.weightx = 1; 174 c.gridwidth = 1; 175 editPanel.add(country, c); 176 177 // state 178 stateEnabled = new JCheckBox(TAG_ADDR_STATE); 179 stateEnabled.setFocusable(false); 180 stateEnabled.setSelected(dto.isSaveState()); 181 stateEnabled.setToolTipText(APPLY_CHANGES); 182 c = new GridBagConstraints(); 183 c.fill = GridBagConstraints.HORIZONTAL; 184 c.gridx = 0; 185 c.gridy = 2; 186 c.weightx = 0; 187 c.gridwidth = 3; 188 editPanel.add(stateEnabled, c); 189 190 state = new AutoCompletingComboBox(); 191 state.setPossibleACItems(acm.getValues(TAG_ADDR_STATE)); 192 state.setPreferredSize(new Dimension(200, 24)); 193 state.setEditable(true); 194 state.setSelectedItem(dto.getState()); 195 c.fill = GridBagConstraints.HORIZONTAL; 196 c.gridx = 3; 197 c.gridy = 2; 198 c.weightx = 1; 199 c.gridwidth = 1; 200 editPanel.add(state, c); 201 202 // city 203 cityEnabled = new JCheckBox(TAG_ADDR_CITY); 204 cityEnabled.setFocusable(false); 205 cityEnabled.setSelected(dto.isSaveCity()); 206 cityEnabled.setToolTipText(APPLY_CHANGES); 207 c.fill = GridBagConstraints.HORIZONTAL; 208 c.gridx = 0; 209 c.gridy = 3; 210 c.weightx = 0; 211 c.gridwidth = 3; 212 editPanel.add(cityEnabled, c); 213 214 city = new AutoCompletingComboBox(); 215 city.setPossibleACItems(acm.getValues(TAG_ADDR_CITY)); 216 city.setPreferredSize(new Dimension(200, 24)); 217 city.setEditable(true); 218 city.setSelectedItem(dto.getCity()); 219 c.fill = GridBagConstraints.HORIZONTAL; 220 c.gridx = 3; 221 c.gridy = 3; 222 c.weightx = 1; 223 c.gridwidth = 1; 224 editPanel.add(city, c); 225 226 // postcode 227 zipEnabled = new JCheckBox(TAG_ADDR_POSTCODE); 228 zipEnabled.setFocusable(false); 229 zipEnabled.setSelected(dto.isSavePostcode()); 230 zipEnabled.setToolTipText(APPLY_CHANGES); 231 c.fill = GridBagConstraints.HORIZONTAL; 232 c.gridx = 0; 233 c.gridy = 4; 234 c.weightx = 0; 235 c.gridwidth = 3; 236 editPanel.add(zipEnabled, c); 237 238 postcode = new AutoCompletingComboBox(); 239 postcode.setPossibleACItems(acm.getValues(TAG_ADDR_POSTCODE)); 240 postcode.setPreferredSize(new Dimension(200, 24)); 241 postcode.setEditable(true); 242 postcode.setSelectedItem(dto.getPostcode()); 243 c.fill = GridBagConstraints.HORIZONTAL; 244 c.gridx = 3; 245 c.gridy = 4; 246 c.weightx = 1; 247 c.gridwidth = 1; 248 editPanel.add(postcode, c); 249 250 // street 251 streetEnabled = new JCheckBox(); 252 streetEnabled.setFocusable(false); 253 streetEnabled.setSelected(dto.isSaveStreet()); 254 streetEnabled.setToolTipText(APPLY_CHANGES); 255 c.fill = GridBagConstraints.HORIZONTAL; 256 c.gridx = 0; 257 c.gridy = 5; 258 c.weightx = 0; 259 c.gridwidth = 1; 260 editPanel.add(streetEnabled, c); 261 262 streetRadio = new JRadioButton(TAG_ADDR_STREET); 263 streetRadio.setToolTipText(TAG_STREET_OR_PLACE); 264 streetRadio.setSelected(dto.isTagStreet()); 265 streetRadio.addItemListener(new RadioChangeListener()); 266 c.fill = GridBagConstraints.HORIZONTAL; 267 c.gridx = 1; 268 c.gridy = 5; 269 c.weightx = 0; 270 c.gridwidth = 1; 271 editPanel.add(streetRadio, c); 272 273 placeRadio = new JRadioButton("addr:place"); 274 placeRadio.setToolTipText(TAG_STREET_OR_PLACE); 275 placeRadio.setSelected(!dto.isTagStreet()); 276 placeRadio.addItemListener(new RadioChangeListener()); 277 c.fill = GridBagConstraints.HORIZONTAL; 278 c.gridx = 2; 279 c.gridy = 5; 280 c.weightx = 0; 281 c.gridwidth = 1; 282 editPanel.add(placeRadio, c); 283 284 ButtonGroup g = new ButtonGroup(); 285 g.add( streetRadio ); 286 g.add( placeRadio ); 287 288 street = new AutoCompletingComboBox(); 289 if (dto.isTagStreet()) { 290 street.setPossibleItems(getPossibleStreets()); 291 } else { 292 street.setPossibleACItems(acm.getValues(TAG_ADDR_PLACE)); 293 } 294 street.setPreferredSize(new Dimension(200, 24)); 295 street.setEditable(true); 296 street.setSelectedItem(dto.getStreet()); 297 c.fill = GridBagConstraints.HORIZONTAL; 298 c.gridx = 3; 299 c.gridy = 5; 300 c.weightx = 1; 301 c.gridwidth = 1; 302 editPanel.add(street, c); 303 304 // housenumber 305 housenumberEnabled = new JCheckBox(TAG_ADDR_HOUSENUMBER); 306 housenumberEnabled.setFocusable(false); 307 housenumberEnabled.setSelected(dto.isSaveHousenumber()); 308 housenumberEnabled.setToolTipText(APPLY_CHANGES); 309 c.fill = GridBagConstraints.HORIZONTAL; 310 c.gridx = 0; 311 c.gridy = 6; 312 c.weightx = 0; 313 c.gridwidth = 3; 314 editPanel.add(housenumberEnabled, c); 315 316 housnumber = new JTextField(); 317 housnumber.setPreferredSize(new Dimension(200, 24)); 318 319 int number = 0; 320 try { 321 number = Integer.valueOf(dto.getHousenumber()) + dto.getHousenumberChangeValue(); 322 } catch (NumberFormatException e) { 323 // Do nothing 324 } 325 if (number > 0) { 326 housnumber.setText(String.valueOf(number)); 327 } 328 329 c.fill = GridBagConstraints.HORIZONTAL; 330 c.gridx = 3; 331 c.gridy = 6; 332 c.weightx = 1; 333 c.gridwidth = 1; 334 editPanel.add(housnumber, c); 335 336 JLabel seqLabel = new JLabel(tr("House number increment:")); 337 c.fill = GridBagConstraints.HORIZONTAL; 338 c.gridx = 0; 339 c.gridy = 7; 340 c.weightx = 0; 341 c.gridwidth = 3; 342 editPanel.add(seqLabel, c); 343 344 housenumberChangeSequence = new JSlider(JSlider.HORIZONTAL, FPS_MIN, FPS_MAX, dto.getHousenumberChangeValue()); 345 housenumberChangeSequence.setPaintTicks(true); 346 housenumberChangeSequence.setMajorTickSpacing(1); 347 housenumberChangeSequence.setMinorTickSpacing(1); 348 housenumberChangeSequence.setPaintLabels(true); 349 housenumberChangeSequence.setSnapToTicks(true); 350 c.gridx = 3; 351 c.gridy = 7; 352 c.weightx = 1; 353 c.gridwidth = 1; 354 editPanel.add(housenumberChangeSequence, c); 355 356 return editPanel; 357 } 358 359 @Override 360 protected void buttonAction(int buttonIndex, ActionEvent evt) { 361 if (buttonIndex == 0) { 362 Dto dto = new Dto(); 363 dto.setSaveBuilding(buildingEnabled.isSelected()); 364 dto.setSaveCity(cityEnabled.isSelected()); 365 dto.setSaveCountry(countryEnabled.isSelected()); 366 dto.setSaveState(stateEnabled.isSelected()); 367 dto.setSaveHousenumber(housenumberEnabled.isSelected()); 368 dto.setSavePostcode(zipEnabled.isSelected()); 369 dto.setSaveStreet(streetEnabled.isSelected()); 370 dto.setTagStreet(streetRadio.isSelected()); 371 372 dto.setBuilding((String) building.getSelectedItem()); 373 dto.setCity(getAutoCompletingComboBoxValue(city)); 374 dto.setCountry(getAutoCompletingComboBoxValue(country)); 375 dto.setHousenumber(housnumber.getText()); 376 dto.setPostcode(getAutoCompletingComboBoxValue(postcode)); 377 dto.setStreet(getAutoCompletingComboBoxValue(street)); 378 dto.setState(getAutoCompletingComboBoxValue(state)); 379 dto.setHousenumberChangeValue(housenumberChangeSequence.getValue()); 380 381 updateJOSMSelection(selection, dto); 382 saveDto(dto); 383 } 384 setVisible(false); 385 } 386 387 private String getAutoCompletingComboBoxValue(AutoCompletingComboBox box) { 388 Object item = box.getSelectedItem(); 389 if (item != null) { 390 if (item instanceof String) { 391 return (String) item; 392 } 393 if (item instanceof AutoCompletionListItem) { 394 return ((AutoCompletionListItem) item).getValue(); 395 } 396 return item.toString(); 397 } else { 398 return ""; 399 } 400 } 401 402 protected void saveDto(Dto dto) { 403 File path = new File(pluginDir); 404 File fileName = new File(pluginDir + TagDialog.TEMPLATE_DATA); 405 406 try { 407 path.mkdirs(); 408 try ( 409 FileOutputStream file = new FileOutputStream(fileName); 410 ObjectOutputStream o = new ObjectOutputStream(file) 411 ) { 412 o.writeObject(dto); 413 } 414 } catch (Exception ex) { 415 LOGGER.log(Level.SEVERE, ex.getMessage()); 416 fileName.delete(); 417 } 418 } 419 420 protected void updateJOSMSelection(OsmPrimitive selection, Dto dto) { 421 List<Command> commands = new ArrayList<>(); 422 423 if (dto.isSaveBuilding()) { 424 String value = selection.get(TagDialog.TAG_BUILDING); 425 if (value == null || (value != null && !value.equals(dto.getBuilding()))) { 426 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_BUILDING, dto.getBuilding()); 427 commands.add(command); 428 } 429 } 430 431 if (dto.isSaveCity()) { 432 String value = selection.get(TagDialog.TAG_ADDR_CITY); 433 if (value == null || (value != null && !value.equals(dto.getCity()))) { 434 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_CITY, dto.getCity()); 435 commands.add(command); 436 } 437 } 438 439 if (dto.isSaveCountry()) { 440 String value = selection.get(TagDialog.TAG_ADDR_COUNTRY); 441 if (value == null || (value != null && !value.equals(dto.getCountry()))) { 442 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_COUNTRY, dto.getCountry()); 443 commands.add(command); 444 } 445 } 446 447 if (dto.isSaveHousenumber()) { 448 String value = selection.get(TagDialog.TAG_ADDR_HOUSENUMBER); 449 if (value == null || (value != null && !value.equals(dto.getHousenumber()))) { 450 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_HOUSENUMBER, dto.getHousenumber()); 451 commands.add(command); 452 } 453 } 454 455 if (dto.isSavePostcode()) { 456 String value = selection.get(TagDialog.TAG_ADDR_POSTCODE); 457 if (value == null || (value != null && !value.equals(dto.getPostcode()))) { 458 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_POSTCODE, dto.getPostcode()); 459 commands.add(command); 460 } 461 } 462 463 if (dto.isSaveStreet()) { 464 if (dto.isTagStreet()) { 474 465 String value = selection.get(TagDialog.TAG_ADDR_STREET); 475 if (value == null || (value != null && !value.equals(dto.getStreet()))) 476 { 466 if (value == null || (value != null && !value.equals(dto.getStreet()))) { 477 467 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STREET, dto.getStreet()); 478 468 commands.add(command); 479 469 480 470 // remove old place-tag 481 if (selection.get(TagDialog.TAG_ADDR_PLACE) != null) 482 { 471 if (selection.get(TagDialog.TAG_ADDR_PLACE) != null) { 483 472 ChangePropertyCommand command2 = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_PLACE, null); 484 473 commands.add(command2); 485 474 } 486 475 } 487 } 488 else 489 { 476 } else { 490 477 String value = selection.get(TagDialog.TAG_ADDR_PLACE); 491 if (value == null || (value != null && !value.equals(dto.getStreet()))) 492 { 478 if (value == null || (value != null && !value.equals(dto.getStreet()))) { 493 479 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_PLACE, dto.getStreet()); 494 480 commands.add(command); 495 481 496 482 // remove old place-tag 497 if (selection.get(TagDialog.TAG_ADDR_STREET) != null) 498 { 483 if (selection.get(TagDialog.TAG_ADDR_STREET) != null) { 499 484 ChangePropertyCommand command2 = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STREET, null); 500 485 commands.add(command2); … … 504 489 } 505 490 506 if (dto.isSaveState()) { 507 String value = selection.get(TagDialog.TAG_ADDR_STATE); 508 if (value == null || (value != null && !value.equals(dto.getState()))) { 509 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STATE, dto.getState()); 510 commands.add(command); 511 } 512 } 513 514 if (commands.size() > 0) {515 SequenceCommand sequenceCommand = new SequenceCommand( trn("Updating properties of up to {0} object", "Updating properties of up to {0} objects", commands.size(), commands.size()), commands);516 517 // executes thecommandsand adds them to the undo/redo chains518 Main.main.undoRedo.add(sequenceCommand); 519 }520 }521 522 private Collection<String> getPossibleStreets() {523 /** 524 * Generates a list of all visible names of highways in order to do autocompletion on the road name.525 */526 TreeSet<String>names= new TreeSet<>();527 for (OsmPrimitive osm : Main.main.getCurrentDataSet().allNonDeletedPrimitives())528 {529 if (osm.getKeys() != null && osm.keySet().contains("highway") && osm.keySet().contains("name"))530 { 531 names.add(osm.get("name")); 532 } 533 } 534 return names; 535 } 491 if (dto.isSaveState()) { 492 String value = selection.get(TagDialog.TAG_ADDR_STATE); 493 if (value == null || (value != null && !value.equals(dto.getState()))) { 494 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STATE, dto.getState()); 495 commands.add(command); 496 } 497 } 498 499 if (!commands.isEmpty()) { 500 SequenceCommand sequenceCommand = new SequenceCommand( 501 trn("Updating properties of up to {0} object", 502 "Updating properties of up to {0} objects", commands.size(), commands.size()), commands); 503 504 // executes the commands and adds them to the undo/redo chains 505 Main.main.undoRedo.add(sequenceCommand); 506 } 507 } 508 509 private Collection<String> getPossibleStreets() { 510 /** 511 * Generates a list of all visible names of highways in order to do autocompletion on the road name. 512 */ 513 Set<String> names = new TreeSet<>(); 514 for (OsmPrimitive osm : Main.main.getCurrentDataSet().allNonDeletedPrimitives()) { 515 if (osm.getKeys() != null && osm.keySet().contains("highway") && osm.keySet().contains("name")) { 516 names.add(osm.get("name")); 517 } 518 } 519 return names; 520 } 536 521 537 522 private Dto loadDto() { … … 542 527 if (fileName.exists()) { 543 528 try ( 544 545 529 FileInputStream file = new FileInputStream(fileName); 530 ObjectInputStream o = new ObjectInputStream(file); 546 531 ) { 547 532 dto = (Dto) o.readObject(); 548 533 } 549 534 } else { 550 551 552 553 554 555 535 dto.setCity(selection.get(TagDialog.TAG_ADDR_CITY)); 536 dto.setCountry(selection.get(TagDialog.TAG_ADDR_COUNTRY)); 537 dto.setHousenumber(selection.get(TagDialog.TAG_ADDR_HOUSENUMBER)); 538 dto.setPostcode(selection.get(TagDialog.TAG_ADDR_POSTCODE)); 539 dto.setStreet(selection.get(TagDialog.TAG_ADDR_STREET)); 540 dto.setState(selection.get(TagDialog.TAG_ADDR_STATE)); 556 541 } 557 542 } catch (Exception ex) { 558 logger.log(Level.SEVERE, ex.getMessage());543 LOGGER.log(Level.SEVERE, ex.getMessage()); 559 544 fileName.delete(); 560 545 } … … 564 549 class RadioChangeListener implements ItemListener { 565 550 566 @Override 567 public void itemStateChanged(ItemEvent e) 568 { 569 if (streetRadio.isSelected()) 570 { 551 @Override 552 public void itemStateChanged(ItemEvent e) { 553 if (streetRadio.isSelected()) { 571 554 street.setPossibleItems(getPossibleStreets()); 572 } 573 else 574 { 555 } else { 575 556 street.setPossibleACItems(acm.getValues(TAG_ADDR_PLACE)); 576 557 } 577 558 } 578 579 559 } 580 560 }
Note:
See TracChangeset
for help on using the changeset viewer.