Changeset 29623 in osm for applications/editors
- Timestamp:
- 2013-06-04T22:36:05+02:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/terracer/src/terracer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputDialog.java
r29035 r29623 19 19 import java.util.ArrayList; 20 20 import java.util.Iterator; 21 import java.util.List; 21 22 import java.util.TreeSet; 22 23 … … 34 35 import org.openstreetmap.josm.gui.ExtendedDialog; 35 36 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox; 37 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem; 36 38 import org.openstreetmap.josm.tools.GBC; 37 39 … … 59 61 //final private Way street; 60 62 final private String streetName; 63 final private String buildingType; 61 64 final private boolean relationExists; 62 65 final ArrayList<Node> housenumbers; … … 74 77 private JLabel streetLabel; 75 78 AutoCompletingComboBox streetComboBox; 79 private JLabel buildingLabel; 80 AutoCompletingComboBox buildingComboBox; 76 81 private JLabel segmentsLabel; 77 82 JTextField segments; … … 90 95 * street line or the house numbers which are guaranteed to have the 91 96 * same name attached (may be null) 97 * @param buildingType The value to add for building key 92 98 * @param relationExists If the buildings can be added to an existing relation or not. 93 99 * @param housenumbers a list of house numbers in this outline (may be empty) 94 100 */ 95 public HouseNumberInputDialog(HouseNumberInputHandler handler, Way street, String streetName, boolean relationExists, ArrayList<Node> housenumbers) { 101 public HouseNumberInputDialog(HouseNumberInputHandler handler, Way street, String streetName, String buildingType, boolean relationExists, ArrayList<Node> housenumbers) { 96 102 super(Main.parent, 97 103 tr("Terrace a house"), … … 102 108 //this.street = street; 103 109 this.streetName = streetName; 110 this.buildingType = buildingType; 104 111 this.relationExists = relationExists; 105 112 this.housenumbers = housenumbers; … … 163 170 messageLabel.setFocusable(false); // Needed so that lowest number can have focus immediately 164 171 165 interpolationLabel = new JLabel(); 166 interpolationLabel.setText(tr("Interpolation")); 167 segmentsLabel = new JLabel(); 168 segmentsLabel.setText(tr("Segments")); 169 streetLabel = new JLabel(); 170 streetLabel.setText(tr("Street")); 171 loLabel = new JLabel(); 172 loLabel.setText(tr("Lowest Number")); 172 interpolationLabel = new JLabel(tr("Interpolation")); 173 segmentsLabel = new JLabel(tr("Segments")); 174 streetLabel = new JLabel(tr("Street")); 175 buildingLabel = new JLabel(tr("Building")); 176 loLabel = new JLabel(tr("Lowest Number")); 173 177 loLabel.setPreferredSize(new Dimension(111, 16)); 174 178 loLabel.setToolTipText(tr("Lowest housenumber of the terraced house")); 175 hiLabel = new JLabel(); 176 hiLabel.setText(tr("Highest Number")); 177 numbersLabel = new JLabel(); 178 numbersLabel.setText(tr("List of Numbers")); 179 hiLabel = new JLabel(tr("Highest Number")); 180 numbersLabel = new JLabel(tr("List of Numbers")); 179 181 loLabel.setPreferredSize(new Dimension(111, 16)); 180 182 final String txt = relationExists ? tr("add to existing associatedStreet relation") : tr("create an associatedStreet relation"); … … 204 206 } else { 205 207 inputPanel.add(new JLabel(tr("Street name: ")+"\""+streetName+"\""), GBC.eol().insets(3,3,0,0)); 208 } 209 if (buildingType == null) { 210 inputPanel.add(buildingLabel, GBC.std().insets(3,3,0,0)); 211 inputPanel.add(getBuilding(), GBC.eol().insets(5,3,0,0)); 212 } else { 213 inputPanel.add(new JLabel(tr("Building: ")+"\""+buildingType+"\""), GBC.eol().insets(3,3,0,0)); 206 214 } 207 215 inputPanel.add(handleRelationCheckBox, GBC.eol().insets(3,3,0,0)); … … 290 298 * This method initializes street 291 299 * 292 * @return javax.swing.JTextField300 * @return AutoCompletingComboBox 293 301 */ 294 302 private AutoCompletingComboBox getStreet() { … … 304 312 } 305 313 return streetComboBox; 314 } 315 316 /** 317 * This method initializes building 318 * 319 * @return AutoCompletingComboBox 320 */ 321 private AutoCompletingComboBox getBuilding() { 322 323 if (buildingComboBox == null) { 324 final List<AutoCompletionListItem> values = Main.main.getCurrentDataSet().getAutoCompletionManager().getValues("building"); 325 326 buildingComboBox = new AutoCompletingComboBox(); 327 buildingComboBox.setPossibleACItems(values); 328 buildingComboBox.setEditable(true); 329 buildingComboBox.setSelectedItem("yes"); 330 331 } 332 return buildingComboBox; 306 333 } 307 334 -
applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputHandler.java
r29509 r29623 31 31 import org.openstreetmap.josm.data.osm.Relation; 32 32 import org.openstreetmap.josm.data.osm.Way; 33 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox; 33 34 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem; 34 35 … … 48 49 private final Way outline, street; 49 50 private final String streetName; 51 private final String buildingType; 50 52 private final Node init; 51 53 private final Relation associatedStreet; … … 63 65 * the house numbers which are guaranteed to have the same name 64 66 * attached (may be null) 67 * @param buildingType The value to add for building key 65 68 * @param associatedStreet a relation where we can add the houses (may be null) 66 69 * @param housenumbers a list of house number nodes in this outline (may be empty) … … 68 71 */ 69 72 public HouseNumberInputHandler(final TerracerAction terracerAction, 70 final Way outline, final Node init, final Way street, final String streetName, 73 final Way outline, final Node init, final Way street, final String streetName, final String buildingType, 71 74 final Relation associatedStreet, 72 75 final ArrayList<Node> housenumbers, final String title) { … … 76 79 this.street = street; 77 80 this.streetName = streetName; 81 this.buildingType = buildingType; 78 82 this.associatedStreet = associatedStreet; 79 83 this.housenumbers = housenumbers; 80 84 81 85 // This dialog is started modal 82 this.dialog = new HouseNumberInputDialog(this, street, streetName, 86 this.dialog = new HouseNumberInputDialog(this, street, streetName, buildingType, 83 87 associatedStreet != null, housenumbers); 84 88 … … 318 322 streetName(), 319 323 doHandleRelation(), 320 doDeleteOutline()); 324 doDeleteOutline(), buildingType()); 321 325 } catch (UserCancelException ex) { 322 326 // Ignore … … 393 397 return streetName; 394 398 395 Object selected = dialog.streetComboBox.getSelectedItem(); 399 return getItemText(dialog.streetComboBox); 400 } 401 402 /** 403 * Gets the building type. 404 * 405 * @return the building type or null, if not set / invalid. 406 */ 407 public String buildingType() { 408 if (buildingType != null) 409 return buildingType; 410 411 return getItemText(dialog.buildingComboBox); 412 } 413 414 private static String getItemText(AutoCompletingComboBox box) { 415 Object selected = box.getSelectedItem(); 396 416 if (selected == null) { 397 417 return null; -
applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java
r29509 r29623 221 221 // Don't open the dialog 222 222 try { 223 terraceBuilding(outline, init, street, associatedStreet, 0, null, null, 0, housenumbers, streetname, associatedStreet != null, false); 223 terraceBuilding(outline, init, street, associatedStreet, 0, null, null, 0, housenumbers, streetname, associatedStreet != null, false, "yes"); 224 224 } catch (UserCancelException ex) { 225 225 // Ignore … … 231 231 String title = trn("Change {0} object", "Change {0} objects", sel.size(), sel.size()); 232 232 // show input dialog. 233 new HouseNumberInputHandler(this, outline, init, street, streetname, 233 new HouseNumberInputHandler(this, outline, init, street, streetname, null, 234 234 associatedStreet, housenumbers, title); 235 235 } … … 312 312 * existing relation 313 313 * @param deleteOutline If the outline way should be deleted when done 314 * @param buildingValue The value for {@code building} key to add 314 315 * @throws UserCancelException 315 316 */ … … 325 326 String streetName, 326 327 boolean handleRelations, 327 boolean deleteOutline) throws UserCancelException { 328 boolean deleteOutline, String buildingValue) throws UserCancelException { 328 329 final int nb; 329 330 Integer to = null, from = null; … … 397 398 TagCollection.from(outline).applyTo(terr); 398 399 ways.add(addressBuilding(terr, street, streetName, associatedStreet, housenumbers, i, 399 from != null ? Integer.toString(from + i * step) : null)); 400 from != null ? Integer.toString(from + i * step) : null, buildingValue)); 400 401 401 402 this.commands.add(new AddCommand(terr)); … … 417 418 } else { 418 419 // Single building, just add the address details 419 ways.add(addressBuilding(outline, street, streetName, associatedStreet, housenumbers, 0, From)); 420 ways.add(addressBuilding(outline, street, streetName, associatedStreet, housenumbers, 0, From, buildingValue)); 420 421 } 421 422 … … 473 474 * @param streetName the name of a street (may be null). Used if not null and street is null. 474 475 * @param associatedStreet The associated street. Used to determine if addr:street should be set or not. 476 * @param buildingValue The value for {@code building} key to add 475 477 * @return {@code outline} 476 478 * @throws UserCancelException 477 479 */ 478 private Way addressBuilding(Way outline, Way street, String streetName, Relation associatedStreet, ArrayList<Node> housenumbers, int i, String defaultNumber) throws UserCancelException { 480 private Way addressBuilding(Way outline, Way street, String streetName, Relation associatedStreet, ArrayList<Node> housenumbers, int i, String defaultNumber, String buildingValue) throws UserCancelException { 479 481 Node houseNum = (housenumbers != null && i >= 0 && i < housenumbers.size()) ? housenumbers.get(i) : null; 480 482 boolean buildingAdded = false; … … 498 500 } 499 501 if (!outline.hasKey("building") && !buildingAdded) { 500 this.commands.add(new ChangePropertyCommand(outline, "building", "yes"));502 this.commands.add(new ChangePropertyCommand(outline, "building", buildingValue)); 501 503 } 502 504 if (defaultNumber != null && !numberAdded) {
Note:
See TracChangeset
for help on using the changeset viewer.