Changeset 30048 in osm for applications/editors/josm/plugins
- Timestamp:
- 2013-11-13T20:36:34+01:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/Dto.java
r29475 r30048 8 8 public class Dto implements Serializable 9 9 { 10 private static final long serialVersionUID = -4035800761473241695L; 10 11 private static final long serialVersionUID = 5226513739078369787L; 11 12 12 13 private boolean saveBuilding = true; … … 18 19 private boolean saveHousenumber = true; 19 20 21 private boolean tagStreet = true; // use tag addr:street or addr:place 22 20 23 private String building = "yes"; 21 24 private String country; … … 24 27 private String postcode; 25 28 private String street; 29 private String place; 26 30 private String housenumber; 27 31 private int housenumberChangeValue = 0; … … 176 180 this.building = building; 177 181 } 182 183 public boolean isTagStreet() 184 { 185 return tagStreet; 186 } 187 188 public void setTagStreet(boolean tagStreet) 189 { 190 this.tagStreet = tagStreet; 191 } 192 193 public String getPlace() 194 { 195 return place; 196 } 197 198 public void setPlace(String place) 199 { 200 this.place = place; 201 } 178 202 } -
applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/TagDialog.java
r29778 r30048 8 8 import java.awt.GridBagLayout; 9 9 import java.awt.event.ActionEvent; 10 import java.awt.event.ItemEvent; 11 import java.awt.event.ItemListener; 10 12 import java.io.File; 11 13 import java.io.FileInputStream; … … 20 22 import java.util.logging.Logger; 21 23 24 import javax.swing.ButtonGroup; 22 25 import javax.swing.JCheckBox; 23 26 import javax.swing.JComboBox; 24 27 import javax.swing.JLabel; 25 28 import javax.swing.JPanel; 29 import javax.swing.JRadioButton; 26 30 import javax.swing.JSlider; 27 31 import javax.swing.JTextField; … … 45 49 { 46 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'"); 47 52 48 53 public static final String TAG_BUILDING = "building"; … … 53 58 public static final String TAG_ADDR_HOUSENUMBER = "addr:housenumber"; 54 59 public static final String TAG_ADDR_STREET = "addr:street"; 60 public static final String TAG_ADDR_PLACE = "addr:place"; 55 61 56 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" }; 57 63 58 64 private static final int FPS_MIN = -2; 59 private static final int FPS_MAX = 2;65 private static final int FPS_MAX = 2; 60 66 61 67 private static final long serialVersionUID = 6414385452106276923L; … … 83 89 private JCheckBox housenumberEnabled; 84 90 private JSlider housenumberChangeSequence; 85 private JComboBox building; 91 private JComboBox<String[]> building; 92 private JRadioButton streetRadio; 93 private JRadioButton placeRadio; 86 94 87 95 public TagDialog(String pluginDir, OsmPrimitive p_selection) … … 127 135 c.gridy = 0; 128 136 c.weightx = 0; 137 c.gridwidth = 3; 129 138 editPanel.add(buildingEnabled, c); 130 139 … … 133 142 building.setSelectedItem(dto.getBuilding()); 134 143 building.setMaximumRowCount(50); 135 c.gridx = 1;144 c.gridx = 3; 136 145 c.gridy = 0; 137 146 c.weightx = 1; 147 c.gridwidth = 1; 138 148 editPanel.add(building, c); 139 149 … … 148 158 c.gridy = 1; 149 159 c.weightx = 0; 160 c.gridwidth = 3; 150 161 editPanel.add(countryEnabled, c); 151 162 … … 156 167 country.setSelectedItem(dto.getCountry()); 157 168 c.fill = GridBagConstraints.HORIZONTAL; 158 c.gridx = 1;169 c.gridx = 3; 159 170 c.gridy = 1; 160 171 c.weightx = 1; 172 c.gridwidth = 1; 161 173 editPanel.add(country, c); 162 174 … … 171 183 c.gridy = 2; 172 184 c.weightx = 0; 185 c.gridwidth = 3; 173 186 editPanel.add(stateEnabled, c); 174 187 … … 179 192 state.setSelectedItem(dto.getState()); 180 193 c.fill = GridBagConstraints.HORIZONTAL; 181 c.gridx = 1;194 c.gridx = 3; 182 195 c.gridy = 2; 183 196 c.weightx = 1; 197 c.gridwidth = 1; 184 198 editPanel.add(state, c); 185 199 … … 193 207 c.gridy = 3; 194 208 c.weightx = 0; 209 c.gridwidth = 3; 195 210 editPanel.add(cityEnabled, c); 196 211 … … 201 216 city.setSelectedItem(dto.getCity()); 202 217 c.fill = GridBagConstraints.HORIZONTAL; 203 c.gridx = 1;218 c.gridx = 3; 204 219 c.gridy = 3; 205 220 c.weightx = 1; 221 c.gridwidth = 1; 206 222 editPanel.add(city, c); 207 223 … … 215 231 c.gridy = 4; 216 232 c.weightx = 0; 233 c.gridwidth = 3; 217 234 editPanel.add(zipEnabled, c); 218 235 … … 223 240 postcode.setSelectedItem(dto.getPostcode()); 224 241 c.fill = GridBagConstraints.HORIZONTAL; 225 c.gridx = 1;242 c.gridx = 3; 226 243 c.gridy = 4; 227 244 c.weightx = 1; 245 c.gridwidth = 1; 228 246 editPanel.add(postcode, c); 229 247 230 248 // street 231 streetEnabled = new JCheckBox( TAG_ADDR_STREET);249 streetEnabled = new JCheckBox(); 232 250 streetEnabled.setFocusable(false); 233 251 streetEnabled.setSelected(dto.isSaveStreet()); … … 237 255 c.gridy = 5; 238 256 c.weightx = 0; 257 c.gridwidth = 1; 239 258 editPanel.add(streetEnabled, c); 240 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 241 287 street = new AutoCompletingComboBox(); 242 street.setPossibleItems(getPossibleStreets()); 288 if (dto.isTagStreet()) 289 { 290 street.setPossibleItems(getPossibleStreets()); 291 } 292 else 293 { 294 street.setPossibleACItems(acm.getValues(TAG_ADDR_PLACE)); 295 } 243 296 street.setPreferredSize(new Dimension(200, 24)); 244 297 street.setEditable(true); 245 298 street.setSelectedItem(dto.getStreet()); 246 299 c.fill = GridBagConstraints.HORIZONTAL; 247 c.gridx = 1;300 c.gridx = 3; 248 301 c.gridy = 5; 249 302 c.weightx = 1; 303 c.gridwidth = 1; 250 304 editPanel.add(street, c); 251 305 … … 259 313 c.gridy = 6; 260 314 c.weightx = 0; 315 c.gridwidth = 3; 261 316 editPanel.add(housenumberEnabled, c); 262 317 … … 275 330 276 331 c.fill = GridBagConstraints.HORIZONTAL; 277 c.gridx = 1;332 c.gridx = 3; 278 333 c.gridy = 6; 279 334 c.weightx = 1; 335 c.gridwidth = 1; 280 336 editPanel.add(housnumber, c); 281 337 … … 285 341 c.gridy = 7; 286 342 c.weightx = 0; 343 c.gridwidth = 3; 287 344 editPanel.add(seqLabel, c); 288 345 … … 293 350 housenumberChangeSequence.setPaintLabels(true); 294 351 housenumberChangeSequence.setSnapToTicks(true); 295 c.gridx = 1;352 c.gridx = 3; 296 353 c.gridy = 7; 297 354 c.weightx = 1; 355 c.gridwidth = 1; 298 356 editPanel.add(housenumberChangeSequence, c); 299 357 … … 313 371 dto.setSavePostcode(zipEnabled.isSelected()); 314 372 dto.setSaveStreet(streetEnabled.isSelected()); 315 373 dto.setTagStreet(streetRadio.isSelected()); 374 316 375 dto.setBuilding((String) building.getSelectedItem()); 317 376 dto.setCity(getAutoCompletingComboBoxValue(city)); … … 408 467 } 409 468 410 if (dto.isSaveStreet()) { 411 String value = selection.get(TagDialog.TAG_ADDR_STREET); 412 if (value == null || (value != null && !value.equals(dto.getStreet()))) 413 { 414 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STREET, dto.getStreet()); 415 commands.add(command); 416 } 417 } 469 if (dto.isSaveStreet()) 470 { 471 if (dto.isTagStreet()) 472 { 473 String value = selection.get(TagDialog.TAG_ADDR_STREET); 474 if (value == null || (value != null && !value.equals(dto.getStreet()))) 475 { 476 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STREET, dto.getStreet()); 477 commands.add(command); 478 479 // remove old place-tag 480 if (selection.get(TagDialog.TAG_ADDR_PLACE) != null) 481 { 482 ChangePropertyCommand command2 = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_PLACE, null); 483 commands.add(command2); 484 } 485 } 486 } 487 else 488 { 489 String value = selection.get(TagDialog.TAG_ADDR_PLACE); 490 if (value == null || (value != null && !value.equals(dto.getStreet()))) 491 { 492 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_PLACE, dto.getStreet()); 493 commands.add(command); 494 495 // remove old place-tag 496 if (selection.get(TagDialog.TAG_ADDR_STREET) != null) 497 { 498 ChangePropertyCommand command2 = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STREET, null); 499 commands.add(command2); 500 } 501 } 502 } 503 } 418 504 419 505 if (dto.isSaveState()) { … … 475 561 476 562 } 563 564 class RadioChangeListener implements ItemListener 565 { 566 567 @Override 568 public void itemStateChanged(ItemEvent e) 569 { 570 if (streetRadio.isSelected()) 571 { 572 street.setPossibleItems(getPossibleStreets()); 573 } 574 else 575 { 576 street.setPossibleACItems(acm.getValues(TAG_ADDR_PLACE)); 577 } 578 } 579 580 } 477 581 }
Note:
See TracChangeset
for help on using the changeset viewer.