Changeset 35508 in osm for applications/editors/josm/plugins
- Timestamp:
- 2020-07-11T12:54:08+02:00 (4 years ago)
- Location:
- applications/editors/josm/plugins/HouseNumberTaggingTool
- Files:
-
- 1 added
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/HouseNumberTaggingTool
- Property svn:ignore
-
old new 6 6 spotbugs-josm-HouseNumberTaggingTool.xml 7 7 javadoc 8 .idea 9 JOSM-HouseNumberTaggingTool.iml
-
- Property svn:ignore
-
applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/Dto.java
r34070 r35508 9 9 public class Dto implements Serializable { 10 10 11 private static final long serialVersionUID = 5226513739078369787L;11 private static final long serialVersionUID = 7719940860196679722L; 12 12 13 13 private boolean saveBuilding = true; 14 private boolean saveSource = true; 14 15 private boolean saveCountry = true; 15 16 private boolean saveState = true; 16 17 private boolean saveCity = true; 18 private boolean saveSuburb = true; 17 19 private boolean savePostcode = true; 18 20 private boolean saveStreet = true; … … 22 24 23 25 private String building = "yes"; 26 private String source; 24 27 private String country; 25 28 private String state; 26 29 private String city; 30 private String suburb; 27 31 private String postcode; 28 32 private String street; … … 166 170 this.place = place; 167 171 } 172 173 public boolean isSaveSuburb() { 174 return saveSuburb; 175 } 176 177 public void setSaveSuburb(boolean saveSuburb) { 178 this.saveSuburb = saveSuburb; 179 } 180 181 public String getSuburb() { 182 return suburb; 183 } 184 185 public void setSuburb(String suburb) { 186 this.suburb = suburb; 187 } 188 189 public boolean isSaveSource() { 190 return saveSource; 191 } 192 193 public void setSaveSource(boolean saveSource) { 194 this.saveSource = saveSource; 195 } 196 197 public String getSource() { 198 return source; 199 } 200 201 public void setSource(String source) { 202 this.source = source; 203 } 168 204 } -
applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/TagDialog.java
r35506 r35508 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.housenumbertool; 3 4 import static org.openstreetmap.josm.tools.I18n.tr;5 import static org.openstreetmap.josm.tools.I18n.trn;6 7 import java.awt.Dimension;8 import java.awt.GridBagConstraints;9 import java.awt.GridBagLayout;10 import java.awt.event.ActionEvent;11 import java.awt.event.ItemEvent;12 import java.awt.event.ItemListener;13 import java.io.File;14 import java.io.FileInputStream;15 import java.io.FileOutputStream;16 import java.io.ObjectInputStream;17 import java.io.ObjectOutputStream;18 import java.util.ArrayList;19 import java.util.Arrays;20 import java.util.Collection;21 import java.util.List;22 import java.util.Set;23 import java.util.TreeSet;24 import java.util.logging.Level;25 import java.util.logging.Logger;26 import java.util.regex.Matcher;27 import java.util.regex.Pattern;28 29 import javax.swing.ButtonGroup;30 import javax.swing.JCheckBox;31 import javax.swing.JComboBox;32 import javax.swing.JLabel;33 import javax.swing.JPanel;34 import javax.swing.JRadioButton;35 import javax.swing.JSlider;36 import javax.swing.JTextField;37 import javax.swing.SwingUtilities;38 3 39 4 import org.openstreetmap.josm.command.ChangePropertyCommand; … … 48 13 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; 49 14 15 import javax.swing.*; 16 import java.awt.*; 17 import java.awt.event.ActionEvent; 18 import java.awt.event.ItemEvent; 19 import java.awt.event.ItemListener; 20 import java.io.*; 21 import java.util.List; 22 import java.util.*; 23 import java.util.logging.Level; 24 import java.util.logging.Logger; 25 26 import static org.openstreetmap.josm.tools.I18n.tr; 27 import static org.openstreetmap.josm.tools.I18n.trn; 28 50 29 /** 51 30 * @author Oliver Raupach 09.01.2012 … … 57 36 58 37 private static final String TAG_BUILDING = "building"; 38 private static final String TAG_SOURCE = "source"; 59 39 private static final String TAG_ADDR_COUNTRY = "addr:country"; 60 40 private static final String TAG_ADDR_STATE = "addr:state"; … … 64 44 private static final String TAG_ADDR_STREET = "addr:street"; 65 45 private static final String TAG_ADDR_PLACE = "addr:place"; 46 private static final String TAG_ADDR_SUBURB = "addr:suburb"; 66 47 67 48 private static final String[] BUILDING_STRINGS = { … … 82 63 private static final String TEMPLATE_DATA = "/template.data"; 83 64 65 private AutoCompletingComboBox source; 84 66 private AutoCompletingComboBox country; 85 67 private AutoCompletingComboBox state; 68 private AutoCompletingComboBox suburb; 86 69 private AutoCompletingComboBox city; 87 70 private AutoCompletingComboBox postcode; … … 89 72 private JTextField housnumber; 90 73 private JCheckBox buildingEnabled; 74 private JCheckBox sourceEnabled; 91 75 private JCheckBox countryEnabled; 92 76 private JCheckBox stateEnabled; 93 77 private JCheckBox cityEnabled; 78 private JCheckBox suburbEnabled; 94 79 private JCheckBox zipEnabled; 95 80 private JCheckBox streetEnabled; … … 98 83 private JComboBox<String> building; 99 84 private JRadioButton streetRadio; 85 private JRadioButton placeRadio; 100 86 101 87 /** … … 111 97 JPanel editPanel = createContentPane(); 112 98 113 setPreferredSize(new Dimension( 700, 300));114 setMinimumSize(new Dimension( 700, 300));99 setPreferredSize(new Dimension(900, 500)); 100 setMinimumSize(new Dimension(900, 500)); 115 101 116 102 setContent(editPanel); … … 137 123 GridBagConstraints c = new GridBagConstraints(); 138 124 125 JLabel labelNewValues = new JLabel(); 126 Font newLabelFont = new Font(labelNewValues.getFont().getName(), Font.BOLD, labelNewValues.getFont().getSize()); 127 labelNewValues.setFont(newLabelFont); 128 labelNewValues.setText(tr("New values:")); 129 c.fill = GridBagConstraints.HORIZONTAL; 130 c.gridx = 3; 131 c.gridy = 0; 132 c.weightx = 0; 133 c.gridwidth = 1; 134 c.insets = new Insets(0, 5, 10, 5); 135 editPanel.add(labelNewValues, c); 136 137 JLabel labelExistingValues = new JLabel(); 138 labelExistingValues.setFont(newLabelFont); 139 labelExistingValues.setText(tr("Existing values:")); 140 c.fill = GridBagConstraints.HORIZONTAL; 141 c.gridx = 5; 142 c.gridy = 0; 143 c.weightx = 0; 144 c.gridwidth = 1; 145 c.insets = new Insets(0, 5, 10, 5); 146 editPanel.add(labelExistingValues, c); 147 148 JButton getAllButton = new JButton("<<"); 149 getAllButton.setPreferredSize(new Dimension(60, 24)); 150 getAllButton.setToolTipText(tr("Accept all existing values")); 151 getAllButton.addActionListener(actionEvent -> acceptAllExistingValues()); 152 GridBagConstraints buttonContstraints = new GridBagConstraints(); 153 buttonContstraints.fill = GridBagConstraints.NONE; 154 buttonContstraints.gridx = 6; 155 buttonContstraints.gridy = 0; 156 buttonContstraints.weightx = 0; 157 buttonContstraints.gridwidth = 1; 158 buttonContstraints.anchor = GridBagConstraints.EAST; 159 buttonContstraints.insets = new Insets(0, 5, 10, 5); 160 editPanel.add(getAllButton, buttonContstraints); 161 162 // building 139 163 buildingEnabled = new JCheckBox(TAG_BUILDING); 140 164 buildingEnabled.setFocusable(false); … … 143 167 c.fill = GridBagConstraints.HORIZONTAL; 144 168 c.gridx = 0; 145 c.gridy = 0;169 c.gridy = 1; 146 170 c.weightx = 0; 147 171 c.gridwidth = 3; 172 c.insets = new Insets(5, 5, 0, 5); 148 173 editPanel.add(buildingEnabled, c); 149 174 … … 153 178 building.setMaximumRowCount(50); 154 179 c.gridx = 3; 155 c.gridy = 0; 156 c.weightx = 1; 157 c.gridwidth = 1; 180 c.gridy = 1; 181 c.weightx = 1; 182 c.gridwidth = 1; 183 c.insets = new Insets(5, 5, 0, 5); 158 184 editPanel.add(building, c); 185 186 JButton getBuildingButton = new JButton("<"); 187 getBuildingButton.setPreferredSize(new Dimension(45, 24)); 188 getBuildingButton.setToolTipText(tr("Accept existing value")); 189 getBuildingButton.addActionListener(actionEvent -> building.setSelectedItem(selection.get(TAG_BUILDING))); 190 c.fill = GridBagConstraints.NONE; 191 c.gridx = 4; 192 c.gridy = 1; 193 c.weightx = 0; 194 c.gridwidth = 1; 195 c.insets = new Insets(5, 5, 0, 5); 196 editPanel.add(getBuildingButton, c); 197 198 JTextField existingBuilding = new JTextField(); 199 existingBuilding.setText(selection.get(TAG_BUILDING)); 200 existingBuilding.setPreferredSize(new Dimension(200, 24)); 201 existingBuilding.setEditable(false); 202 c.fill = GridBagConstraints.HORIZONTAL; 203 c.gridx = 5; 204 c.gridy = 1; 205 c.weightx = 1; 206 c.gridwidth = 2; 207 c.insets = new Insets(5, 5, 0, 5); 208 editPanel.add(existingBuilding, c); 209 210 // source 211 sourceEnabled = new JCheckBox(TAG_SOURCE); 212 sourceEnabled.setFocusable(false); 213 sourceEnabled.setSelected(dto.isSaveBuilding()); 214 sourceEnabled.setToolTipText(APPLY_CHANGES); 215 c.fill = GridBagConstraints.HORIZONTAL; 216 c.gridx = 0; 217 c.gridy = 2; 218 c.weightx = 0; 219 c.gridwidth = 3; 220 c.insets = new Insets(5, 5, 0, 5); 221 editPanel.add(sourceEnabled, c); 222 223 source = new AutoCompletingComboBox(); 224 source.setPossibleAcItems(acm.getTagValues(TAG_SOURCE)); 225 source.setPreferredSize(new Dimension(200, 24)); 226 source.setEditable(true); 227 source.setSelectedItem(dto.getSource()); 228 c.gridx = 3; 229 c.gridy = 2; 230 c.weightx = 1; 231 c.gridwidth = 1; 232 c.insets = new Insets(5, 5, 0, 5); 233 editPanel.add(source, c); 234 235 JButton getSourceButton = new JButton("<"); 236 getSourceButton.setPreferredSize(new Dimension(45, 24)); 237 getSourceButton.setToolTipText(tr("Accept existing value")); 238 getSourceButton.addActionListener(actionEvent -> source.setSelectedItem(selection.get(TAG_SOURCE))); 239 c.fill = GridBagConstraints.NONE; 240 c.gridx = 4; 241 c.gridy = 2; 242 c.weightx = 0; 243 c.gridwidth = 1; 244 c.insets = new Insets(5, 5, 0, 5); 245 editPanel.add(getSourceButton, c); 246 247 JTextField existingSource = new JTextField(); 248 existingSource.setText(selection.get(TAG_SOURCE)); 249 existingSource.setPreferredSize(new Dimension(200, 24)); 250 existingSource.setEditable(false); 251 c.fill = GridBagConstraints.HORIZONTAL; 252 c.gridx = 5; 253 c.gridy = 2; 254 c.weightx = 1; 255 c.gridwidth = 2; 256 c.insets = new Insets(5, 5, 0, 5); 257 editPanel.add(existingSource, c); 159 258 160 259 // country … … 166 265 c.fill = GridBagConstraints.HORIZONTAL; 167 266 c.gridx = 0; 168 c.gridy = 1;267 c.gridy = 3; 169 268 c.weightx = 0; 170 269 c.gridwidth = 3; 270 c.insets = new Insets(5, 5, 0, 5); 171 271 editPanel.add(countryEnabled, c); 172 272 … … 178 278 c.fill = GridBagConstraints.HORIZONTAL; 179 279 c.gridx = 3; 180 c.gridy = 1; 181 c.weightx = 1; 182 c.gridwidth = 1; 280 c.gridy = 3; 281 c.weightx = 1; 282 c.gridwidth = 1; 283 c.insets = new Insets(5, 5, 0, 5); 183 284 editPanel.add(country, c); 285 286 JButton getCountryButton = new JButton("<"); 287 getCountryButton.setPreferredSize(new Dimension(45, 24)); 288 getCountryButton.setToolTipText(tr("Accept existing value")); 289 getCountryButton.addActionListener(actionEvent -> country.setSelectedItem(selection.get(TAG_ADDR_COUNTRY))); 290 c.fill = GridBagConstraints.NONE; 291 c.gridx = 4; 292 c.gridy = 3; 293 c.weightx = 0; 294 c.gridwidth = 1; 295 c.insets = new Insets(5, 5, 0, 5); 296 editPanel.add(getCountryButton, c); 297 298 JTextField existingCountry = new JTextField(); 299 existingCountry.setText(selection.get(TAG_ADDR_COUNTRY)); 300 existingCountry.setPreferredSize(new Dimension(200, 24)); 301 existingCountry.setEditable(false); 302 c.fill = GridBagConstraints.HORIZONTAL; 303 c.gridx = 5; 304 c.gridy = 3; 305 c.weightx = 1; 306 c.gridwidth = 2; 307 c.insets = new Insets(5, 5, 0, 5); 308 editPanel.add(existingCountry, c); 184 309 185 310 // state … … 188 313 stateEnabled.setSelected(dto.isSaveState()); 189 314 stateEnabled.setToolTipText(APPLY_CHANGES); 190 c = new GridBagConstraints();191 315 c.fill = GridBagConstraints.HORIZONTAL; 192 316 c.gridx = 0; 193 c.gridy = 2;317 c.gridy = 4; 194 318 c.weightx = 0; 195 319 c.gridwidth = 3; 320 c.insets = new Insets(5, 5, 0, 5); 196 321 editPanel.add(stateEnabled, c); 197 322 … … 203 328 c.fill = GridBagConstraints.HORIZONTAL; 204 329 c.gridx = 3; 205 c.gridy = 2; 206 c.weightx = 1; 207 c.gridwidth = 1; 330 c.gridy = 4; 331 c.weightx = 1; 332 c.gridwidth = 1; 333 c.insets = new Insets(5, 5, 0, 5); 208 334 editPanel.add(state, c); 335 336 JButton getStateButton = new JButton("<"); 337 getStateButton.setPreferredSize(new Dimension(45, 24)); 338 getStateButton.setToolTipText(tr("Accept existing value")); 339 getStateButton.addActionListener(actionEvent -> state.setSelectedItem(selection.get(TAG_ADDR_STATE))); 340 c.fill = GridBagConstraints.NONE; 341 c.gridx = 4; 342 c.gridy = 4; 343 c.weightx = 0; 344 c.gridwidth = 1; 345 c.insets = new Insets(5, 5, 0, 5); 346 editPanel.add(getStateButton, c); 347 348 JTextField existingState= new JTextField(); 349 existingState.setText(selection.get(TAG_ADDR_STATE)); 350 existingState.setPreferredSize(new Dimension(200, 24)); 351 existingState.setEditable(false); 352 c.fill = GridBagConstraints.HORIZONTAL; 353 c.gridx = 5; 354 c.gridy = 4; 355 c.weightx = 1; 356 c.gridwidth = 2; 357 c.insets = new Insets(5, 5, 0, 5); 358 editPanel.add(existingState, c); 359 360 // suburb 361 suburbEnabled = new JCheckBox(TAG_ADDR_SUBURB); 362 suburbEnabled.setFocusable(false); 363 suburbEnabled.setSelected(dto.isSaveSuburb()); 364 suburbEnabled.setToolTipText(APPLY_CHANGES); 365 c.fill = GridBagConstraints.HORIZONTAL; 366 c.gridx = 0; 367 c.gridy = 5; 368 c.weightx = 0; 369 c.gridwidth = 3; 370 c.insets = new Insets(5, 5, 0, 5); 371 editPanel.add(suburbEnabled, c); 372 373 suburb = new AutoCompletingComboBox(); 374 suburb.setPossibleAcItems(acm.getTagValues(TAG_ADDR_SUBURB)); 375 suburb.setPreferredSize(new Dimension(200, 24)); 376 suburb.setEditable(true); 377 suburb.setSelectedItem(dto.getSuburb()); 378 c.fill = GridBagConstraints.HORIZONTAL; 379 c.gridx = 3; 380 c.gridy = 5; 381 c.weightx = 1; 382 c.gridwidth = 1; 383 c.insets = new Insets(5, 5, 0, 5); 384 editPanel.add(suburb, c); 385 386 JButton getSuburbButton = new JButton("<"); 387 getSuburbButton.setPreferredSize(new Dimension(45, 24)); 388 getSuburbButton.setToolTipText(tr("Accept existing value")); 389 getSuburbButton.addActionListener(actionEvent -> suburb.setSelectedItem(selection.get(TAG_ADDR_SUBURB))); 390 c.fill = GridBagConstraints.NONE; 391 c.gridx = 4; 392 c.gridy = 5; 393 c.weightx = 0; 394 c.gridwidth = 1; 395 c.insets = new Insets(5, 5, 0, 5); 396 editPanel.add(getSuburbButton, c); 397 398 JTextField existingSuburb = new JTextField(); 399 existingSuburb.setText(selection.get(TAG_ADDR_SUBURB)); 400 existingSuburb.setPreferredSize(new Dimension(200, 24)); 401 existingSuburb.setEditable(false); 402 c.fill = GridBagConstraints.HORIZONTAL; 403 c.gridx = 5; 404 c.gridy = 5; 405 c.weightx = 1; 406 c.gridwidth = 2; 407 c.insets = new Insets(5, 5, 0, 5); 408 editPanel.add(existingSuburb, c); 209 409 210 410 // city … … 215 415 c.fill = GridBagConstraints.HORIZONTAL; 216 416 c.gridx = 0; 217 c.gridy = 3;417 c.gridy = 6; 218 418 c.weightx = 0; 219 419 c.gridwidth = 3; 420 c.insets = new Insets(5, 5, 0, 5); 220 421 editPanel.add(cityEnabled, c); 221 422 … … 227 428 c.fill = GridBagConstraints.HORIZONTAL; 228 429 c.gridx = 3; 229 c.gridy = 3; 230 c.weightx = 1; 231 c.gridwidth = 1; 430 c.gridy = 6; 431 c.weightx = 1; 432 c.gridwidth = 1; 433 c.insets = new Insets(5, 5, 0, 5); 232 434 editPanel.add(city, c); 435 436 JButton getCityButton = new JButton("<"); 437 getCityButton.setPreferredSize(new Dimension(45, 24)); 438 getCityButton.setToolTipText(tr("Accept existing value")); 439 getCityButton.addActionListener(actionEvent -> city.setSelectedItem(selection.get(TAG_ADDR_CITY))); 440 c.fill = GridBagConstraints.NONE; 441 c.gridx = 4; 442 c.gridy = 6; 443 c.weightx = 0; 444 c.gridwidth = 1; 445 c.insets = new Insets(5, 5, 0, 5); 446 editPanel.add(getCityButton, c); 447 448 JTextField existingCity = new JTextField(); 449 existingCity.setText(selection.get(TAG_ADDR_CITY)); 450 existingCity.setPreferredSize(new Dimension(200, 24)); 451 existingCity.setEditable(false); 452 c.fill = GridBagConstraints.HORIZONTAL; 453 c.gridx = 5; 454 c.gridy = 6; 455 c.weightx = 1; 456 c.gridwidth = 2; 457 c.insets = new Insets(5, 5, 0, 5); 458 editPanel.add(existingCity, c); 233 459 234 460 // postcode … … 239 465 c.fill = GridBagConstraints.HORIZONTAL; 240 466 c.gridx = 0; 241 c.gridy = 4;467 c.gridy = 7; 242 468 c.weightx = 0; 243 469 c.gridwidth = 3; 470 c.insets = new Insets(5, 5, 0, 5); 244 471 editPanel.add(zipEnabled, c); 245 472 … … 251 478 c.fill = GridBagConstraints.HORIZONTAL; 252 479 c.gridx = 3; 253 c.gridy = 4; 254 c.weightx = 1; 255 c.gridwidth = 1; 480 c.gridy = 7; 481 c.weightx = 1; 482 c.gridwidth = 1; 483 c.insets = new Insets(5, 5, 0, 5); 256 484 editPanel.add(postcode, c); 485 486 JButton getPostcodeButton = new JButton("<"); 487 getPostcodeButton.setPreferredSize(new Dimension(45, 24)); 488 getPostcodeButton.setToolTipText(tr("Accept existing value")); 489 getPostcodeButton.addActionListener(actionEvent -> postcode.setSelectedItem(selection.get(TAG_ADDR_POSTCODE))); 490 c.fill = GridBagConstraints.NONE; 491 c.gridx = 4; 492 c.gridy = 7; 493 c.weightx = 0; 494 c.gridwidth = 1; 495 c.insets = new Insets(5, 5, 0, 5); 496 editPanel.add(getPostcodeButton, c); 497 498 JTextField existingPostcode = new JTextField(); 499 existingPostcode.setText(selection.get(TAG_ADDR_POSTCODE)); 500 existingPostcode.setPreferredSize(new Dimension(200, 24)); 501 existingPostcode.setEditable(false); 502 c.fill = GridBagConstraints.HORIZONTAL; 503 c.gridx = 5; 504 c.gridy = 7; 505 c.weightx = 1; 506 c.gridwidth = 2; 507 c.insets = new Insets(5, 5, 0, 5); 508 editPanel.add(existingPostcode, c); 257 509 258 510 // street … … 263 515 c.fill = GridBagConstraints.HORIZONTAL; 264 516 c.gridx = 0; 265 c.gridy = 5; 266 c.weightx = 0; 267 c.gridwidth = 1; 517 c.gridy = 8; 518 c.weightx = 0; 519 c.gridwidth = 1; 520 c.insets = new Insets(5, 5, 0, 5); 268 521 editPanel.add(streetEnabled, c); 269 522 … … 274 527 c.fill = GridBagConstraints.HORIZONTAL; 275 528 c.gridx = 1; 276 c.gridy = 5; 277 c.weightx = 0; 278 c.gridwidth = 1; 529 c.gridy = 8; 530 c.weightx = 0; 531 c.gridwidth = 1; 532 c.insets = new Insets(5, 5, 0, 5); 279 533 editPanel.add(streetRadio, c); 280 534 281 JRadioButtonplaceRadio = new JRadioButton("addr:place");535 placeRadio = new JRadioButton("addr:place"); 282 536 placeRadio.setToolTipText(TAG_STREET_OR_PLACE); 283 537 placeRadio.setSelected(!dto.isTagStreet()); … … 285 539 c.fill = GridBagConstraints.HORIZONTAL; 286 540 c.gridx = 2; 287 c.gridy = 5; 288 c.weightx = 0; 289 c.gridwidth = 1; 541 c.gridy = 8; 542 c.weightx = 0; 543 c.gridwidth = 1; 544 c.insets = new Insets(5, 5, 0, 5); 290 545 editPanel.add(placeRadio, c); 291 546 292 547 ButtonGroup g = new ButtonGroup(); 293 g.add( streetRadio);548 g.add(streetRadio); 294 549 g.add(placeRadio); 295 550 … … 305 560 c.fill = GridBagConstraints.HORIZONTAL; 306 561 c.gridx = 3; 307 c.gridy = 5; 308 c.weightx = 1; 309 c.gridwidth = 1; 562 c.gridy = 8; 563 c.weightx = 1; 564 c.gridwidth = 1; 565 c.insets = new Insets(5, 5, 0, 5); 310 566 editPanel.add(street, c); 567 568 JButton getStreetButton = new JButton("<"); 569 getStreetButton.setPreferredSize(new Dimension(45, 24)); 570 getStreetButton.setToolTipText(tr("Accept existing value")); 571 getStreetButton.addActionListener(actionEvent -> updateStreetOrPlaceValues()); 572 c.fill = GridBagConstraints.NONE; 573 c.gridx = 4; 574 c.gridy = 8; 575 c.weightx = 0; 576 c.gridwidth = 1; 577 c.insets = new Insets(5, 5, 0, 5); 578 editPanel.add(getStreetButton, c); 579 580 JTextField streetOrPlace = new JTextField(); 581 streetOrPlace.setText(getStreetOrPlaceTag()); 582 streetOrPlace.setPreferredSize(new Dimension(50, 24)); 583 streetOrPlace.setEditable(false); 584 c.fill = GridBagConstraints.HORIZONTAL; 585 c.gridx = 5; 586 c.gridy = 8; 587 c.weightx = 0; 588 c.gridwidth = 1; 589 c.insets = new Insets(5, 5, 0, 5); 590 editPanel.add(streetOrPlace, c); 591 592 JTextField existingStreet = new JTextField(); 593 existingStreet.setText(getStreetOrPlaceValue()); 594 existingStreet.setPreferredSize(new Dimension(100, 24)); 595 existingStreet.setEditable(false); 596 c.fill = GridBagConstraints.HORIZONTAL; 597 c.gridx = 6; 598 c.gridy = 8; 599 c.weightx = 1; 600 c.gridwidth = 1; 601 c.insets = new Insets(5, 5, 0, 5); 602 editPanel.add(existingStreet, c); 603 311 604 312 605 // housenumber … … 317 610 c.fill = GridBagConstraints.HORIZONTAL; 318 611 c.gridx = 0; 319 c.gridy = 6;612 c.gridy = 9; 320 613 c.weightx = 0; 321 614 c.gridwidth = 3; 615 c.insets = new Insets(5, 5, 0, 5); 322 616 editPanel.add(housenumberEnabled, c); 323 617 … … 325 619 housnumber.setPreferredSize(new Dimension(200, 24)); 326 620 327 String number = incrementHouseNumber(dto.getHousenumber(), dto.getHousenumberChangeValue());621 String number = HouseNumberHelper.incrementHouseNumber(dto.getHousenumber(), dto.getHousenumberChangeValue()); 328 622 if (number != null) { 329 623 housnumber.setText(number); … … 332 626 c.fill = GridBagConstraints.HORIZONTAL; 333 627 c.gridx = 3; 334 c.gridy = 6; 335 c.weightx = 1; 336 c.gridwidth = 1; 628 c.gridy = 9; 629 c.weightx = 1; 630 c.gridwidth = 1; 631 c.insets = new Insets(5, 5, 0, 5); 337 632 editPanel.add(housnumber, c); 338 633 634 JButton getHousenumberButton = new JButton("<"); 635 getHousenumberButton.setPreferredSize(new Dimension(45, 24)); 636 getHousenumberButton.setToolTipText(tr("Accept existing value")); 637 getHousenumberButton.addActionListener(actionEvent -> housnumber.setText(selection.get(TAG_ADDR_HOUSENUMBER))); 638 c.fill = GridBagConstraints.NONE; 639 c.gridx = 4; 640 c.gridy = 9; 641 c.weightx = 0; 642 c.gridwidth = 1; 643 c.insets = new Insets(5, 5, 0, 5); 644 editPanel.add(getHousenumberButton, c); 645 646 JTextField existingHousenumber = new JTextField(); 647 existingHousenumber.setText(selection.get(TAG_ADDR_HOUSENUMBER)); 648 existingHousenumber.setPreferredSize(new Dimension(200, 24)); 649 existingHousenumber.setEditable(false); 650 c.fill = GridBagConstraints.HORIZONTAL; 651 c.gridx = 5; 652 c.gridy = 9; 653 c.weightx = 1; 654 c.gridwidth = 2; 655 c.insets = new Insets(5, 5, 0, 5); 656 editPanel.add(existingHousenumber, c); 657 658 // increment 339 659 JLabel seqLabel = new JLabel(tr("House number increment:")); 340 660 c.fill = GridBagConstraints.HORIZONTAL; 341 661 c.gridx = 0; 342 c.gridy = 7;662 c.gridy = 10; 343 663 c.weightx = 0; 344 664 c.gridwidth = 3; 665 c.insets = new Insets(5, 5, 0, 5); 345 666 editPanel.add(seqLabel, c); 346 667 347 housenumberChangeSequence = new JSlider(JSlider.HORIZONTAL, 668 housenumberChangeSequence = new JSlider(JSlider.HORIZONTAL, FPS_MIN, FPS_MAX, dto.getHousenumberChangeValue()); 348 669 housenumberChangeSequence.setPaintTicks(true); 349 670 housenumberChangeSequence.setMajorTickSpacing(1); … … 352 673 housenumberChangeSequence.setSnapToTicks(true); 353 674 c.gridx = 3; 354 c.gridy = 7; 355 c.weightx = 1; 356 c.gridwidth = 1; 675 c.gridy = 10; 676 c.weightx = 1; 677 c.gridwidth = 4; 678 c.insets = new Insets(20, 5, 10, 5); 357 679 editPanel.add(housenumberChangeSequence, c); 358 680 … … 360 682 } 361 683 362 static String incrementHouseNumber(String number, int increment) { 363 if (number != null) { 364 try { 365 Matcher m = Pattern.compile("([^\\pN]+)?(\\pN+)([^\\pN]+)?").matcher(number); 366 if (m.matches()) { 367 String prefix = m.group(1) != null ? m.group(1) : ""; 368 int n = Integer.parseInt(m.group(2)) + increment; 369 String suffix = m.group(3) != null ? m.group(3) : ""; 370 return prefix + n + suffix; 371 } 372 } catch (NumberFormatException e) { 373 // Do nothing 374 } 375 } 376 return null; 684 private void acceptAllExistingValues() { 685 updateStreetOrPlaceValues(); 686 building.setSelectedItem(selection.get(TAG_BUILDING)); 687 source.setSelectedItem(selection.get(TAG_SOURCE)); 688 country.setSelectedItem(selection.get(TAG_ADDR_COUNTRY)); 689 state.setSelectedItem(selection.get(TAG_ADDR_STATE)); 690 suburb.setSelectedItem(selection.get(TAG_ADDR_SUBURB)); 691 city.setSelectedItem(selection.get(TAG_ADDR_CITY)); 692 postcode.setSelectedItem(selection.get(TAG_ADDR_POSTCODE)); 693 housnumber.setText(selection.get(TAG_ADDR_HOUSENUMBER)); 694 } 695 696 private void updateStreetOrPlaceValues() { 697 if (selection.hasTag(TAG_ADDR_PLACE)) { 698 placeRadio.setSelected(true); 699 street.setSelectedItem(selection.get(TAG_ADDR_PLACE)); 700 }else { 701 streetRadio.setSelected(true); 702 street.setSelectedItem(selection.get(TAG_ADDR_STREET)); 703 } 704 } 705 706 private String getStreetOrPlaceValue() { 707 if (selection.hasTag(TAG_ADDR_PLACE)) { 708 return selection.get(TAG_ADDR_PLACE); 709 } else if (selection.hasTag(TAG_ADDR_STREET)) { 710 return selection.get(TAG_ADDR_STREET); 711 } else { 712 return ""; 713 } 714 } 715 716 private String getStreetOrPlaceTag() { 717 if (selection.hasTag(TAG_ADDR_PLACE)) { 718 return TAG_ADDR_PLACE; 719 } else if (selection.hasTag(TAG_ADDR_STREET)) { 720 return TAG_ADDR_STREET; 721 } else { 722 return ""; 723 } 377 724 } 378 725 … … 382 729 Dto dto = new Dto(); 383 730 dto.setSaveBuilding(buildingEnabled.isSelected()); 731 dto.setSaveSource(sourceEnabled.isSelected()); 384 732 dto.setSaveCity(cityEnabled.isSelected()); 385 733 dto.setSaveCountry(countryEnabled.isSelected()); … … 389 737 dto.setSaveStreet(streetEnabled.isSelected()); 390 738 dto.setTagStreet(streetRadio.isSelected()); 739 dto.setSaveSuburb(suburbEnabled.isSelected()); 391 740 392 741 dto.setBuilding((String) building.getSelectedItem()); 742 dto.setSource(getAutoCompletingComboBoxValue(source)); 393 743 dto.setCity(getAutoCompletingComboBoxValue(city)); 394 744 dto.setCountry(getAutoCompletingComboBoxValue(country)); … … 397 747 dto.setStreet(getAutoCompletingComboBoxValue(street)); 398 748 dto.setState(getAutoCompletingComboBoxValue(state)); 749 dto.setSuburb(getAutoCompletingComboBoxValue(suburb)); 399 750 dto.setHousenumberChangeValue(housenumberChangeSequence.getValue()); 400 751 … … 449 800 } 450 801 802 if (dto.isSaveSource()) { 803 String value = selection.get(TagDialog.TAG_SOURCE); 804 if (value == null || (value != null && !value.equals(dto.getSource()))) { 805 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_SOURCE, dto.getSource()); 806 commands.add(command); 807 } 808 } 809 451 810 if (dto.isSaveCity()) { 452 811 String value = selection.get(TagDialog.TAG_ADDR_CITY); … … 461 820 if (value == null || (value != null && !value.equals(dto.getCountry()))) { 462 821 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_COUNTRY, dto.getCountry()); 822 commands.add(command); 823 } 824 } 825 826 if (dto.isSaveSuburb()) { 827 String value = selection.get(TagDialog.TAG_ADDR_SUBURB); 828 if (value == null || (value != null && !value.equals(dto.getSuburb()))) { 829 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_SUBURB, dto.getSuburb()); 463 830 commands.add(command); 464 831 } … … 547 914 if (fileName.exists()) { 548 915 try ( 549 FileInputStream file = new FileInputStream(fileName);550 ObjectInputStream o = new ObjectInputStream(file);916 FileInputStream file = new FileInputStream(fileName); 917 ObjectInputStream o = new ObjectInputStream(file); 551 918 ) { 552 919 dto = (Dto) o.readObject(); 553 920 } 554 921 } else { 555 dto.setCity(selection.get(TagDialog.TAG_ADDR_CITY)); 556 dto.setCountry(selection.get(TagDialog.TAG_ADDR_COUNTRY)); 557 dto.setHousenumber(selection.get(TagDialog.TAG_ADDR_HOUSENUMBER)); 558 dto.setPostcode(selection.get(TagDialog.TAG_ADDR_POSTCODE)); 559 dto.setStreet(selection.get(TagDialog.TAG_ADDR_STREET)); 560 dto.setState(selection.get(TagDialog.TAG_ADDR_STATE)); 922 loadExistingValuesToDto(dto); 561 923 } 562 924 } catch (Exception ex) { 563 925 LOGGER.log(Level.SEVERE, ex.getMessage()); 564 926 fileName.delete(); 927 loadExistingValuesToDto(dto); 565 928 } 566 929 return dto; 930 } 931 932 private void loadExistingValuesToDto(Dto dto) { 933 dto.setCity(selection.get(TagDialog.TAG_ADDR_CITY)); 934 dto.setCountry(selection.get(TagDialog.TAG_ADDR_COUNTRY)); 935 dto.setSource(selection.get(TagDialog.TAG_SOURCE)); 936 dto.setHousenumber(selection.get(TagDialog.TAG_ADDR_HOUSENUMBER)); 937 dto.setPostcode(selection.get(TagDialog.TAG_ADDR_POSTCODE)); 938 dto.setStreet(selection.get(TagDialog.TAG_ADDR_STREET)); 939 dto.setState(selection.get(TagDialog.TAG_ADDR_STATE)); 940 dto.setSuburb(selection.get(TagDialog.TAG_ADDR_SUBURB)); 567 941 } 568 942 -
applications/editors/josm/plugins/HouseNumberTaggingTool/test
-
Property svn:ignore
set to
report
build
jacoco.exec
-
Property svn:ignore
set to
-
applications/editors/josm/plugins/HouseNumberTaggingTool/test/unit/org/openstreetmap/josm/plugins/housenumbertool/HouseNumberHelperTest.java
r35507 r35508 10 10 * Unit tests of {@link TagDialog}. 11 11 */ 12 public class TagDialogTest {12 public class HouseNumberHelperTest { 13 13 14 14 /** 15 * Unit test of {@link TagDialog#incrementHouseNumber}15 * Unit test of {@link HouseNumberHelper#incrementHouseNumber} 16 16 */ 17 17 @Test 18 18 public void testIncrementHouseNumber() { 19 assertEquals("2", TagDialog.incrementHouseNumber("1", 1));20 assertEquals("12", TagDialog.incrementHouseNumber("10", 2));21 assertEquals("2A", TagDialog.incrementHouseNumber("1A", 1));22 assertEquals("E2", TagDialog.incrementHouseNumber("E1", 1));23 //assertEquals("۲", TagDialog.incrementHouseNumber("۱", 1)); // FIXME: how to increment persian numbers ?24 assertEquals("2", TagDialog.incrementHouseNumber("۱", 1));25 assertNull( TagDialog.incrementHouseNumber(null, 1));19 assertEquals("2", HouseNumberHelper.incrementHouseNumber("1", 1)); 20 assertEquals("12", HouseNumberHelper.incrementHouseNumber("10", 2)); 21 assertEquals("2A", HouseNumberHelper.incrementHouseNumber("1A", 1)); 22 assertEquals("E2", HouseNumberHelper.incrementHouseNumber("E1", 1)); 23 //assertEquals("۲", HouseNumberHelper.incrementHouseNumber("۱", 1)); // FIXME: how to increment persian numbers ? 24 assertEquals("2", HouseNumberHelper.incrementHouseNumber("۱", 1)); 25 assertNull(HouseNumberHelper.incrementHouseNumber(null, 1)); 26 26 } 27 27 }
Note:
See TracChangeset
for help on using the changeset viewer.