Changeset 5211 in josm
- Timestamp:
- 2012-05-04T19:15:59+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/DownloadPrimitiveAction.java
r4982 r5211 10 10 import java.awt.GridBagLayout; 11 11 import java.awt.event.ActionEvent; 12 import java.awt.event.ActionListener; 12 import java.awt.event.ItemEvent; 13 import java.awt.event.ItemListener; 13 14 import java.awt.event.KeyEvent; 14 15 import java.lang.reflect.InvocationTargetException; … … 139 140 ); 140 141 141 cbType.add ActionListener(new ActionListener() {142 cbType.addItemListener(new ItemListener() { 142 143 143 144 @Override 144 public void actionPerformed(ActionEvent ae) { 145 public void itemStateChanged(ItemEvent e) { 146 tfId.setType(cbType.getType()); 147 tfId.performValidation(); 145 148 referrers.setText(cbType.getType() == OsmPrimitiveType.NODE 146 149 ? tr("Download referrers (parent relations and ways)") … … 186 189 187 190 tfId.setType(cbType.getType()); 188 if( tfId.readOsmIds()==false) {191 if(!tfId.readOsmIds()) { 189 192 JOptionPane.showMessageDialog( 190 193 Main.parent, 191 194 tr("Invalid ID list specified\n" 192 + " 195 + "Cannot download object."), 193 196 tr("Information"), 194 197 JOptionPane.INFORMATION_MESSAGE -
trunk/src/org/openstreetmap/josm/gui/widgets/OsmIdTextField.java
r4796 r5211 30 30 } 31 31 32 public long getOsmId() {33 return validator.getOsmId();34 }35 36 32 /** 37 33 * Get entered ID list - supports "1,2,3" "1 2 ,3" or even "1 2 3 v2 6 v8" … … 46 42 } 47 43 44 public void performValidation() { 45 validator.validate(); 46 } 48 47 49 48 /** … … 66 65 @Override 67 66 public boolean isValid() { 68 return getOsmId() > 0 || readOsmIds() != false;67 return readOsmIds(); 69 68 } 70 69 … … 78 77 } 79 78 80 public long getOsmId() {81 String value = getComponent().getText();82 if (value == null || value.trim().length() == 0) return 0;83 try {84 long osmId = Long.parseLong(value.trim());85 if (osmId > 0)86 return osmId;87 return 0;88 } catch(NumberFormatException e) {89 return 0;90 }91 }92 93 79 public boolean readOsmIds() { 94 80 String value = getComponent().getText(); … … 110 96 ids.add(SimplePrimitiveId.fromString(s)); 111 97 } catch (IllegalArgumentException ex) { 112 if (type == OsmPrimitiveType.NODE) { 113 ids.add(new SimplePrimitiveId(Long.parseLong(s), OsmPrimitiveType.NODE)); 114 } else if (type == OsmPrimitiveType.WAY) { 115 ids.add(new SimplePrimitiveId(Long.parseLong(s), OsmPrimitiveType.WAY)); 116 } else if (type == OsmPrimitiveType.RELATION) { 117 ids.add(new SimplePrimitiveId(Long.parseLong(s), OsmPrimitiveType.RELATION)); 118 } else { 98 try { 99 if (type == OsmPrimitiveType.NODE) { 100 ids.add(new SimplePrimitiveId(Long.parseLong(s), OsmPrimitiveType.NODE)); 101 } else if (type == OsmPrimitiveType.WAY) { 102 ids.add(new SimplePrimitiveId(Long.parseLong(s), OsmPrimitiveType.WAY)); 103 } else if (type == OsmPrimitiveType.RELATION) { 104 ids.add(new SimplePrimitiveId(Long.parseLong(s), OsmPrimitiveType.RELATION)); 105 } else { 106 return false; 107 } 108 } catch (IllegalArgumentException ex2) { 119 109 return false; 120 110 }
Note:
See TracChangeset
for help on using the changeset viewer.