Changeset 36060 in osm for applications
- Timestamp:
- 2023-02-27T16:08:37+01:00 (22 months ago)
- Location:
- applications/editors/josm/plugins/HouseNumberTaggingTool
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/Dto.java
r35508 r36060 5 5 6 6 /** 7 * An object for the current dialog settings 7 8 * @author Oliver Raupach 18.01.2012 8 9 */ -
applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/HouseNumberHelper.java
r35508 r36060 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.housenumbertool; 2 3 … … 4 5 import java.util.regex.Pattern; 5 6 6 public class HouseNumberHelper { 7 import org.openstreetmap.josm.tools.Logging; 7 8 8 static public String incrementHouseNumber(String number, int increment) { 9 /** 10 * A helper class for incrementing addr:housenumber 11 */ 12 public final class HouseNumberHelper { 13 private HouseNumberHelper() { 14 // Hide constructor 15 } 16 17 /** 18 * Increment a house number 19 * @param number The number to increment 20 * @param increment The amount to increment the number by 21 * @return The incremented number 22 */ 23 public static String incrementHouseNumber(String number, int increment) { 9 24 if (number != null) { 10 25 try { … … 16 31 return prefix + n + suffix; 17 32 } 18 } catch (NumberFormatException e) 19 // Do nothing33 } catch (NumberFormatException e) { 34 Logging.trace(e); 20 35 } 21 36 } -
applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/LaunchAction.java
r35581 r36060 15 15 import org.openstreetmap.josm.tools.Shortcut; 16 16 17 /** 18 * An action for opening the {@link TagDialog} editor 19 */ 17 20 public class LaunchAction extends JosmAction implements DataSelectionListener { 18 21 19 private OsmPrimitive selection = null; 22 private static final long serialVersionUID = -2017126466206457986L; 23 private OsmPrimitive selection; 20 24 21 private File pluginDir;25 private final File pluginDir; 22 26 23 27 /** … … 26 30 */ 27 31 public LaunchAction(File pluginDir) { 28 super( "HouseNumberTaggingTool",32 super(tr("HouseNumberTaggingTool"), 29 33 "home-icon32", 30 "Launches the HouseNumberTaggingTool dialog",34 tr("Launches the HouseNumberTaggingTool dialog"), 31 35 Shortcut.registerShortcut("edit:housenumbertaggingtool", tr("Data: {0}", "HouseNumberTaggingTool"), 32 36 KeyEvent.VK_K, Shortcut.DIRECT), … … 60 64 if (newSelection != null && newSelection.size() == 1) { 61 65 setEnabled(true); 62 selection =newSelection.iterator().next();66 selection = newSelection.iterator().next(); 63 67 } else { 64 68 setEnabled(false); -
applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/TagDialog.java
r35814 r36060 9 9 import java.awt.GridBagConstraints; 10 10 import java.awt.GridBagLayout; 11 import java.awt.Insets;12 11 import java.awt.event.ActionEvent; 12 import java.awt.event.ActionListener; 13 13 import java.awt.event.ItemEvent; 14 14 import java.awt.event.ItemListener; … … 16 16 import java.io.FileInputStream; 17 17 import java.io.FileOutputStream; 18 import java.io.IOException; 18 19 import java.io.ObjectInputStream; 19 20 import java.io.ObjectOutputStream; … … 24 25 import java.util.Set; 25 26 import java.util.TreeSet; 26 import java.util.logging.Level;27 import java.util.logging.Logger;28 27 29 28 import javax.swing.ButtonGroup; … … 48 47 import org.openstreetmap.josm.gui.tagging.ac.AutoCompComboBox; 49 48 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; 49 import org.openstreetmap.josm.gui.widgets.JosmComboBox; 50 import org.openstreetmap.josm.gui.widgets.JosmTextField; 51 import org.openstreetmap.josm.tools.GBC; 52 import org.openstreetmap.josm.tools.Logging; 50 53 51 54 /** 55 * The dialog to show users the tags that will be applied to an object 56 * 52 57 * @author Oliver Raupach 09.01.2012 53 58 * @author Victor Kropp 10.03.2012 54 59 */ 55 60 public class TagDialog extends ExtendedDialog { 61 private static final long serialVersionUID = -4781477945608720136L; 56 62 private static final String APPLY_CHANGES = tr("Apply Changes"); 57 63 private static final String TAG_STREET_OR_PLACE = tr("Use tag ''addr:street'' or ''addr:place''"); … … 70 76 private static final String[] BUILDING_STRINGS = { 71 77 "yes", "apartments", "chapel", "church", "commercial", "dormitory", "hotel", "house", "residential", "terrace", 72 "industrial", "retail", "warehouse", "cathedral", 78 "industrial", "retail", "warehouse", "cathedral", "civic", "hospital", "school", "train_station", "transportation", 73 79 "university", "public", "bridge", "bunker", "cabin", "construction", "farm_auxiliary", "garage", "garages", 74 80 "greenhouse", "hangar", "hut", "roof", "shed", "stable"}; 75 81 76 82 private static final int FPS_MIN = -10; 77 private static final int FPS_MAX = 10; 78 79 private static final Logger LOGGER = Logger.getLogger(TagDialog.class.getName()); 80 81 private File pluginDir; 83 private static final int FPS_MAX = 10; 84 85 private final File pluginDir; 82 86 private AutoCompletionManager acm; 83 private OsmPrimitive selection;87 private final OsmPrimitive selection; 84 88 85 89 private static final String TEMPLATE_DATA = "/template.data"; … … 87 91 private AutoCompComboBox<AutoCompletionItem> source; 88 92 private AutoCompComboBox<AutoCompletionItem> country; 89 private AutoCompComboBox<AutoCompletionItem> state ;93 private AutoCompComboBox<AutoCompletionItem> stateTag; 90 94 private AutoCompComboBox<AutoCompletionItem> suburb; 91 95 private AutoCompComboBox<AutoCompletionItem> city; 92 96 private AutoCompComboBox<AutoCompletionItem> postcode; 93 97 private AutoCompComboBox<AutoCompletionItem> street; 94 private JTextField hous number;98 private JTextField housenumber; 95 99 private JCheckBox buildingEnabled; 96 100 private JCheckBox sourceEnabled; … … 113 117 */ 114 118 public TagDialog(File pluginDir, OsmPrimitive selection) { 115 super(MainApplication.getMainFrame(), tr("House Number Editor"), new String[] { tr("OK"), tr("Cancel")}, true);119 super(MainApplication.getMainFrame(), tr("House Number Editor"), new String[] {tr("OK"), tr("Cancel")}, true); 116 120 this.pluginDir = pluginDir; 117 121 this.selection = selection; … … 132 136 133 137 SwingUtilities.invokeLater(() -> { 134 hous number.requestFocus();135 hous number.selectAll();138 housenumber.requestFocus(); 139 housenumber.selectAll(); 136 140 }); 137 141 } … … 143 147 144 148 JPanel editPanel = new JPanel(new GridBagLayout()); 145 GridBagConstraints c = new GridBagConstraints();146 149 147 150 JLabel labelNewValues = new JLabel(); … … 149 152 labelNewValues.setFont(newLabelFont); 150 153 labelNewValues.setText(tr("New values:")); 151 c.fill = GridBagConstraints.HORIZONTAL; 152 c.gridx = 3; 153 c.gridy = 0; 154 c.weightx = 0; 155 c.gridwidth = 1; 156 c.insets = new Insets(0, 5, 10, 5); 157 editPanel.add(labelNewValues, c); 154 editPanel.add(labelNewValues, GBC.std().grid(3, 0).insets(0, 5, 10, 5)); 158 155 159 156 JLabel labelExistingValues = new JLabel(); 160 157 labelExistingValues.setFont(newLabelFont); 161 158 labelExistingValues.setText(tr("Existing values:")); 162 c.fill = GridBagConstraints.HORIZONTAL; 163 c.gridx = 5; 164 c.gridy = 0; 165 c.weightx = 0; 166 c.gridwidth = 1; 167 c.insets = new Insets(0, 5, 10, 5); 168 editPanel.add(labelExistingValues, c); 159 editPanel.add(labelExistingValues, GBC.std().span(3).weight(0, 0).grid(5, 0).insets(0, 5, 10, 5)); 169 160 170 161 JButton getAllButton = new JButton("<<"); … … 172 163 getAllButton.setToolTipText(tr("Accept all existing values")); 173 164 getAllButton.addActionListener(actionEvent -> acceptAllExistingValues()); 174 GridBagConstraints buttonContstraints = new GridBagConstraints(); 175 buttonContstraints.fill = GridBagConstraints.NONE; 176 buttonContstraints.gridx = 6; 177 buttonContstraints.gridy = 0; 178 buttonContstraints.weightx = 0; 179 buttonContstraints.gridwidth = 1; 180 buttonContstraints.anchor = GridBagConstraints.EAST; 181 buttonContstraints.insets = new Insets(0, 5, 10, 5); 182 editPanel.add(getAllButton, buttonContstraints); 165 editPanel.add(getAllButton, GBC.eol().grid(7, 0).anchor(GridBagConstraints.EAST).insets(0, 5, 10, 5)); 166 167 GBC columnOne = GBC.std().span(3).insets(5, 5, 0, 5); 168 GBC columnTwo = GBC.std().span(1).weight(1, 0).fill(GBC.HORIZONTAL).insets(5, 5, 0, 5); 169 GBC columnThree = GBC.std().insets(5, 5, 0, 5); 170 GBC columnFour = GBC.eol().weight(1, 0).fill(GBC.HORIZONTAL).insets(5, 5, 0, 5); 183 171 184 172 // building 185 buildingEnabled = new JCheckBox(TAG_BUILDING); 186 buildingEnabled.setFocusable(false); 187 buildingEnabled.setSelected(dto.isSaveBuilding()); 188 buildingEnabled.setToolTipText(APPLY_CHANGES); 189 c.fill = GridBagConstraints.HORIZONTAL; 190 c.gridx = 0; 191 c.gridy = 1; 192 c.weightx = 0; 193 c.gridwidth = 3; 194 c.insets = new Insets(5, 5, 0, 5); 195 editPanel.add(buildingEnabled, c); 173 buildingEnabled = generateCheckbox(TAG_BUILDING, dto.isSaveBuilding()); 174 editPanel.add(buildingEnabled, columnOne); 196 175 197 176 Arrays.sort(BUILDING_STRINGS); 198 building = new J ComboBox<>(BUILDING_STRINGS);177 building = new JosmComboBox<>(BUILDING_STRINGS); 199 178 building.setSelectedItem(dto.getBuilding()); 200 179 building.setMaximumRowCount(50); 201 c.gridx = 3; 202 c.gridy = 1; 203 c.weightx = 1; 204 c.gridwidth = 1; 205 c.insets = new Insets(5, 5, 0, 5); 206 editPanel.add(building, c); 207 208 JButton getBuildingButton = new JButton("<"); 209 getBuildingButton.setPreferredSize(new Dimension(45, 24)); 210 getBuildingButton.setToolTipText(tr("Accept existing value")); 211 getBuildingButton.addActionListener(actionEvent -> building.setSelectedItem(selection.get(TAG_BUILDING))); 212 c.fill = GridBagConstraints.NONE; 213 c.gridx = 4; 214 c.gridy = 1; 215 c.weightx = 0; 216 c.gridwidth = 1; 217 c.insets = new Insets(5, 5, 0, 5); 218 editPanel.add(getBuildingButton, c); 219 220 JTextField existingBuilding = new JTextField(); 221 existingBuilding.setText(selection.get(TAG_BUILDING)); 222 existingBuilding.setPreferredSize(new Dimension(200, 24)); 223 existingBuilding.setEditable(false); 224 c.fill = GridBagConstraints.HORIZONTAL; 225 c.gridx = 5; 226 c.gridy = 1; 227 c.weightx = 1; 228 c.gridwidth = 2; 229 c.insets = new Insets(5, 5, 0, 5); 230 editPanel.add(existingBuilding, c); 180 editPanel.add(building, columnTwo); 181 182 editPanel.add(generateAcceptButton(actionEvent -> building.setSelectedItem(selection.get(TAG_BUILDING))), columnThree); 183 editPanel.add(generateTextField(selection.get(TAG_BUILDING)), columnFour); 231 184 232 185 // source 233 sourceEnabled = new JCheckBox(TAG_SOURCE); 234 sourceEnabled.setFocusable(false); 235 sourceEnabled.setSelected(dto.isSaveBuilding()); 236 sourceEnabled.setToolTipText(APPLY_CHANGES); 237 c.fill = GridBagConstraints.HORIZONTAL; 238 c.gridx = 0; 239 c.gridy = 2; 240 c.weightx = 0; 241 c.gridwidth = 3; 242 c.insets = new Insets(5, 5, 0, 5); 243 editPanel.add(sourceEnabled, c); 244 245 source = new AutoCompComboBox<>(); 246 source.getModel().addAllElements(acm.getTagValues(TAG_SOURCE)); 247 source.setPreferredSize(new Dimension(200, 24)); 248 source.setEditable(true); 249 source.setSelectedItem(dto.getSource()); 250 c.gridx = 3; 251 c.gridy = 2; 252 c.weightx = 1; 253 c.gridwidth = 1; 254 c.insets = new Insets(5, 5, 0, 5); 255 editPanel.add(source, c); 256 257 JButton getSourceButton = new JButton("<"); 258 getSourceButton.setPreferredSize(new Dimension(45, 24)); 259 getSourceButton.setToolTipText(tr("Accept existing value")); 260 getSourceButton.addActionListener(actionEvent -> source.setSelectedItem(selection.get(TAG_SOURCE))); 261 c.fill = GridBagConstraints.NONE; 262 c.gridx = 4; 263 c.gridy = 2; 264 c.weightx = 0; 265 c.gridwidth = 1; 266 c.insets = new Insets(5, 5, 0, 5); 267 editPanel.add(getSourceButton, c); 268 269 JTextField existingSource = new JTextField(); 270 existingSource.setText(selection.get(TAG_SOURCE)); 271 existingSource.setPreferredSize(new Dimension(200, 24)); 272 existingSource.setEditable(false); 273 c.fill = GridBagConstraints.HORIZONTAL; 274 c.gridx = 5; 275 c.gridy = 2; 276 c.weightx = 1; 277 c.gridwidth = 2; 278 c.insets = new Insets(5, 5, 0, 5); 279 editPanel.add(existingSource, c); 186 sourceEnabled = generateCheckbox(TAG_SOURCE, dto.isSaveSource()); 187 editPanel.add(sourceEnabled, columnOne); 188 189 source = generateAutoCompTextField(acm.getTagValues(TAG_SOURCE), dto.getSource()); 190 editPanel.add(source, columnTwo); 191 192 editPanel.add(generateAcceptButton(actionEvent -> source.setSelectedItem(selection.get(TAG_SOURCE))), columnThree); 193 editPanel.add(generateTextField(selection.get(TAG_SOURCE)), columnFour); 280 194 281 195 // country 282 countryEnabled = new JCheckBox(TAG_ADDR_COUNTRY); 283 countryEnabled.setFocusable(false); 284 countryEnabled.setSelected(dto.isSaveCountry()); 285 countryEnabled.setToolTipText(APPLY_CHANGES); 286 c = new GridBagConstraints(); 287 c.fill = GridBagConstraints.HORIZONTAL; 288 c.gridx = 0; 289 c.gridy = 3; 290 c.weightx = 0; 291 c.gridwidth = 3; 292 c.insets = new Insets(5, 5, 0, 5); 293 editPanel.add(countryEnabled, c); 294 295 country = new AutoCompComboBox<>(); 296 country.getModel().addAllElements(acm.getTagValues(TAG_ADDR_COUNTRY)); 297 country.setPreferredSize(new Dimension(200, 24)); 298 country.setEditable(true); 299 country.setSelectedItem(dto.getCountry()); 300 c.fill = GridBagConstraints.HORIZONTAL; 301 c.gridx = 3; 302 c.gridy = 3; 303 c.weightx = 1; 304 c.gridwidth = 1; 305 c.insets = new Insets(5, 5, 0, 5); 306 editPanel.add(country, c); 307 308 JButton getCountryButton = new JButton("<"); 309 getCountryButton.setPreferredSize(new Dimension(45, 24)); 310 getCountryButton.setToolTipText(tr("Accept existing value")); 311 getCountryButton.addActionListener(actionEvent -> country.setSelectedItem(selection.get(TAG_ADDR_COUNTRY))); 312 c.fill = GridBagConstraints.NONE; 313 c.gridx = 4; 314 c.gridy = 3; 315 c.weightx = 0; 316 c.gridwidth = 1; 317 c.insets = new Insets(5, 5, 0, 5); 318 editPanel.add(getCountryButton, c); 319 320 JTextField existingCountry = new JTextField(); 321 existingCountry.setText(selection.get(TAG_ADDR_COUNTRY)); 322 existingCountry.setPreferredSize(new Dimension(200, 24)); 323 existingCountry.setEditable(false); 324 c.fill = GridBagConstraints.HORIZONTAL; 325 c.gridx = 5; 326 c.gridy = 3; 327 c.weightx = 1; 328 c.gridwidth = 2; 329 c.insets = new Insets(5, 5, 0, 5); 330 editPanel.add(existingCountry, c); 196 countryEnabled = generateCheckbox(TAG_ADDR_COUNTRY, dto.isSaveCountry()); 197 editPanel.add(countryEnabled, columnOne); 198 199 country = generateAutoCompTextField(acm.getTagValues(TAG_ADDR_COUNTRY), dto.getCountry()); 200 editPanel.add(country, columnTwo); 201 202 editPanel.add(generateAcceptButton(actionEvent -> country.setSelectedItem(selection.get(TAG_ADDR_COUNTRY))), columnThree); 203 editPanel.add(generateTextField(selection.get(TAG_ADDR_COUNTRY)), columnFour); 331 204 332 205 // state 333 stateEnabled = new JCheckBox(TAG_ADDR_STATE); 334 stateEnabled.setFocusable(false); 335 stateEnabled.setSelected(dto.isSaveState()); 336 stateEnabled.setToolTipText(APPLY_CHANGES); 337 c.fill = GridBagConstraints.HORIZONTAL; 338 c.gridx = 0; 339 c.gridy = 4; 340 c.weightx = 0; 341 c.gridwidth = 3; 342 c.insets = new Insets(5, 5, 0, 5); 343 editPanel.add(stateEnabled, c); 344 345 state = new AutoCompComboBox<>(); 346 state.getModel().addAllElements(acm.getTagValues(TAG_ADDR_STATE)); 347 state.setPreferredSize(new Dimension(200, 24)); 348 state.setEditable(true); 349 state.setSelectedItem(dto.getState()); 350 c.fill = GridBagConstraints.HORIZONTAL; 351 c.gridx = 3; 352 c.gridy = 4; 353 c.weightx = 1; 354 c.gridwidth = 1; 355 c.insets = new Insets(5, 5, 0, 5); 356 editPanel.add(state, c); 357 358 JButton getStateButton = new JButton("<"); 359 getStateButton.setPreferredSize(new Dimension(45, 24)); 360 getStateButton.setToolTipText(tr("Accept existing value")); 361 getStateButton.addActionListener(actionEvent -> state.setSelectedItem(selection.get(TAG_ADDR_STATE))); 362 c.fill = GridBagConstraints.NONE; 363 c.gridx = 4; 364 c.gridy = 4; 365 c.weightx = 0; 366 c.gridwidth = 1; 367 c.insets = new Insets(5, 5, 0, 5); 368 editPanel.add(getStateButton, c); 369 370 JTextField existingState= new JTextField(); 371 existingState.setText(selection.get(TAG_ADDR_STATE)); 372 existingState.setPreferredSize(new Dimension(200, 24)); 373 existingState.setEditable(false); 374 c.fill = GridBagConstraints.HORIZONTAL; 375 c.gridx = 5; 376 c.gridy = 4; 377 c.weightx = 1; 378 c.gridwidth = 2; 379 c.insets = new Insets(5, 5, 0, 5); 380 editPanel.add(existingState, c); 206 stateEnabled = generateCheckbox(TAG_ADDR_STATE, dto.isSaveState()); 207 editPanel.add(stateEnabled, columnOne); 208 209 stateTag = generateAutoCompTextField(acm.getTagValues(TAG_ADDR_STATE), dto.getState()); 210 editPanel.add(stateTag, columnTwo); 211 212 editPanel.add(generateAcceptButton(actionEvent -> stateTag.setSelectedItem(selection.get(TAG_ADDR_STATE))), columnThree); 213 editPanel.add(generateTextField(selection.get(TAG_ADDR_STATE)), columnFour); 381 214 382 215 // suburb 383 suburbEnabled = new JCheckBox(TAG_ADDR_SUBURB); 384 suburbEnabled.setFocusable(false); 385 suburbEnabled.setSelected(dto.isSaveSuburb()); 386 suburbEnabled.setToolTipText(APPLY_CHANGES); 387 c.fill = GridBagConstraints.HORIZONTAL; 388 c.gridx = 0; 389 c.gridy = 5; 390 c.weightx = 0; 391 c.gridwidth = 3; 392 c.insets = new Insets(5, 5, 0, 5); 393 editPanel.add(suburbEnabled, c); 394 395 suburb = new AutoCompComboBox<>(); 396 suburb.getModel().addAllElements(acm.getTagValues(TAG_ADDR_SUBURB)); 397 suburb.setPreferredSize(new Dimension(200, 24)); 398 suburb.setEditable(true); 399 suburb.setSelectedItem(dto.getSuburb()); 400 c.fill = GridBagConstraints.HORIZONTAL; 401 c.gridx = 3; 402 c.gridy = 5; 403 c.weightx = 1; 404 c.gridwidth = 1; 405 c.insets = new Insets(5, 5, 0, 5); 406 editPanel.add(suburb, c); 407 408 JButton getSuburbButton = new JButton("<"); 409 getSuburbButton.setPreferredSize(new Dimension(45, 24)); 410 getSuburbButton.setToolTipText(tr("Accept existing value")); 411 getSuburbButton.addActionListener(actionEvent -> suburb.setSelectedItem(selection.get(TAG_ADDR_SUBURB))); 412 c.fill = GridBagConstraints.NONE; 413 c.gridx = 4; 414 c.gridy = 5; 415 c.weightx = 0; 416 c.gridwidth = 1; 417 c.insets = new Insets(5, 5, 0, 5); 418 editPanel.add(getSuburbButton, c); 419 420 JTextField existingSuburb = new JTextField(); 421 existingSuburb.setText(selection.get(TAG_ADDR_SUBURB)); 422 existingSuburb.setPreferredSize(new Dimension(200, 24)); 423 existingSuburb.setEditable(false); 424 c.fill = GridBagConstraints.HORIZONTAL; 425 c.gridx = 5; 426 c.gridy = 5; 427 c.weightx = 1; 428 c.gridwidth = 2; 429 c.insets = new Insets(5, 5, 0, 5); 430 editPanel.add(existingSuburb, c); 216 suburbEnabled = generateCheckbox(TAG_ADDR_SUBURB, dto.isSaveSuburb()); 217 editPanel.add(suburbEnabled, columnOne); 218 219 suburb = generateAutoCompTextField(acm.getTagValues(TAG_ADDR_SUBURB), dto.getSuburb()); 220 editPanel.add(suburb, columnTwo); 221 222 editPanel.add(generateAcceptButton(actionEvent -> suburb.setSelectedItem(selection.get(TAG_ADDR_SUBURB))), columnThree); 223 editPanel.add(generateTextField(selection.get(TAG_ADDR_SUBURB)), columnFour); 431 224 432 225 // city 433 cityEnabled = new JCheckBox(TAG_ADDR_CITY); 434 cityEnabled.setFocusable(false); 435 cityEnabled.setSelected(dto.isSaveCity()); 436 cityEnabled.setToolTipText(APPLY_CHANGES); 437 c.fill = GridBagConstraints.HORIZONTAL; 438 c.gridx = 0; 439 c.gridy = 6; 440 c.weightx = 0; 441 c.gridwidth = 3; 442 c.insets = new Insets(5, 5, 0, 5); 443 editPanel.add(cityEnabled, c); 444 445 city = new AutoCompComboBox<>(); 446 city.getModel().addAllElements(acm.getTagValues(TAG_ADDR_CITY)); 447 city.setPreferredSize(new Dimension(200, 24)); 448 city.setEditable(true); 449 city.setSelectedItem(dto.getCity()); 450 c.fill = GridBagConstraints.HORIZONTAL; 451 c.gridx = 3; 452 c.gridy = 6; 453 c.weightx = 1; 454 c.gridwidth = 1; 455 c.insets = new Insets(5, 5, 0, 5); 456 editPanel.add(city, c); 457 458 JButton getCityButton = new JButton("<"); 459 getCityButton.setPreferredSize(new Dimension(45, 24)); 460 getCityButton.setToolTipText(tr("Accept existing value")); 461 getCityButton.addActionListener(actionEvent -> city.setSelectedItem(selection.get(TAG_ADDR_CITY))); 462 c.fill = GridBagConstraints.NONE; 463 c.gridx = 4; 464 c.gridy = 6; 465 c.weightx = 0; 466 c.gridwidth = 1; 467 c.insets = new Insets(5, 5, 0, 5); 468 editPanel.add(getCityButton, c); 469 470 JTextField existingCity = new JTextField(); 471 existingCity.setText(selection.get(TAG_ADDR_CITY)); 472 existingCity.setPreferredSize(new Dimension(200, 24)); 473 existingCity.setEditable(false); 474 c.fill = GridBagConstraints.HORIZONTAL; 475 c.gridx = 5; 476 c.gridy = 6; 477 c.weightx = 1; 478 c.gridwidth = 2; 479 c.insets = new Insets(5, 5, 0, 5); 480 editPanel.add(existingCity, c); 226 cityEnabled = generateCheckbox(TAG_ADDR_CITY, dto.isSaveCity()); 227 editPanel.add(cityEnabled, columnOne); 228 229 city = generateAutoCompTextField(acm.getTagValues(TAG_ADDR_CITY), dto.getCity()); 230 editPanel.add(city, columnTwo); 231 232 editPanel.add(generateAcceptButton(actionEvent -> city.setSelectedItem(selection.get(TAG_ADDR_CITY))), columnThree); 233 editPanel.add(generateTextField(selection.get(TAG_ADDR_CITY)), columnFour); 481 234 482 235 // postcode 483 zipEnabled = new JCheckBox(TAG_ADDR_POSTCODE); 484 zipEnabled.setFocusable(false); 485 zipEnabled.setSelected(dto.isSavePostcode()); 486 zipEnabled.setToolTipText(APPLY_CHANGES); 487 c.fill = GridBagConstraints.HORIZONTAL; 488 c.gridx = 0; 489 c.gridy = 7; 490 c.weightx = 0; 491 c.gridwidth = 3; 492 c.insets = new Insets(5, 5, 0, 5); 493 editPanel.add(zipEnabled, c); 494 495 postcode = new AutoCompComboBox<>(); 496 postcode.getModel().addAllElements(acm.getTagValues(TAG_ADDR_POSTCODE)); 497 postcode.setPreferredSize(new Dimension(200, 24)); 498 postcode.setEditable(true); 499 postcode.setSelectedItem(dto.getPostcode()); 500 c.fill = GridBagConstraints.HORIZONTAL; 501 c.gridx = 3; 502 c.gridy = 7; 503 c.weightx = 1; 504 c.gridwidth = 1; 505 c.insets = new Insets(5, 5, 0, 5); 506 editPanel.add(postcode, c); 507 508 JButton getPostcodeButton = new JButton("<"); 509 getPostcodeButton.setPreferredSize(new Dimension(45, 24)); 510 getPostcodeButton.setToolTipText(tr("Accept existing value")); 511 getPostcodeButton.addActionListener(actionEvent -> postcode.setSelectedItem(selection.get(TAG_ADDR_POSTCODE))); 512 c.fill = GridBagConstraints.NONE; 513 c.gridx = 4; 514 c.gridy = 7; 515 c.weightx = 0; 516 c.gridwidth = 1; 517 c.insets = new Insets(5, 5, 0, 5); 518 editPanel.add(getPostcodeButton, c); 519 520 JTextField existingPostcode = new JTextField(); 521 existingPostcode.setText(selection.get(TAG_ADDR_POSTCODE)); 522 existingPostcode.setPreferredSize(new Dimension(200, 24)); 523 existingPostcode.setEditable(false); 524 c.fill = GridBagConstraints.HORIZONTAL; 525 c.gridx = 5; 526 c.gridy = 7; 527 c.weightx = 1; 528 c.gridwidth = 2; 529 c.insets = new Insets(5, 5, 0, 5); 530 editPanel.add(existingPostcode, c); 236 zipEnabled = generateCheckbox(TAG_ADDR_POSTCODE, dto.isSavePostcode()); 237 editPanel.add(zipEnabled, columnOne); 238 239 postcode = generateAutoCompTextField(acm.getTagValues(TAG_ADDR_POSTCODE), dto.getPostcode()); 240 editPanel.add(postcode, columnTwo); 241 242 editPanel.add(generateAcceptButton(actionEvent -> postcode.setSelectedItem(selection.get(TAG_ADDR_POSTCODE))), columnThree); 243 editPanel.add(generateTextField(selection.get(TAG_ADDR_POSTCODE)), columnFour); 531 244 532 245 // street 533 streetEnabled = new JCheckBox(); 534 streetEnabled.setFocusable(false); 535 streetEnabled.setSelected(dto.isSaveStreet()); 536 streetEnabled.setToolTipText(APPLY_CHANGES); 537 c.fill = GridBagConstraints.HORIZONTAL; 538 c.gridx = 0; 539 c.gridy = 8; 540 c.weightx = 0; 541 c.gridwidth = 1; 542 c.insets = new Insets(5, 5, 0, 5); 543 editPanel.add(streetEnabled, c); 246 streetEnabled = generateCheckbox(null, dto.isSaveStreet()); 247 editPanel.add(streetEnabled, GBC.std().insets(5, 5, 0, 5)); 544 248 545 249 streetRadio = new JRadioButton(TAG_ADDR_STREET); … … 547 251 streetRadio.setSelected(dto.isTagStreet()); 548 252 streetRadio.addItemListener(new RadioChangeListener()); 549 c.fill = GridBagConstraints.HORIZONTAL; 550 c.gridx = 1; 551 c.gridy = 8; 552 c.weightx = 0; 553 c.gridwidth = 1; 554 c.insets = new Insets(5, 5, 0, 5); 555 editPanel.add(streetRadio, c); 253 editPanel.add(streetRadio, GBC.std().weight(0, 0).insets(5, 5, 0, 5)); 556 254 557 255 placeRadio = new JRadioButton("addr:place"); … … 559 257 placeRadio.setSelected(!dto.isTagStreet()); 560 258 placeRadio.addItemListener(new RadioChangeListener()); 561 c.fill = GridBagConstraints.HORIZONTAL; 562 c.gridx = 2; 563 c.gridy = 8; 564 c.weightx = 0; 565 c.gridwidth = 1; 566 c.insets = new Insets(5, 5, 0, 5); 567 editPanel.add(placeRadio, c); 259 editPanel.add(placeRadio, GBC.std().insets(5, 5, 0, 5)); 568 260 569 261 ButtonGroup g = new ButtonGroup(); … … 571 263 g.add(placeRadio); 572 264 573 street = new AutoCompComboBox<>();574 265 if (dto.isTagStreet()) { 575 street .getModel().addAllElements(getPossibleStreets());266 street = generateAutoCompTextField(getPossibleStreets(), dto.getStreet()); 576 267 } else { 577 street.getModel().addAllElements(acm.getTagValues(TAG_ADDR_PLACE)); 578 } 579 street.setPreferredSize(new Dimension(200, 24)); 580 street.setEditable(true); 581 street.setSelectedItem(dto.getStreet()); 582 c.fill = GridBagConstraints.HORIZONTAL; 583 c.gridx = 3; 584 c.gridy = 8; 585 c.weightx = 1; 586 c.gridwidth = 1; 587 c.insets = new Insets(5, 5, 0, 5); 588 editPanel.add(street, c); 589 590 JButton getStreetButton = new JButton("<"); 591 getStreetButton.setPreferredSize(new Dimension(45, 24)); 592 getStreetButton.setToolTipText(tr("Accept existing value")); 593 getStreetButton.addActionListener(actionEvent -> updateStreetOrPlaceValues()); 594 c.fill = GridBagConstraints.NONE; 595 c.gridx = 4; 596 c.gridy = 8; 597 c.weightx = 0; 598 c.gridwidth = 1; 599 c.insets = new Insets(5, 5, 0, 5); 600 editPanel.add(getStreetButton, c); 601 602 JTextField streetOrPlace = new JTextField(); 603 streetOrPlace.setText(getStreetOrPlaceTag()); 268 street = generateAutoCompTextField(acm.getTagValues(TAG_ADDR_PLACE), dto.getStreet()); 269 } 270 editPanel.add(street, columnTwo); 271 272 editPanel.add(generateAcceptButton(actionEvent -> updateStreetOrPlaceValues()), columnThree); 273 274 JTextField streetOrPlace = generateTextField(getStreetOrPlaceTag()); 604 275 streetOrPlace.setPreferredSize(new Dimension(50, 24)); 605 streetOrPlace.setEditable(false); 606 c.fill = GridBagConstraints.HORIZONTAL; 607 c.gridx = 5; 608 c.gridy = 8; 609 c.weightx = 0; 610 c.gridwidth = 1; 611 c.insets = new Insets(5, 5, 0, 5); 612 editPanel.add(streetOrPlace, c); 613 614 JTextField existingStreet = new JTextField(); 615 existingStreet.setText(getStreetOrPlaceValue()); 276 editPanel.add(streetOrPlace, GBC.std().weight(0, 0).fill(GridBagConstraints.HORIZONTAL).insets(5, 5, 0, 5)); 277 278 JTextField existingStreet = generateTextField(getStreetOrPlaceValue()); 616 279 existingStreet.setPreferredSize(new Dimension(100, 24)); 617 existingStreet.setEditable(false); 618 c.fill = GridBagConstraints.HORIZONTAL; 619 c.gridx = 6; 620 c.gridy = 8; 621 c.weightx = 1; 622 c.gridwidth = 1; 623 c.insets = new Insets(5, 5, 0, 5); 624 editPanel.add(existingStreet, c); 625 626 280 editPanel.add(existingStreet, GBC.eol().weight(1, 0).insets(5, 5, 0, 5).fill(GridBagConstraints.HORIZONTAL)); 627 281 // housenumber 628 housenumberEnabled = new JCheckBox(TAG_ADDR_HOUSENUMBER); 629 housenumberEnabled.setFocusable(false); 630 housenumberEnabled.setSelected(dto.isSaveHousenumber()); 631 housenumberEnabled.setToolTipText(APPLY_CHANGES); 632 c.fill = GridBagConstraints.HORIZONTAL; 633 c.gridx = 0; 634 c.gridy = 9; 635 c.weightx = 0; 636 c.gridwidth = 3; 637 c.insets = new Insets(5, 5, 0, 5); 638 editPanel.add(housenumberEnabled, c); 639 640 housnumber = new JTextField(); 641 housnumber.setPreferredSize(new Dimension(200, 24)); 642 643 String number = HouseNumberHelper.incrementHouseNumber(dto.getHousenumber(), dto.getHousenumberChangeValue()); 644 if (number != null) { 645 housnumber.setText(number); 646 } 647 648 c.fill = GridBagConstraints.HORIZONTAL; 649 c.gridx = 3; 650 c.gridy = 9; 651 c.weightx = 1; 652 c.gridwidth = 1; 653 c.insets = new Insets(5, 5, 0, 5); 654 editPanel.add(housnumber, c); 655 656 JButton getHousenumberButton = new JButton("<"); 657 getHousenumberButton.setPreferredSize(new Dimension(45, 24)); 658 getHousenumberButton.setToolTipText(tr("Accept existing value")); 659 getHousenumberButton.addActionListener(actionEvent -> housnumber.setText(selection.get(TAG_ADDR_HOUSENUMBER))); 660 c.fill = GridBagConstraints.NONE; 661 c.gridx = 4; 662 c.gridy = 9; 663 c.weightx = 0; 664 c.gridwidth = 1; 665 c.insets = new Insets(5, 5, 0, 5); 666 editPanel.add(getHousenumberButton, c); 667 668 JTextField existingHousenumber = new JTextField(); 669 existingHousenumber.setText(selection.get(TAG_ADDR_HOUSENUMBER)); 670 existingHousenumber.setPreferredSize(new Dimension(200, 24)); 671 existingHousenumber.setEditable(false); 672 c.fill = GridBagConstraints.HORIZONTAL; 673 c.gridx = 5; 674 c.gridy = 9; 675 c.weightx = 1; 676 c.gridwidth = 2; 677 c.insets = new Insets(5, 5, 0, 5); 678 editPanel.add(existingHousenumber, c); 282 housenumberEnabled = generateCheckbox(TAG_ADDR_HOUSENUMBER, dto.isSaveHousenumber()); 283 editPanel.add(housenumberEnabled, columnOne); 284 285 housenumber = generateTextField(HouseNumberHelper.incrementHouseNumber(dto.getHousenumber(), dto.getHousenumberChangeValue())); 286 housenumber.setEditable(true); 287 288 editPanel.add(housenumber, columnTwo); 289 290 editPanel.add(generateAcceptButton(actionEvent -> housenumber.setText(selection.get(TAG_ADDR_HOUSENUMBER))), columnThree); 291 editPanel.add(generateTextField(selection.get(TAG_ADDR_HOUSENUMBER)), columnFour); 679 292 680 293 // increment 681 294 JLabel seqLabel = new JLabel(tr("House number increment:")); 682 c.fill = GridBagConstraints.HORIZONTAL; 683 c.gridx = 0; 684 c.gridy = 10; 685 c.weightx = 0; 686 c.gridwidth = 3; 687 c.insets = new Insets(5, 5, 0, 5); 688 editPanel.add(seqLabel, c); 295 editPanel.add(seqLabel, columnOne); 689 296 690 297 housenumberChangeSequence = new JSlider(JSlider.HORIZONTAL, FPS_MIN, FPS_MAX, dto.getHousenumberChangeValue()); … … 694 301 housenumberChangeSequence.setPaintLabels(true); 695 302 housenumberChangeSequence.setSnapToTicks(true); 696 c.gridx = 3; 697 c.gridy = 10; 698 c.weightx = 1; 699 c.gridwidth = 4; 700 c.insets = new Insets(20, 5, 10, 5); 701 editPanel.add(housenumberChangeSequence, c); 303 editPanel.add(housenumberChangeSequence, GBC.eol().weight(1, 0).insets(20, 5, 10, 5).fill(GridBagConstraints.HORIZONTAL)); 702 304 703 305 return editPanel; 306 } 307 308 /** 309 * Generate a checkbox for applying changes 310 * @param text The text to show 311 * @param enabled Whether or not the checkbox is enabled 312 * @return The checkbox to add 313 */ 314 private static JCheckBox generateCheckbox(String text, boolean enabled) { 315 JCheckBox checkBox = new JCheckBox(text, enabled); 316 checkBox.setFocusable(false); 317 checkBox.setToolTipText(APPLY_CHANGES); 318 return checkBox; 319 } 320 321 /** 322 * Generate an accept button 323 * @param listener The listener to call when the user "accepts" a value 324 * @return The button to add 325 */ 326 private static JButton generateAcceptButton(ActionListener listener) { 327 JButton button = new JButton("<"); 328 button.setPreferredSize(new Dimension(45, 24)); 329 button.setToolTipText(tr("Accept existing value")); 330 button.addActionListener(listener); 331 return button; 332 } 333 334 private static AutoCompComboBox<AutoCompletionItem> generateAutoCompTextField(Collection<AutoCompletionItem> tagValues, String selected) { 335 AutoCompComboBox<AutoCompletionItem> comboBox = new AutoCompComboBox<>(); 336 comboBox.getModel().addAllElements(tagValues); 337 comboBox.setPreferredSize(new Dimension(200, 24)); 338 comboBox.setEditable(true); 339 comboBox.setSelectedItem(selected); 340 return comboBox; 341 } 342 343 /** 344 * Generate a non-editable text field 345 * @param startingText The text to show 346 * @return The text field (200x24) 347 */ 348 private static JosmTextField generateTextField(String startingText) { 349 JosmTextField textField = new JosmTextField(); 350 textField.setText(startingText); 351 textField.setPreferredSize(new Dimension(200, 24)); 352 textField.setEditable(false); 353 return textField; 704 354 } 705 355 … … 709 359 source.setSelectedItem(selection.get(TAG_SOURCE)); 710 360 country.setSelectedItem(selection.get(TAG_ADDR_COUNTRY)); 711 state .setSelectedItem(selection.get(TAG_ADDR_STATE));361 stateTag.setSelectedItem(selection.get(TAG_ADDR_STATE)); 712 362 suburb.setSelectedItem(selection.get(TAG_ADDR_SUBURB)); 713 363 city.setSelectedItem(selection.get(TAG_ADDR_CITY)); 714 364 postcode.setSelectedItem(selection.get(TAG_ADDR_POSTCODE)); 715 hous number.setText(selection.get(TAG_ADDR_HOUSENUMBER));365 housenumber.setText(selection.get(TAG_ADDR_HOUSENUMBER)); 716 366 } 717 367 … … 720 370 placeRadio.setSelected(true); 721 371 street.setSelectedItem(selection.get(TAG_ADDR_PLACE)); 722 } else {372 } else { 723 373 streetRadio.setSelected(true); 724 374 street.setSelectedItem(selection.get(TAG_ADDR_STREET)); … … 765 415 dto.setCity(getAutoCompletingComboBoxValue(city)); 766 416 dto.setCountry(getAutoCompletingComboBoxValue(country)); 767 dto.setHousenumber(hous number.getText());417 dto.setHousenumber(housenumber.getText()); 768 418 dto.setPostcode(getAutoCompletingComboBoxValue(postcode)); 769 419 dto.setStreet(getAutoCompletingComboBoxValue(street)); 770 dto.setState(getAutoCompletingComboBoxValue(state ));420 dto.setState(getAutoCompletingComboBoxValue(stateTag)); 771 421 dto.setSuburb(getAutoCompletingComboBoxValue(suburb)); 772 422 dto.setHousenumberChangeValue(housenumberChangeSequence.getValue()); … … 778 428 } 779 429 780 private String getAutoCompletingComboBoxValue(AutoCompComboBox<AutoCompletionItem> box) {430 private static String getAutoCompletingComboBoxValue(AutoCompComboBox<AutoCompletionItem> box) { 781 431 Object item = box.getSelectedItem(); 782 432 if (item != null) { … … 794 444 795 445 protected void saveDto(Dto dto) { 796 File path = pluginDir;797 446 File fileName = new File(pluginDir + TagDialog.TEMPLATE_DATA); 798 447 799 448 try { 800 path.mkdirs(); 801 try ( 802 FileOutputStream file = new FileOutputStream(fileName); 803 ObjectOutputStream o = new ObjectOutputStream(file) 804 ) { 805 o.writeObject(dto); 806 } 807 } catch (Exception ex) { 808 LOGGER.log(Level.SEVERE, ex.getMessage()); 809 fileName.delete(); 449 if (pluginDir.mkdirs()) { 450 try ( 451 FileOutputStream file = new FileOutputStream(fileName); 452 ObjectOutputStream o = new ObjectOutputStream(file) 453 ) { 454 o.writeObject(dto); 455 } 456 } 457 } catch (IOException ex) { 458 Logging.error(ex); 459 if (!fileName.delete()) { 460 Logging.trace("TagDialog: {0} not deleted", fileName); 461 } 810 462 } 811 463 } … … 816 468 if (dto.isSaveBuilding()) { 817 469 String value = selection.get(TagDialog.TAG_BUILDING); 818 if (value == null || (value != null && !value.equals(dto.getBuilding()))) {470 if (value == null || !value.equals(dto.getBuilding())) { 819 471 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_BUILDING, dto.getBuilding()); 820 472 commands.add(command); … … 824 476 if (dto.isSaveSource()) { 825 477 String value = selection.get(TagDialog.TAG_SOURCE); 826 if (value == null || (value != null && !value.equals(dto.getSource()))) {478 if (value == null || !value.equals(dto.getSource())) { 827 479 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_SOURCE, dto.getSource()); 828 480 commands.add(command); … … 832 484 if (dto.isSaveCity()) { 833 485 String value = selection.get(TagDialog.TAG_ADDR_CITY); 834 if (value == null || (value != null && !value.equals(dto.getCity()))) {486 if (value == null || !value.equals(dto.getCity())) { 835 487 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_CITY, dto.getCity()); 836 488 commands.add(command); … … 838 490 } 839 491 840 if (dto.isSaveCountry()) 492 if (dto.isSaveCountry()) { 841 493 String value = selection.get(TagDialog.TAG_ADDR_COUNTRY); 842 if (value == null || (value != null && !value.equals(dto.getCountry()))) {494 if (value == null || !value.equals(dto.getCountry())) { 843 495 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_COUNTRY, dto.getCountry()); 844 496 commands.add(command); … … 846 498 } 847 499 848 if (dto.isSaveSuburb()) 500 if (dto.isSaveSuburb()) { 849 501 String value = selection.get(TagDialog.TAG_ADDR_SUBURB); 850 if (value == null || (value != null && !value.equals(dto.getSuburb()))) {502 if (value == null || !value.equals(dto.getSuburb())) { 851 503 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_SUBURB, dto.getSuburb()); 852 504 commands.add(command); … … 854 506 } 855 507 856 if (dto.isSaveHousenumber()) 508 if (dto.isSaveHousenumber()) { 857 509 String value = selection.get(TagDialog.TAG_ADDR_HOUSENUMBER); 858 if (value == null || (value != null && !value.equals(dto.getHousenumber()))) {510 if (value == null || !value.equals(dto.getHousenumber())) { 859 511 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_HOUSENUMBER, dto.getHousenumber()); 860 512 commands.add(command); … … 864 516 if (dto.isSavePostcode()) { 865 517 String value = selection.get(TagDialog.TAG_ADDR_POSTCODE); 866 if (value == null || (value != null && !value.equals(dto.getPostcode()))) {518 if (value == null || !value.equals(dto.getPostcode())) { 867 519 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_POSTCODE, dto.getPostcode()); 868 520 commands.add(command); … … 873 525 if (dto.isTagStreet()) { 874 526 String value = selection.get(TagDialog.TAG_ADDR_STREET); 875 if (value == null || (value != null && !value.equals(dto.getStreet()))) {527 if (value == null || !value.equals(dto.getStreet())) { 876 528 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STREET, dto.getStreet()); 877 529 commands.add(command); … … 885 537 } else { 886 538 String value = selection.get(TagDialog.TAG_ADDR_PLACE); 887 if (value == null || (value != null && !value.equals(dto.getStreet()))) {539 if (value == null || !value.equals(dto.getStreet())) { 888 540 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_PLACE, dto.getStreet()); 889 541 commands.add(command); … … 900 552 if (dto.isSaveState()) { 901 553 String value = selection.get(TagDialog.TAG_ADDR_STATE); 902 if (value == null || (value != null && !value.equals(dto.getState()))){554 if (value == null || !value.equals(dto.getState())) { 903 555 ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STATE, dto.getState()); 904 556 commands.add(command); … … 918 570 /** 919 571 * Generates a list of all visible names of highways in order to do autocompletion on the road name. 572 * @return The possible streets for the current edit dataset 920 573 */ 921 private Collection<AutoCompletionItem> getPossibleStreets() {574 private static Collection<AutoCompletionItem> getPossibleStreets() { 922 575 Set<AutoCompletionItem> names = new TreeSet<>(); 923 576 for (OsmPrimitive osm : MainApplication.getLayerManager().getEditDataSet().allNonDeletedPrimitives()) { … … 937 590 try ( 938 591 FileInputStream file = new FileInputStream(fileName); 939 ObjectInputStream o = new ObjectInputStream(file) ;592 ObjectInputStream o = new ObjectInputStream(file) 940 593 ) { 941 594 dto = (Dto) o.readObject(); … … 944 597 loadExistingValuesToDto(dto); 945 598 } 946 } catch (Exception ex) { 947 LOGGER.log(Level.SEVERE, ex.getMessage()); 948 fileName.delete(); 599 } catch (ClassNotFoundException | IOException ex) { 600 Logging.error(ex); 601 if (!fileName.delete()) { 602 Logging.trace("TagDialog: {0} not deleted", fileName); 603 } 949 604 loadExistingValuesToDto(dto); 950 605 } -
applications/editors/josm/plugins/HouseNumberTaggingTool/test/unit/org/openstreetmap/josm/plugins/housenumbertool/HouseNumberHelperTest.java
r35508 r36060 2 2 package org.openstreetmap.josm.plugins.housenumbertool; 3 3 4 import static org.junit.Assert.assertEquals;5 import static org.junit.Assert.assertNull;6 4 7 import org.junit.Test; 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 8 import org.junit.jupiter.api.Test; 8 9 9 10 /** 10 11 * Unit tests of {@link TagDialog}. 11 12 */ 12 publicclass HouseNumberHelperTest {13 class HouseNumberHelperTest { 13 14 14 15 /** … … 16 17 */ 17 18 @Test 18 publicvoid testIncrementHouseNumber() {19 void testIncrementHouseNumber() { 19 20 assertEquals("2", HouseNumberHelper.incrementHouseNumber("1", 1)); 20 21 assertEquals("12", HouseNumberHelper.incrementHouseNumber("10", 2));
Note:
See TracChangeset
for help on using the changeset viewer.