Changeset 30613 in osm for applications
- Timestamp:
- 2014-08-31T02:46:33+02:00 (10 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
r30612 r30613 38 38 import org.openstreetmap.josm.tools.GBC; 39 39 40 41 40 /** 42 41 * The HouseNumberInputDialog is the layout of the house number input logic. 43 * Created with the Eclipse Visual Editor.44 42 * 45 43 * This dialog is concerned with the layout, all logic goes into the … … 47 45 * 48 46 * @author casualwalker 49 *50 47 */ 51 48 public class HouseNumberInputDialog extends ExtendedDialog { … … 207 204 inputPanel.add(new JLabel(tr("Street name: ")+"\""+streetName+"\""), GBC.eol().insets(3,3,0,0)); 208 205 } 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)); 214 } 206 inputPanel.add(buildingLabel, GBC.std().insets(3,3,0,0)); 207 inputPanel.add(getBuilding(), GBC.eol().insets(5,3,0,0)); 215 208 inputPanel.add(handleRelationCheckBox, GBC.eol().insets(3,3,0,0)); 216 209 inputPanel.add(deleteOutlineCheckBox, GBC.eol().insets(3,3,0,0)); 217 210 218 if (numbers.isVisible()) 219 { 211 if (numbers.isVisible()) { 220 212 loLabel.setVisible(false); 221 213 lo.setVisible(false); … … 237 229 * Overrides the default actions. Will not close the window when upload trace is clicked 238 230 */ 239 @Override protected void buttonAction(int buttonIndex, final ActionEvent evt) {240 //String a = evt.getActionCommand();231 @Override 232 protected void buttonAction(int buttonIndex, final ActionEvent evt) { 241 233 this.inputHandler.actionPerformed(evt); 242 234 } … … 309 301 streetComboBox.setEditable(true); 310 302 streetComboBox.setSelectedItem(null); 311 312 303 } 313 304 return streetComboBox; … … 327 318 buildingComboBox.setPossibleACItems(values); 328 319 buildingComboBox.setEditable(true); 329 buildingComboBox.setSelectedItem("yes"); 330 320 if (buildingType != null && !buildingType.isEmpty()) { 321 buildingComboBox.setSelectedItem(buildingType); 322 } else { 323 buildingComboBox.setSelectedItem("yes"); 324 } 331 325 } 332 326 return buildingComboBox; … … 361 355 interpolation.select(tr("Even/Odd")); 362 356 } 363 //return (dialog.interpolation.getSelectedItem().equals(tr("All"))) ? 1 : 2;364 357 } 365 358 return interpolation; -
applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputHandler.java
r30612 r30613 394 394 */ 395 395 public String buildingType() { 396 if (buildingType != null)397 return buildingType;398 399 396 return getItemText(dialog.buildingComboBox); 400 397 } -
applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java
r30612 r30613 97 97 } 98 98 99 private static final class InvalidUserInputException extends Exception { 100 InvalidUserInputException(String message) { 101 super(message); 102 } 103 } 104 99 105 /** 100 106 * Checks that the selection is OK. If not, displays error message. If so … … 110 116 Node init = null; 111 117 112 class InvalidUserInputException extends Exception {113 /*InvalidUserInputException(String message) {114 super(message);115 }*/116 117 InvalidUserInputException() {118 super();119 }120 }121 122 118 try { 123 119 if (sel.size() == 1) { … … 125 121 126 122 if (!(prim instanceof Way)) 127 throw new InvalidUserInputException( );123 throw new InvalidUserInputException(prim+" is not a way"); 128 124 129 125 outline = (Way) prim; … … 136 132 if (outline != null) 137 133 // already have a building 138 throw new InvalidUserInputException( );134 throw new InvalidUserInputException("already have a building"); 139 135 outline = way; 140 136 } else if (way.hasKey("highway")) { 141 137 if (street != null) 142 138 // already have a street 143 throw new InvalidUserInputException( );139 throw new InvalidUserInputException("already have a street"); 144 140 street = way; 145 146 if ( (streetname = street.get("name"))== null)147 throw new InvalidUserInputException( );141 streetname = street.get("name"); 142 if (streetname == null) 143 throw new InvalidUserInputException("street does not have any name"); 148 144 } else 149 throw new InvalidUserInputException( );145 throw new InvalidUserInputException(way+" is neither a building nor a highway"); 150 146 } 151 147 152 148 if (outline == null) 153 throw new InvalidUserInputException( );149 throw new InvalidUserInputException("no outline way found"); 154 150 155 151 List<Node> nodes = OsmPrimitive.getFilteredList(sel, Node.class); … … 160 156 Node node = nit.next(); 161 157 if (node.hasKey("addr:housenumber")) { 162 String nodes streetname = node.get("addr:street");158 String nodesStreetName = node.get("addr:street"); 163 159 // if a node has a street name if must be equal 164 160 // to the one of the other address nodes 165 if (nodes streetname != null) {161 if (nodesStreetName != null) { 166 162 if (streetname == null) 167 streetname = nodes streetname;168 else if (!nodes streetname.equals(streetname))169 throw new InvalidUserInputException( );163 streetname = nodesStreetName; 164 else if (!nodesStreetName.equals(streetname)) 165 throw new InvalidUserInputException("addr:street does not match street name"); 170 166 } 171 167 … … 176 172 // the number direction right. 177 173 if (!outline.containsNode(node) || init != null) 178 throw new InvalidUserInputException( );174 throw new InvalidUserInputException("node problem"); 179 175 init = node; 180 176 } … … 185 181 186 182 if (outline == null || !outline.isClosed() || outline.getNodesCount() < 5) 187 throw new InvalidUserInputException(); 183 throw new InvalidUserInputException("wrong or missing outline"); 184 188 185 } catch (InvalidUserInputException ex) { 186 Main.warn("Terracer: "+ex.getMessage()); 189 187 new ExtendedDialog(Main.parent, tr("Invalid selection"), new String[] {"OK"}) 190 188 .setButtonIcons(new String[] {"ok"}).setIcon(JOptionPane.INFORMATION_MESSAGE) … … 211 209 if (associatedStreets.size() > 1) { 212 210 // TODO: Deal with multiple associated Streets 213 System.out.println("Terracer warning: Found "+associatedStreets.size()+" associatedStreet relations. Considering the first one only.");211 Main.warn("Terracer: Found "+associatedStreets.size()+" associatedStreet relations. Considering the first one only."); 214 212 } 215 213 } … … 233 231 String title = trn("Change {0} object", "Change {0} objects", sel.size(), sel.size()); 234 232 // show input dialog. 235 new HouseNumberInputHandler(this, outline, init, street, streetname, null,233 new HouseNumberInputHandler(this, outline, init, street, streetname, outline.get("building"), 236 234 associatedStreet, housenumbers, title); 237 235 } … … 522 520 numberAdded = houseNum.hasKey("addr:housenumber"); 523 521 } 524 if (! outline.hasKey("building") && !buildingAdded) {522 if (!buildingAdded && buildingValue != null && !buildingValue.isEmpty()) { 525 523 this.commands.add(new ChangePropertyCommand(outline, "building", buildingValue)); 526 524 }
Note:
See TracChangeset
for help on using the changeset viewer.