- Timestamp:
- 2016-02-17T21:40:45+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java
r9078 r9816 55 55 private NodeListPopupMenu popupMenu; 56 56 57 /** 58 * Constructs a new {@code NodeListViewer}. 59 * @param model history browser model 60 */ 61 public NodeListViewer(HistoryBrowserModel model) { 62 setModel(model); 63 build(); 64 } 65 57 66 protected JScrollPane embeddInScrollPane(JTable table) { 58 67 JScrollPane pane = new JScrollPane(table); … … 96 105 public void tableChanged(TableModelEvent e) { 97 106 if (e.getSource() instanceof DiffTableModel) { 98 final DiffTableModel mod el= (DiffTableModel) e.getSource();99 if (reversed == null || reversed != mod el.isReversed()) {100 reversed = mod el.isReversed();107 final DiffTableModel mod = (DiffTableModel) e.getSource(); 108 if (reversed == null || reversed != mod.isReversed()) { 109 reversed = mod.isReversed(); 101 110 columnModel.getColumn(0).setHeaderValue(reversed ? reversedText : nonReversedText); 102 111 table.getTableHeader().setToolTipText( … … 164 173 } 165 174 166 public NodeListViewer(HistoryBrowserModel model) {167 setModel(model);168 build();169 }170 171 175 protected void unregisterAsObserver(HistoryBrowserModel model) { 172 176 if (currentInfoPanel != null) { … … 187 191 } 188 192 193 /** 194 * Sets the history browser model. 195 * @param model the history browser model 196 */ 189 197 public void setModel(HistoryBrowserModel model) { 190 198 if (this.model != null) { … … 231 239 @Override 232 240 public void actionPerformed(ActionEvent e) { 233 if (!isEnabled()) return; 241 if (!isEnabled()) 242 return; 234 243 OsmPrimitive p = getPrimitiveToZoom(); 235 244 if (p != null) { … … 248 257 249 258 protected OsmPrimitive getPrimitiveToZoom() { 250 if (primitiveId == null) return null; 259 if (primitiveId == null) 260 return null; 251 261 OsmDataLayer editLayer = Main.main.getEditLayer(); 252 if (editLayer == null) return null; 262 if (editLayer == null) 263 return null; 253 264 return editLayer.data.getPrimitiveById(primitiveId); 254 265 } … … 277 288 @Override 278 289 public void actionPerformed(ActionEvent e) { 279 if (!isEnabled()) return; 280 run(); 290 if (isEnabled()) { 291 run(); 292 } 281 293 } 282 294 … … 314 326 DiffTableModel castedModel = (DiffTableModel) model; 315 327 Long id = (Long) castedModel.getValueAt(row, 0).value; 316 if (id == null) return null; 317 return new SimplePrimitiveId(id, OsmPrimitiveType.NODE); 328 return id == null ? null : new SimplePrimitiveId(id, OsmPrimitiveType.NODE); 318 329 } 319 330 … … 342 353 @Override 343 354 public void mouseClicked(MouseEvent e) { 344 if (e.getClickCount() < 2) return; 355 if (e.getClickCount() < 2) 356 return; 345 357 int row = table.rowAtPoint(e.getPoint()); 346 if (row <= 0) return; 358 if (row <= 0) 359 return; 347 360 PrimitiveId pid = primitiveIdAtRow(table.getModel(), row); 348 361 if (pid == null || pid.isNew()) -
trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java
r9657 r9816 102 102 } 103 103 104 public void removeProper yChangeListener(PropertyChangeListener listener) {104 public void removePropertyChangeListener(PropertyChangeListener listener) { 105 105 propChangeSupport.removePropertyChangeListener(listener); 106 106 } … … 133 133 throw new IndexOutOfBoundsException("unexpected rowIndex: rowIndex=" + rowIndex); 134 134 135 TagModel tag = tags.get(rowIndex); 136 switch(columnIndex) { 137 case 0: 138 case 1: 139 return tag; 140 141 default: 142 throw new IndexOutOfBoundsException("unexpected columnIndex: columnIndex=" + columnIndex); 143 } 135 return tags.get(rowIndex); 144 136 } 145 137 … … 147 139 public void setValueAt(Object value, int row, int col) { 148 140 TagModel tag = get(row); 149 if (tag == null) return; 150 switch(col) { 151 case 0: 152 updateTagName(tag, (String) value); 153 break; 154 case 1: 155 String v = (String) value; 156 if (tag.getValueCount() > 1 && !v.isEmpty()) { 157 updateTagValue(tag, v); 158 } else if (tag.getValueCount() <= 1) { 159 updateTagValue(tag, v); 141 if (tag != null) { 142 switch(col) { 143 case 0: 144 updateTagName(tag, (String) value); 145 break; 146 case 1: 147 String v = (String) value; 148 if (tag.getValueCount() > 1 && !v.isEmpty()) { 149 updateTagValue(tag, v); 150 } else if (tag.getValueCount() <= 1) { 151 updateTagValue(tag, v); 152 } 160 153 } 161 154 } … … 208 201 */ 209 202 public void add(String name, String value) { 210 name= (name == null) ? "" : name;211 value= (value == null) ? "" : value;212 213 TagModel tag = get( name);203 String key = (name == null) ? "" : name; 204 String val = (value == null) ? "" : value; 205 206 TagModel tag = get(key); 214 207 if (tag == null) { 215 tag = new TagModel( name, value);208 tag = new TagModel(key, val); 216 209 int index = tags.size(); 217 210 while (index >= 1 && tags.get(index - 1).getName().isEmpty() && tags.get(index - 1).getValue().isEmpty()) { … … 220 213 tags.add(index, tag); 221 214 } else { 222 tag.addValue(val ue);215 tag.addValue(val); 223 216 } 224 217 setDirty(true); … … 232 225 */ 233 226 public TagModel get(String name) { 234 name= (name == null) ? "" : name;227 String key = (name == null) ? "" : name; 235 228 for (TagModel tag : tags) { 236 if (tag.getName().equals( name))229 if (tag.getName().equals(key)) 237 230 return tag; 238 231 } … … 241 234 242 235 public TagModel get(int idx) { 243 if (idx >= tags.size()) return null; 244 return tags.get(idx); 236 return idx >= tags.size() ? null : tags.get(idx); 245 237 } 246 238 … … 293 285 */ 294 286 public void delete(String name) { 295 if (name == null) return; 287 if (name == null) 288 return; 296 289 Iterator<TagModel> it = tags.iterator(); 297 290 boolean changed = false; … … 474 467 */ 475 468 public boolean includesTag(String key) { 476 if (key == null) return false; 477 for (TagModel tag : tags) { 478 if (tag.getName().equals(key)) 479 return true; 469 if (key != null) { 470 for (TagModel tag : tags) { 471 if (tag.getName().equals(key)) 472 return true; 473 } 480 474 } 481 475 return false; … … 502 496 List<Command> commands = new ArrayList<>(); 503 497 504 for (OsmPrimitive prim itive: primitives) {505 for (String oldkey : prim itive.keySet()) {498 for (OsmPrimitive prim : primitives) { 499 for (String oldkey : prim.keySet()) { 506 500 if (!currentkeys.contains(oldkey)) { 507 501 ChangePropertyCommand deleteCommand = 508 new ChangePropertyCommand(prim itive, oldkey, null);502 new ChangePropertyCommand(prim, oldkey, null); 509 503 commands.add(deleteCommand); 510 504 } -
trunk/src/org/openstreetmap/josm/gui/tagging/TagModel.java
r8840 r9816 5 5 import java.util.List; 6 6 7 /** 8 * Tag model. 9 * @since 1762 10 */ 7 11 public class TagModel { 8 12 … … 48 52 */ 49 53 public final void setName(String name) { 50 name = (name == null) ? "" : name; 51 this.name = name; 54 this.name = (name == null) ? "" : name; 52 55 } 53 56 54 57 /** 58 * returns the tag name (key). 55 59 * @return the tag name 56 60 */ … … 71 75 */ 72 76 public final void setValue(String value) { 73 value = (value == null) ? "" : value;74 77 clearValues(); 75 this.values.add( value);78 this.values.add((value == null) ? "" : value); 76 79 } 77 80 78 81 /** 79 * 82 * determines if this tag model has a specific value 80 83 * @param value the value to be checked; converted to "" if null 81 84 * @return true, if the values of this tag include <code>value</code>; false otherwise 82 85 */ 83 86 public boolean hasValue(String value) { 84 value = (value == null) ? "" : value; 85 return values.contains(value); 87 return values.contains((value == null) ? "" : value); 86 88 } 87 89 90 /** 91 * adds a tag value 92 * @param value the value to add; converted to "" if null 93 */ 88 94 public void addValue(String value) { 89 value= (value == null) ? "" : value;90 if (hasValue(val ue)) {95 String val = (value == null) ? "" : value; 96 if (hasValue(val)) { 91 97 return; 92 98 } 93 values.add(val ue);99 values.add(val); 94 100 } 95 101 … … 99 105 */ 100 106 public void removeValue(String value) { 101 value = (value == null) ? "" : value; 102 values.remove(value); 107 values.remove((value == null) ? "" : value); 103 108 } 104 109 110 /** 111 * returns the list of values 112 * @return the list of values 113 */ 105 114 public List<String> getValues() { 106 115 return values; 107 116 } 108 117 118 /** 119 * returns the value(s) as string 120 * @return the value(s) as string, joined with a semicolon (;) if multiple values 121 */ 109 122 public String getValue() { 110 123 if (getValueCount() == 0) { … … 124 137 } 125 138 139 /** 140 * returns the number of values 141 * @return the number of values 142 */ 126 143 public int getValueCount() { 127 144 return values.size();
Note:
See TracChangeset
for help on using the changeset viewer.