Changeset 23191 in osm for applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputHandler.java
- Timestamp:
- 2010-09-15T18:56:19+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputHandler.java
r21169 r23191 61 61 this.street = street; 62 62 this.associatedStreet = associatedStreet; 63 63 64 64 // This dialog is started modal 65 65 this.dialog = new HouseNumberInputDialog(this, street, associatedStreet != null); 66 66 67 67 // We're done 68 68 } 69 69 70 71 72 73 74 75 76 77 78 79 80 81 70 /** 71 * Find a button with a certain caption. 72 * Loops recursively through all objects to find all buttons. 73 * Function returns on the first match. 74 * 75 * @param root A container object that is recursively searched for other containers or buttons 76 * @param caption The caption of the button that is being searched 77 * 78 * @return The first button that matches the caption or null if not found 79 */ 80 private static JButton getButton(Container root, String caption) { 81 Component children[] = root.getComponents(); 82 82 for (Component child : children) { 83 84 85 86 87 83 JButton b; 84 if (child instanceof JButton) { 85 b = (JButton) child; 86 if (caption.equals(b.getText())) return b; 87 } else if (child instanceof Container) { 88 88 b = getButton((Container)child, caption); 89 89 if (b != null) return b; 90 90 } 91 91 } 92 93 94 92 return null; 93 } 94 95 95 /** 96 96 * Validate the current input fields. … … 110 110 // Allow non numeric characters for the low number as long as there is no high number of the segmentcount is 1 111 111 if (dialog.hi.getText().length() > 0 | segments() > 1) { 112 113 114 115 112 isOk = isOk 113 && checkNumberStringField(dialog.lo, tr("Lowest number"), 114 message); 115 } 116 116 isOk = isOk 117 117 && checkNumberStringField(dialog.hi, tr("Highest number"), … … 124 124 JButton okButton = getButton(dialog, "OK"); 125 125 if (okButton != null) 126 127 126 okButton.setEnabled(true); 127 128 128 // For some reason the messageLabel doesn't want to show up 129 129 dialog.messageLabel.setForeground(Color.black); … … 133 133 JButton okButton = getButton(dialog, "OK"); 134 134 if (okButton != null) 135 136 137 138 139 140 135 okButton.setEnabled(false); 136 137 // For some reason the messageLabel doesn't want to show up, so a MessageDialog is shown instead. Someone more knowledgeable might fix this. 138 dialog.messageLabel.setForeground(Color.red); 139 dialog.messageLabel.setText(message.toString()); 140 //JOptionPane.showMessageDialog(null, message.toString(), tr("Error"), JOptionPane.ERROR_MESSAGE); 141 141 142 142 return false; … … 273 273 JButton button = (JButton) e.getSource(); 274 274 if ("OK".equals(button.getActionCommand()) & button.isEnabled()) { 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 275 if (validateInput()) { 276 saveValues(); 277 278 terracerAction.terraceBuilding( 279 outline, 280 street, 281 associatedStreet, 282 segments(), 283 dialog.lo.getText(), 284 dialog.hi.getText(), 285 stepSize(), 286 streetName(), 287 doHandleRelation(), 288 doDeleteOutline()); 289 290 this.dialog.dispose(); 291 } 292 292 } else if ("Cancel".equals(button.getActionCommand())) { 293 293 this.dialog.dispose(); … … 357 357 if (street != null) 358 358 return null; 359 359 360 360 Object selected = dialog.streetComboBox.getSelectedItem(); 361 361 if (selected == null) { … … 376 376 */ 377 377 public boolean doHandleRelation() { 378 379 JOptionPane.showMessageDialog(null, "dialog", "alert", JOptionPane.ERROR_MESSAGE);380 381 382 JOptionPane.showMessageDialog(null, "checkbox", "alert", JOptionPane.ERROR_MESSAGE);383 384 385 386 } 387 } 388 389 378 if (this.dialog == null) { 379 JOptionPane.showMessageDialog(null, "dialog", "alert", JOptionPane.ERROR_MESSAGE); 380 } 381 if (this.dialog.handleRelationCheckBox == null) { 382 JOptionPane.showMessageDialog(null, "checkbox", "alert", JOptionPane.ERROR_MESSAGE); 383 return true; 384 } else { 385 return this.dialog.handleRelationCheckBox.isSelected(); 386 } 387 } 388 389 390 390 /** 391 391 * Whether the user likes to delete the outline way. … … 394 394 return dialog.deleteOutlineCheckBox.isSelected(); 395 395 } 396 396 397 397 /* (non-Javadoc) 398 398 * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent) 399 399 */ 400 400 public void focusGained(FocusEvent e) { 401 401 // Empty, but placeholder is required 402 402 } 403 403 … … 406 406 */ 407 407 public void focusLost(FocusEvent e) { 408 409 408 if (e.getOppositeComponent() == null) 409 return; 410 410 411 411 validateInput();
Note:
See TracChangeset
for help on using the changeset viewer.