Changeset 1911 in josm
- Timestamp:
- 2009-08-05T10:05:50+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r1862 r1911 54 54 } 55 55 56 @SuppressWarnings("unchecked") 56 57 public void actionPerformed(ActionEvent event) { 57 58 if (getCurrentDataSet() == null) -
trunk/src/org/openstreetmap/josm/data/conflict/Conflict.java
r1750 r1911 51 51 } 52 52 53 @SuppressWarnings("unchecked") 53 54 @Override 54 55 public boolean equals(Object obj) { … … 59 60 if (getClass() != obj.getClass()) 60 61 return false; 61 Conflict<T> other = (Conflict ) obj;62 Conflict<T> other = (Conflict<T>) obj; 62 63 if (my != other.my) 63 64 return false; -
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r1724 r1911 40 40 public Collection<WayPoint> waypoints = new LinkedList<WayPoint>(); 41 41 42 @SuppressWarnings("unchecked") 42 43 public void mergeFrom(GpxData other) { 43 44 if (storageFile == null && other.storageFile != null) { … … 51 52 if (k.equals(META_LINKS) && attr.containsKey(META_LINKS)) { 52 53 ((Collection<GpxLink>) attr.get(META_LINKS)).addAll( 53 (Collection<GpxLink>) ent.getValue());54 (Collection<GpxLink>) ent.getValue()); 54 55 } else { 55 56 attr.put(k, ent.getValue()); -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r1910 r1911 71 71 public Node getNode(int index) { 72 72 return nodes.get(index); 73 } 74 75 /** 76 * Replies true if this way contains the node <code>node</code>, false 77 * otherwise. Replies false if <code>node</code> is null. 78 * 79 * @param node the node. May be null. 80 * @return true if this way contains the node <code>node</code>, false 81 * otherwise 82 * @since 1909 83 */ 84 public boolean containsNode(Node node) { 85 if (node == null) return false; 86 return nodes.contains(node); 73 87 } 74 88 -
trunk/src/org/openstreetmap/josm/gui/FileDrop.java
r1231 r1911 1 /* code from: http://iharder.sourceforge.net/current/java/filedrop/ 1 /* code from: http://iharder.sourceforge.net/current/java/filedrop/ 2 2 (public domain) with only very small additions */ 3 3 package org.openstreetmap.josm.gui; … … 26 26 * new FileDrop( myPanel, new FileDrop.Listener() 27 27 * { public void filesDropped( java.io.File[] files ) 28 * { 28 * { 29 29 * // handle file drop 30 30 * ... … … 55 55 private transient javax.swing.border.Border normalBorder; 56 56 private transient java.awt.dnd.DropTargetListener dropListener; 57 58 57 58 59 59 /** Discover if the running JVM is modern enough to have drag and drop. */ 60 60 private static Boolean supportsDnD; 61 61 62 62 // Default border color 63 63 private static java.awt.Color defaultBorderColor = new java.awt.Color( 0f, 0f, 1f, 0.25f ); 64 64 65 65 66 66 /* Constructor for JOSM file drop */ … … 72 72 true, // Recursive 73 73 new FileDrop.Listener() 74 { 74 { 75 75 public void filesDropped( java.io.File[] files ) 76 { 76 { 77 77 OpenFileAction ofa = new OpenFileAction(); 78 78 for( int i = 0; i < files.length; i++ ) 79 { 79 { 80 80 ofa.openFile(files[i]); 81 81 } // end for: through each dropped file … … 84 84 } 85 85 86 86 87 87 /** 88 88 * Constructs a {@link FileDrop} with a default light-blue border … … 96 96 */ 97 97 public FileDrop( 98 final java.awt.Component c,99 final Listener listener )98 final java.awt.Component c, 99 final Listener listener ) 100 100 { this( null, // Logging stream 101 102 103 104 101 c, // Drop target 102 javax.swing.BorderFactory.createMatteBorder( 2, 2, 2, 2, defaultBorderColor ), // Drag border 103 true, // Recursive 104 listener ); 105 105 } // end constructor 106 107 108 109 106 107 108 109 110 110 /** 111 111 * Constructor with a default border and the option to recursively set drop targets. … … 119 119 */ 120 120 public FileDrop( 121 final java.awt.Component c,122 final boolean recursive,123 final Listener listener )121 final java.awt.Component c, 122 final boolean recursive, 123 final Listener listener ) 124 124 { this( null, // Logging stream 125 126 127 128 125 c, // Drop target 126 javax.swing.BorderFactory.createMatteBorder( 2, 2, 2, 2, defaultBorderColor ), // Drag border 127 recursive, // Recursive 128 listener ); 129 129 } // end constructor 130 131 130 131 132 132 /** 133 133 * Constructor with a default border and debugging optionally turned on. … … 138 138 * 139 139 * @param out PrintStream to record debugging info or null for no debugging. 140 * @param out 140 * @param out 141 141 * @param c Component on which files will be dropped. 142 142 * @param listener Listens for <tt>filesDropped</tt>. … … 144 144 */ 145 145 public FileDrop( 146 final java.io.PrintStream out,147 final java.awt.Component c,148 final Listener listener )146 final java.io.PrintStream out, 147 final java.awt.Component c, 148 final Listener listener ) 149 149 { this( out, // Logging stream 150 151 javax.swing.BorderFactory.createMatteBorder( 2, 2, 2, 2, defaultBorderColor ),152 153 150 c, // Drop target 151 javax.swing.BorderFactory.createMatteBorder( 2, 2, 2, 2, defaultBorderColor ), 152 false, // Recursive 153 listener ); 154 154 } // end constructor 155 156 157 155 156 157 158 158 /** 159 159 * Constructor with a default border, debugging optionally turned on … … 167 167 * 168 168 * @param out PrintStream to record debugging info or null for no debugging. 169 * @param out 169 * @param out 170 170 * @param c Component on which files will be dropped. 171 171 * @param recursive Recursively set children as drop targets. … … 174 174 */ 175 175 public FileDrop( 176 final java.io.PrintStream out,177 final java.awt.Component c,178 final boolean recursive,179 final Listener listener)176 final java.io.PrintStream out, 177 final java.awt.Component c, 178 final boolean recursive, 179 final Listener listener) 180 180 { this( out, // Logging stream 181 182 183 184 181 c, // Drop target 182 javax.swing.BorderFactory.createMatteBorder( 2, 2, 2, 2, defaultBorderColor ), // Drag border 183 recursive, // Recursive 184 listener ); 185 185 } // end constructor 186 187 188 189 190 /** 191 * Constructor with a specified border 186 187 188 189 190 /** 191 * Constructor with a specified border 192 192 * 193 193 * @param c Component on which files will be dropped. … … 197 197 */ 198 198 public FileDrop( 199 final java.awt.Component c,200 final javax.swing.border.Border dragBorder,201 final Listener listener)199 final java.awt.Component c, 200 final javax.swing.border.Border dragBorder, 201 final Listener listener) 202 202 { this( 203 203 null, // Logging stream … … 207 207 listener ); 208 208 } // end constructor 209 210 211 212 209 210 211 212 213 213 /** 214 214 * Constructor with a specified border and the option to recursively set drop targets. … … 223 223 */ 224 224 public FileDrop( 225 final java.awt.Component c,226 final javax.swing.border.Border dragBorder,227 final boolean recursive,228 final Listener listener)225 final java.awt.Component c, 226 final javax.swing.border.Border dragBorder, 227 final boolean recursive, 228 final Listener listener) 229 229 { this( 230 230 null, … … 234 234 listener ); 235 235 } // end constructor 236 237 238 236 237 238 239 239 /** 240 240 * Constructor with a specified border and debugging optionally turned on. … … 251 251 */ 252 252 public FileDrop( 253 final java.io.PrintStream out,254 final java.awt.Component c,255 final javax.swing.border.Border dragBorder,256 final Listener listener)253 final java.io.PrintStream out, 254 final java.awt.Component c, 255 final javax.swing.border.Border dragBorder, 256 final Listener listener) 257 257 { this( 258 258 out, // Logging stream … … 262 262 listener ); 263 263 } // end constructor 264 265 266 267 268 264 265 266 267 268 269 269 /** 270 270 * Full constructor with a specified border and debugging optionally turned on. … … 282 282 */ 283 283 public FileDrop( 284 final java.io.PrintStream out,285 final java.awt.Component c,286 final javax.swing.border.Border dragBorder,287 final boolean recursive,288 final Listener listener)289 { 290 284 final java.io.PrintStream out, 285 final java.awt.Component c, 286 final javax.swing.border.Border dragBorder, 287 final boolean recursive, 288 final Listener listener) 289 { 290 291 291 if( supportsDnD() ) 292 292 { // Make a drop listener 293 293 dropListener = new java.awt.dnd.DropTargetListener() 294 294 { public void dragEnter( java.awt.dnd.DropTargetDragEvent evt ) 295 { log( out, "FileDrop: dragEnter event." ); 296 297 // Is this an acceptable drag event? 298 if( isDragOk( out, evt ) ) 299 { 300 // If it's a Swing component, set its border 301 if( c instanceof javax.swing.JComponent ) 302 { javax.swing.JComponent jc = (javax.swing.JComponent) c; 303 normalBorder = jc.getBorder(); 304 log( out, "FileDrop: normal border saved." ); 305 jc.setBorder( dragBorder ); 306 log( out, "FileDrop: drag border set." ); 307 } // end if: JComponent 308 309 // Acknowledge that it's okay to enter 310 //evt.acceptDrag( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE ); 311 evt.acceptDrag( java.awt.dnd.DnDConstants.ACTION_COPY ); 312 log( out, "FileDrop: event accepted." ); 313 } // end if: drag ok 314 else 315 { // Reject the drag event 316 evt.rejectDrag(); 317 log( out, "FileDrop: event rejected." ); 318 } // end else: drag not ok 319 } // end dragEnter 320 321 public void dragOver( java.awt.dnd.DropTargetDragEvent evt ) 322 { // This is called continually as long as the mouse is 323 // over the drag target. 324 } // end dragOver 325 326 public void drop( java.awt.dnd.DropTargetDropEvent evt ) 327 { log( out, "FileDrop: drop event." ); 328 try 329 { // Get whatever was dropped 330 java.awt.datatransfer.Transferable tr = evt.getTransferable(); 331 332 // Is it a file list? 333 if (tr.isDataFlavorSupported (java.awt.datatransfer.DataFlavor.javaFileListFlavor)) 334 { 295 { log( out, "FileDrop: dragEnter event." ); 296 297 // Is this an acceptable drag event? 298 if( isDragOk( out, evt ) ) 299 { 300 // If it's a Swing component, set its border 301 if( c instanceof javax.swing.JComponent ) 302 { javax.swing.JComponent jc = (javax.swing.JComponent) c; 303 normalBorder = jc.getBorder(); 304 log( out, "FileDrop: normal border saved." ); 305 jc.setBorder( dragBorder ); 306 log( out, "FileDrop: drag border set." ); 307 } // end if: JComponent 308 309 // Acknowledge that it's okay to enter 310 //evt.acceptDrag( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE ); 311 evt.acceptDrag( java.awt.dnd.DnDConstants.ACTION_COPY ); 312 log( out, "FileDrop: event accepted." ); 313 } // end if: drag ok 314 else 315 { // Reject the drag event 316 evt.rejectDrag(); 317 log( out, "FileDrop: event rejected." ); 318 } // end else: drag not ok 319 } // end dragEnter 320 321 public void dragOver( java.awt.dnd.DropTargetDragEvent evt ) 322 { // This is called continually as long as the mouse is 323 // over the drag target. 324 } // end dragOver 325 326 public void drop( java.awt.dnd.DropTargetDropEvent evt ) 327 { log( out, "FileDrop: drop event." ); 328 try 329 { // Get whatever was dropped 330 java.awt.datatransfer.Transferable tr = evt.getTransferable(); 331 332 // Is it a file list? 333 if (tr.isDataFlavorSupported (java.awt.datatransfer.DataFlavor.javaFileListFlavor)) 334 { 335 // Say we'll take it. 336 //evt.acceptDrop ( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE ); 337 evt.acceptDrop ( java.awt.dnd.DnDConstants.ACTION_COPY ); 338 log( out, "FileDrop: file list accepted." ); 339 340 // Get a useful list 341 java.util.List<Object> fileList = (java.util.List<Object>) 342 tr.getTransferData(java.awt.datatransfer.DataFlavor.javaFileListFlavor); 343 344 // Convert list to array 345 java.io.File[] filesTemp = new java.io.File[ fileList.size() ]; 346 fileList.toArray( filesTemp ); 347 final java.io.File[] files = filesTemp; 348 349 // Alert listener to drop. 350 if( listener != null ) { 351 listener.filesDropped( files ); 352 } 353 354 // Mark that drop is completed. 355 evt.getDropTargetContext().dropComplete(true); 356 log( out, "FileDrop: drop complete." ); 357 } // end if: file list 358 else // this section will check for a reader flavor. 359 { 360 // Thanks, Nathan! 361 // BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 362 DataFlavor[] flavors = tr.getTransferDataFlavors(); 363 boolean handled = false; 364 for (int zz = 0; zz < flavors.length; zz++) { 365 if (flavors[zz].isRepresentationClassReader()) { 335 366 // Say we'll take it. 336 367 //evt.acceptDrop ( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE ); 337 evt.acceptDrop ( java.awt.dnd.DnDConstants.ACTION_COPY ); 338 log( out, "FileDrop: file list accepted." ); 339 340 // Get a useful list 341 java.util.List fileList = (java.util.List) 342 tr.getTransferData(java.awt.datatransfer.DataFlavor.javaFileListFlavor); 343 java.util.Iterator iterator = fileList.iterator(); 344 345 // Convert list to array 346 java.io.File[] filesTemp = new java.io.File[ fileList.size() ]; 347 fileList.toArray( filesTemp ); 348 final java.io.File[] files = filesTemp; 349 350 // Alert listener to drop. 351 if( listener != null ) 352 listener.filesDropped( files ); 368 evt.acceptDrop(java.awt.dnd.DnDConstants.ACTION_COPY); 369 log(out, "FileDrop: reader accepted."); 370 371 Reader reader = flavors[zz].getReaderForText(tr); 372 373 BufferedReader br = new BufferedReader(reader); 374 375 if(listener != null) { 376 listener.filesDropped(createFileArray(br, out)); 377 } 353 378 354 379 // Mark that drop is completed. 355 380 evt.getDropTargetContext().dropComplete(true); 356 log( out, "FileDrop: drop complete." ); 357 } // end if: file list 358 else // this section will check for a reader flavor. 359 { 360 // Thanks, Nathan! 361 // BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 362 DataFlavor[] flavors = tr.getTransferDataFlavors(); 363 boolean handled = false; 364 for (int zz = 0; zz < flavors.length; zz++) { 365 if (flavors[zz].isRepresentationClassReader()) { 366 // Say we'll take it. 367 //evt.acceptDrop ( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE ); 368 evt.acceptDrop(java.awt.dnd.DnDConstants.ACTION_COPY); 369 log(out, "FileDrop: reader accepted."); 370 371 Reader reader = flavors[zz].getReaderForText(tr); 372 373 BufferedReader br = new BufferedReader(reader); 374 375 if(listener != null) 376 listener.filesDropped(createFileArray(br, out)); 377 378 // Mark that drop is completed. 379 evt.getDropTargetContext().dropComplete(true); 380 log(out, "FileDrop: drop complete."); 381 handled = true; 382 break; 383 } 384 } 385 if(!handled){ 386 log( out, "FileDrop: not a file list or reader - abort." ); 387 evt.rejectDrop(); 388 } 389 // END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 390 } // end else: not a file list 391 } // end try 392 catch ( java.io.IOException io) 393 { log( out, "FileDrop: IOException - abort:" ); 394 io.printStackTrace( out ); 381 log(out, "FileDrop: drop complete."); 382 handled = true; 383 break; 384 } 385 } 386 if(!handled){ 387 log( out, "FileDrop: not a file list or reader - abort." ); 395 388 evt.rejectDrop(); 396 } // end catch IOException 397 catch (java.awt.datatransfer.UnsupportedFlavorException ufe) 398 { log( out, "FileDrop: UnsupportedFlavorException - abort:" ); 399 ufe.printStackTrace( out ); 400 evt.rejectDrop(); 401 } // end catch: UnsupportedFlavorException 402 finally 403 { 404 // If it's a Swing component, reset its border 405 if( c instanceof javax.swing.JComponent ) 406 { javax.swing.JComponent jc = (javax.swing.JComponent) c; 407 jc.setBorder( normalBorder ); 408 log( out, "FileDrop: normal border restored." ); 409 } // end if: JComponent 410 } // end finally 411 } // end drop 412 413 public void dragExit( java.awt.dnd.DropTargetEvent evt ) 414 { log( out, "FileDrop: dragExit event." ); 415 // If it's a Swing component, reset its border 416 if( c instanceof javax.swing.JComponent ) 417 { javax.swing.JComponent jc = (javax.swing.JComponent) c; 418 jc.setBorder( normalBorder ); 419 log( out, "FileDrop: normal border restored." ); 420 } // end if: JComponent 421 } // end dragExit 422 423 public void dropActionChanged( java.awt.dnd.DropTargetDragEvent evt ) 424 { log( out, "FileDrop: dropActionChanged event." ); 425 // Is this an acceptable drag event? 426 if( isDragOk( out, evt ) ) 427 { //evt.acceptDrag( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE ); 428 evt.acceptDrag( java.awt.dnd.DnDConstants.ACTION_COPY ); 429 log( out, "FileDrop: event accepted." ); 430 } // end if: drag ok 431 else 432 { evt.rejectDrag(); 433 log( out, "FileDrop: event rejected." ); 434 } // end else: drag not ok 435 } // end dropActionChanged 389 } 390 // END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 391 } // end else: not a file list 392 } // end try 393 catch ( java.io.IOException io) 394 { log( out, "FileDrop: IOException - abort:" ); 395 io.printStackTrace( out ); 396 evt.rejectDrop(); 397 } // end catch IOException 398 catch (java.awt.datatransfer.UnsupportedFlavorException ufe) 399 { log( out, "FileDrop: UnsupportedFlavorException - abort:" ); 400 ufe.printStackTrace( out ); 401 evt.rejectDrop(); 402 } // end catch: UnsupportedFlavorException 403 finally 404 { 405 // If it's a Swing component, reset its border 406 if( c instanceof javax.swing.JComponent ) 407 { javax.swing.JComponent jc = (javax.swing.JComponent) c; 408 jc.setBorder( normalBorder ); 409 log( out, "FileDrop: normal border restored." ); 410 } // end if: JComponent 411 } // end finally 412 } // end drop 413 414 public void dragExit( java.awt.dnd.DropTargetEvent evt ) 415 { log( out, "FileDrop: dragExit event." ); 416 // If it's a Swing component, reset its border 417 if( c instanceof javax.swing.JComponent ) 418 { javax.swing.JComponent jc = (javax.swing.JComponent) c; 419 jc.setBorder( normalBorder ); 420 log( out, "FileDrop: normal border restored." ); 421 } // end if: JComponent 422 } // end dragExit 423 424 public void dropActionChanged( java.awt.dnd.DropTargetDragEvent evt ) 425 { log( out, "FileDrop: dropActionChanged event." ); 426 // Is this an acceptable drag event? 427 if( isDragOk( out, evt ) ) 428 { //evt.acceptDrag( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE ); 429 evt.acceptDrag( java.awt.dnd.DnDConstants.ACTION_COPY ); 430 log( out, "FileDrop: event accepted." ); 431 } // end if: drag ok 432 else 433 { evt.rejectDrag(); 434 log( out, "FileDrop: event rejected." ); 435 } // end else: drag not ok 436 } // end dropActionChanged 436 437 }; // end DropTargetListener 437 438 … … 444 445 } // end constructor 445 446 446 447 447 448 private static boolean supportsDnD() 448 449 { // Static Boolean 449 450 if( supportsDnD == null ) 450 { 451 { 451 452 boolean support = false; 452 453 try 453 454 { Class arbitraryDndClass = Class.forName( "java.awt.dnd.DnDConstants" ); 454 455 support = true; 455 456 } // end try 456 457 catch( Exception e ) … … 461 462 return supportsDnD.booleanValue(); 462 463 } // end supportsDnD 463 464 465 466 467 468 469 try { 470 java.util.List list = new java.util.ArrayList();464 465 466 // BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 467 private static String ZERO_CHAR_STRING = "" + (char)0; 468 private static File[] createFileArray(BufferedReader bReader, PrintStream out) 469 { 470 try { 471 java.util.List<File> list = new java.util.ArrayList<File>(); 471 472 java.lang.String line = null; 472 473 while ((line = bReader.readLine()) != null) { 473 474 try { 474 475 // kde seems to append a 0 char to the end of the reader 475 if(ZERO_CHAR_STRING.equals(line)) continue; 476 476 if(ZERO_CHAR_STRING.equals(line)) { 477 continue; 478 } 479 477 480 java.io.File file = new java.io.File(new java.net.URI(line)); 478 481 list.add(file); … … 482 485 } 483 486 484 return (java.io.File[])list.toArray(new File[list.size()]);487 return list.toArray(new File[list.size()]); 485 488 } catch (IOException ex) { 486 489 log(out, "FileDrop: IOException"); 487 490 } 488 491 return new File[0]; 489 490 491 492 492 } 493 // END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 494 495 493 496 private void makeDropTarget( final java.io.PrintStream out, final java.awt.Component c, boolean recursive ) 494 497 { … … 500 503 catch( java.util.TooManyListenersException e ) 501 504 { e.printStackTrace(); 502 505 log(out, "FileDrop: Drop will not work due to previous error. Do you have another listener attached?" ); 503 506 } // end catch 504 507 505 508 // Listen for hierarchy changes and remove the drop target when the parent gets cleared out. 506 509 c.addHierarchyListener( new java.awt.event.HierarchyListener() 507 510 { public void hierarchyChanged( java.awt.event.HierarchyEvent evt ) 508 509 510 511 512 513 514 515 516 517 518 511 { log( out, "FileDrop: Hierarchy changed." ); 512 java.awt.Component parent = c.getParent(); 513 if( parent == null ) 514 { c.setDropTarget( null ); 515 log( out, "FileDrop: Drop target cleared from component." ); 516 } // end if: null parent 517 else 518 { new java.awt.dnd.DropTarget(c, dropListener); 519 log( out, "FileDrop: Drop target added to component." ); 520 } // end else: parent not null 521 } // end hierarchyChanged 519 522 }); // end hierarchy listener 520 if( c.getParent() != null ) 523 if( c.getParent() != null ) { 521 524 new java.awt.dnd.DropTarget(c, dropListener); 522 525 } 526 523 527 if( recursive && (c instanceof java.awt.Container ) ) 524 { 528 { 525 529 // Get the container 526 530 java.awt.Container cont = (java.awt.Container) c; 527 531 528 532 // Get it's components 529 533 java.awt.Component[] comps = cont.getComponents(); 530 534 531 535 // Set it's components as listeners also 532 for( int i = 0; i < comps.length; i++ ) 536 for( int i = 0; i < comps.length; i++ ) { 533 537 makeDropTarget( out, comps[i], recursive ); 538 } 534 539 } // end if: recursively set components as listener 535 540 } // end dropListener 536 537 538 541 542 543 539 544 /** Determine if the dragged data is a file list. */ 540 545 private boolean isDragOk( final java.io.PrintStream out, final java.awt.dnd.DropTargetDragEvent evt ) 541 546 { boolean ok = false; 542 543 544 545 546 547 548 549 {550 551 552 553 547 548 // Get data flavors being dragged 549 java.awt.datatransfer.DataFlavor[] flavors = evt.getCurrentDataFlavors(); 550 551 // See if any of the flavors are a file list 552 int i = 0; 553 while( !ok && i < flavors.length ) 554 { 555 // BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 556 // Is the flavor a file list? 557 final DataFlavor curFlavor = flavors[i]; 558 if( curFlavor.equals( java.awt.datatransfer.DataFlavor.javaFileListFlavor ) || 554 559 curFlavor.isRepresentationClassReader()){ 555 ok = true; 556 } 557 // END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 558 i++; 559 } // end while: through flavors 560 561 // If logging is enabled, show data flavors 562 if( out != null ) 563 { if( flavors.length == 0 ) 564 log( out, "FileDrop: no data flavors." ); 565 for( i = 0; i < flavors.length; i++ ) 566 log( out, flavors[i].toString() ); 567 } // end if: logging enabled 568 569 return ok; 560 ok = true; 561 } 562 // END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 563 i++; 564 } // end while: through flavors 565 566 // If logging is enabled, show data flavors 567 if( out != null ) 568 { if( flavors.length == 0 ) { 569 log( out, "FileDrop: no data flavors." ); 570 } 571 for( i = 0; i < flavors.length; i++ ) { 572 log( out, flavors[i].toString() ); 573 } 574 } // end if: logging enabled 575 576 return ok; 570 577 } // end isDragOk 571 572 578 579 573 580 /** Outputs <tt>message</tt> to <tt>out</tt> if it's not null. */ 574 581 private static void log( java.io.PrintStream out, String message ) 575 582 { // Log message if requested 576 if( out != null ) 583 if( out != null ) { 577 584 out.println( message ); 585 } 578 586 } // end log 579 587 580 581 582 588 589 590 583 591 /** 584 592 * Removes the drag-and-drop hooks from the component and optionally … … 594 602 { return remove( null, c, true ); 595 603 } // end remove 596 597 598 604 605 606 599 607 /** 600 608 * Removes the drag-and-drop hooks from the component and optionally … … 611 619 if( supportsDnD() ) 612 620 { log( out, "FileDrop: Removing drag-and-drop hooks." ); 613 c.setDropTarget( null ); 614 if( recursive && ( c instanceof java.awt.Container ) ) 615 { java.awt.Component[] comps = ((java.awt.Container)c).getComponents(); 616 for( int i = 0; i < comps.length; i++ ) 617 remove( out, comps[i], recursive ); 618 return true; 619 } // end if: recursive 620 else return false; 621 c.setDropTarget( null ); 622 if( recursive && ( c instanceof java.awt.Container ) ) 623 { java.awt.Component[] comps = ((java.awt.Container)c).getComponents(); 624 for( int i = 0; i < comps.length; i++ ) { 625 remove( out, comps[i], recursive ); 626 } 627 return true; 628 } // end if: recursive 629 else return false; 621 630 } // end if: supports DnD 622 631 else return false; 623 632 } // end remove 624 625 626 627 628 /* ******** I N N E R I N T E R F A C E L I S T E N E R ******** */ 629 630 633 634 635 636 637 /* ******** I N N E R I N T E R F A C E L I S T E N E R ******** */ 638 639 631 640 /** 632 641 * Implement this inner interface to listen for when files are dropped. For example … … 645 654 */ 646 655 public static interface Listener { 647 656 648 657 /** 649 658 * This method is called when files have been successfully dropped. … … 653 662 */ 654 663 public abstract void filesDropped( java.io.File[] files ); 655 656 664 665 657 666 } // end inner-interface Listener 658 659 660 /* ******** I N N E R C L A S S ******** */ 661 662 667 668 669 /* ******** I N N E R C L A S S ******** */ 670 671 663 672 /** 664 673 * This is the event that is passed to the … … 701 710 return files; 702 711 } // end getFiles 703 712 704 713 } // end inner class Event 705 706 707 708 /* ******** I N N E R C L A S S ******** */709 714 715 716 717 /* ******** I N N E R C L A S S ******** */ 718 710 719 711 720 /** … … 737 746 * </code></pre> 738 747 * 739 * The {@link java.awt.datatransfer.DataFlavor} associated with 748 * The {@link java.awt.datatransfer.DataFlavor} associated with 740 749 * {@link TransferableObject} has the representation class 741 750 * <tt>net.iharder.dnd.TransferableObject.class</tt> and MIME type … … 754 763 { 755 764 /** 756 * The MIME type for {@link #DATA_FLAVOR} is 765 * The MIME type for {@link #DATA_FLAVOR} is 757 766 * <tt>application/x-net.iharder.dnd.TransferableObject</tt>. 758 767 * … … 766 775 * {@link TransferableObject} has the representation class 767 776 * <tt>net.iharder.dnd.TransferableObject.class</tt> 768 * and the MIME type 777 * and the MIME type 769 778 * <tt>application/x-net.iharder.dnd.TransferableObject</tt>. 770 779 * 771 780 * @since 1.1 772 781 */ 773 public final static java.awt.datatransfer.DataFlavor DATA_FLAVOR = 782 public final static java.awt.datatransfer.DataFlavor DATA_FLAVOR = 774 783 new java.awt.datatransfer.DataFlavor( FileDrop.TransferableObject.class, MIME_TYPE ); 775 784 … … 778 787 private Object data; 779 788 780 private java.awt.datatransfer.DataFlavor customFlavor; 789 private java.awt.datatransfer.DataFlavor customFlavor; 781 790 782 791 … … 785 794 * Creates a new {@link TransferableObject} that wraps <var>data</var>. 786 795 * Along with the {@link #DATA_FLAVOR} associated with this class, 787 * this creates a custom data flavor with a representation class 796 * this creates a custom data flavor with a representation class 788 797 * determined from <code>data.getClass()</code> and the MIME type 789 798 * <tt>application/x-net.iharder.dnd.TransferableObject</tt>. … … 794 803 public TransferableObject( Object data ) 795 804 { this.data = data; 796 805 this.customFlavor = new java.awt.datatransfer.DataFlavor( data.getClass(), MIME_TYPE ); 797 806 } // end constructor 798 807 … … 830 839 public TransferableObject( Class dataClass, Fetcher fetcher ) 831 840 { this.fetcher = fetcher; 832 841 this.customFlavor = new java.awt.datatransfer.DataFlavor( dataClass, MIME_TYPE ); 833 842 } // end constructor 834 843 … … 846 855 847 856 848 /* ******** T R A N S F E R A B L E M E T H O D S ******** */857 /* ******** T R A N S F E R A B L E M E T H O D S ******** */ 849 858 850 859 … … 859 868 * @since 1.1 860 869 */ 861 public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors() 862 { 870 public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors() 871 { 863 872 if( customFlavor != null ) 864 873 return new java.awt.datatransfer.DataFlavor[] 865 { customFlavor,874 { customFlavor, 866 875 DATA_FLAVOR, 867 876 java.awt.datatransfer.DataFlavor.stringFlavor 868 }; // end flavors array877 }; // end flavors array 869 878 else 870 879 return new java.awt.datatransfer.DataFlavor[] 871 { DATA_FLAVOR,880 { DATA_FLAVOR, 872 881 java.awt.datatransfer.DataFlavor.stringFlavor 873 }; // end flavors array882 }; // end flavors array 874 883 } // end getTransferDataFlavors 875 884 … … 888 897 */ 889 898 public Object getTransferData( java.awt.datatransfer.DataFlavor flavor ) 890 throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException 891 { 899 throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException 900 { 892 901 // Native object 893 902 if( flavor.equals( DATA_FLAVOR ) ) … … 898 907 return fetcher == null ? data.toString() : fetcher.getObject().toString(); 899 908 900 // We can't do anything else901 throw new java.awt.datatransfer.UnsupportedFlavorException(flavor);909 // We can't do anything else 910 throw new java.awt.datatransfer.UnsupportedFlavorException(flavor); 902 911 } // end getTransferData 903 912 … … 913 922 * @since 1.1 914 923 */ 915 public boolean isDataFlavorSupported( java.awt.datatransfer.DataFlavor flavor ) 924 public boolean isDataFlavorSupported( java.awt.datatransfer.DataFlavor flavor ) 916 925 { 917 926 // Native object … … 928 937 929 938 930 /* ******** I N N E R I N T E R F A C E F E T C H E R ******** */939 /* ******** I N N E R I N T E R F A C E F E T C H E R ******** */ 931 940 932 941 /** … … 959 968 } // end class TransferableObject 960 969 961 962 963 964 970 971 972 973 965 974 } // end class FileDrop -
trunk/src/org/openstreetmap/josm/gui/SelectionManager.java
r1910 r1911 145 145 */ 146 146 public void mousePressed(MouseEvent e) { 147 if (e.getButton() == MouseEvent.BUTTON1) 147 if (e.getButton() == MouseEvent.BUTTON1) { 148 148 mousePosStart = mousePos = e.getPoint(); 149 } 149 150 } 150 151 … … 157 158 158 159 if (buttonPressed != 0) { 159 if (mousePosStart == null) 160 if (mousePosStart == null) { 160 161 mousePosStart = mousePos = e.getPoint(); 162 } 161 163 paintRect(); 162 164 } … … 191 193 boolean alt = (e.getModifiersEx() & MouseEvent.ALT_DOWN_MASK) != 0; 192 194 boolean ctrl = (e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0; 193 if ((e.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) == 0) 195 if ((e.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) == 0) { 194 196 selectionEndedListener.selectionEnded(r, alt, shift, ctrl); 197 } 195 198 } 196 199 … … 235 238 if ((double)w/h < aspectRatio) { 236 239 int neww = (int)(h*aspectRatio); 237 if (mousePos.x < mousePosStart.x) 240 if (mousePos.x < mousePosStart.x) { 238 241 x += w - neww; 242 } 239 243 w = neww; 240 244 } else { 241 245 int newh = (int)(w/aspectRatio); 242 if (mousePos.y < mousePosStart.y) 246 if (mousePos.y < mousePosStart.y) { 243 247 y += h - newh; 248 } 244 249 h = newh; 245 250 } … … 275 280 if (clicked) { 276 281 OsmPrimitive osm = nc.getNearest(center); 277 if (osm != null) 282 if (osm != null) { 278 283 selection.add(osm); 284 } 279 285 } else { 280 286 // nodes 281 287 for (Node n : nc.getCurrentDataSet().nodes) { 282 if (!n.deleted && !n.incomplete && r.contains(nc.getPoint(n))) 288 if (!n.deleted && !n.incomplete && r.contains(nc.getPoint(n))) { 283 289 selection.add(n); 290 } 284 291 } 285 292 286 293 // ways 287 294 for (Way w : nc.getCurrentDataSet().ways) { 288 if (w.deleted || w.getNodesCount() == 0 || w.incomplete) 289 continue; 295 if (w.deleted || w.getNodesCount() == 0 || w.incomplete) { 296 continue; 297 } 290 298 if (alt) { 291 299 for (Node n : w.getNodes()) { … … 303 311 } 304 312 } 305 if (allIn) selection.add(w); 313 if (allIn) { 314 selection.add(w); 315 } 306 316 } 307 317 } -
trunk/src/org/openstreetmap/josm/gui/conflict/nodes/NodeListTableCellRenderer.java
r1790 r1911 167 167 reset(); 168 168 switch(column) { 169 case 0:170 renderRowId(getModel(table),row, isSelected);171 break;172 case 1:173 if (node == null) {174 renderEmptyRow();175 } else {176 renderNode(getModel(table), node, row, isSelected);177 }178 break;179 default:180 // should not happen181 throw new RuntimeException(tr("unexpected column index. Got {0}", column));169 case 0: 170 renderRowId(getModel(table),row, isSelected); 171 break; 172 case 1: 173 if (node == null) { 174 renderEmptyRow(); 175 } else { 176 renderNode(getModel(table), node, row, isSelected); 177 } 178 break; 179 default: 180 // should not happen 181 throw new RuntimeException(tr("unexpected column index. Got {0}", column)); 182 182 } 183 183 return this; … … 189 189 * @return the table model 190 190 */ 191 @SuppressWarnings("unchecked") 191 192 protected ListMergeModel<Node>.EntriesTableModel getModel(JTable table) { 192 193 return (ListMergeModel.EntriesTableModel)table.getModel(); -
trunk/src/org/openstreetmap/josm/gui/conflict/relation/RelationMemberTableCellRenderer.java
r1790 r1911 198 198 renderForeground(getModel(table), member, row, column, isSelected); 199 199 switch(column) { 200 case 0:201 renderRowId(row);202 break;203 case 1:204 if (member == null) {205 renderEmptyRow();206 } else {207 renderRole(member);208 }209 break;210 case 2:211 if (member == null) {212 renderEmptyRow();213 } else {214 renderPrimitive(member);215 }216 break;217 default:218 // should not happen200 case 0: 201 renderRowId(row); 202 break; 203 case 1: 204 if (member == null) { 205 renderEmptyRow(); 206 } else { 207 renderRole(member); 208 } 209 break; 210 case 2: 211 if (member == null) { 212 renderEmptyRow(); 213 } else { 214 renderPrimitive(member); 215 } 216 break; 217 default: 218 // should not happen 219 219 } 220 220 return this; … … 226 226 * @return the table model 227 227 */ 228 @SuppressWarnings("unchecked") 228 229 protected ListMergeModel<Node>.EntriesTableModel getModel(JTable table) { 229 230 return (ListMergeModel.EntriesTableModel)table.getModel(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r1896 r1911 32 32 import javax.swing.ListModel; 33 33 import javax.swing.ListSelectionModel; 34 import javax.swing.SwingUtilities;35 34 import javax.swing.UIManager; 36 35 import javax.swing.event.ListDataEvent; … … 314 313 ); 315 314 switch(ret) { 316 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return DeleteDecision.deleteAll;317 case JOptionPane.CLOSED_OPTION: return DeleteDecision.cancel;318 case 0: return DeleteDecision.deleteCurrent;319 case 1: return DeleteDecision.dontDeleteCurrent;320 case 2: return DeleteDecision.deleteAll;321 case 3: return DeleteDecision.cancel;322 default:323 // shouldn't happen. This is the safest option.324 return DeleteDecision.cancel;315 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return DeleteDecision.deleteAll; 316 case JOptionPane.CLOSED_OPTION: return DeleteDecision.cancel; 317 case 0: return DeleteDecision.deleteCurrent; 318 case 1: return DeleteDecision.dontDeleteCurrent; 319 case 2: return DeleteDecision.deleteAll; 320 case 3: return DeleteDecision.cancel; 321 default: 322 // shouldn't happen. This is the safest option. 323 return DeleteDecision.cancel; 325 324 } 326 325 } … … 360 359 DeleteDecision decision = confirmDeleteMultipleLayer(layer, i, layers.size()); 361 360 switch(decision) { 362 case deleteCurrent: /* do nothing */ break;363 case deleteAll: doAskConfirmation = false; break;364 case dontDeleteCurrent: continue;365 case cancel: return;361 case deleteCurrent: /* do nothing */ break; 362 case deleteAll: doAskConfirmation = false; break; 363 case dontDeleteCurrent: continue; 364 case cancel: return; 366 365 } 367 366 } … … 674 673 public class LayerListModel extends DefaultListModel implements LayerChangeListener, PropertyChangeListener{ 675 674 676 / /private ArrayList<Layer> layers;675 /** manages list selection state*/ 677 676 private DefaultListSelectionModel selectionModel; 678 677 private CopyOnWriteArrayList<LayerListModelListener> listeners; 679 678 679 /** 680 * constructor 681 * 682 * @param selectionModel the list selection model 683 */ 680 684 private LayerListModel(DefaultListSelectionModel selectionModel) { 681 685 this.selectionModel = selectionModel; … … 683 687 } 684 688 689 /** 690 * Adds a listener to this model 691 * 692 * @param listener the listener 693 */ 685 694 public void addLayerListModelListener(LayerListModelListener listener) { 686 695 synchronized(listeners) { … … 691 700 } 692 701 702 /** 703 * removes a listener from this model 704 * @param listener the listener 705 * 706 */ 693 707 public void removeLayerListModelListener(LayerListModelListener listener) { 694 708 synchronized(listeners) { … … 699 713 } 700 714 715 /** 716 * Fires a make visible event to listeners 717 * 718 * @param index the index of the row to make visible 719 * @param layer the layer at this index 720 * @see LayerListModelListener#makeVisible(int, Layer) 721 */ 701 722 protected void fireMakeVisible(int index, Layer layer) { 702 723 for (LayerListModelListener listener : listeners) { … … 705 726 } 706 727 728 /** 729 * Fires a refresh event to listeners of this model 730 * 731 * @see LayerListModelListener#refresh() 732 */ 707 733 protected void fireRefresh() { 708 734 for (LayerListModelListener listener : listeners) { … … 711 737 } 712 738 739 /** 740 * Populates the model with the current layers managed by 741 * {@see MapView}. 742 * 743 */ 713 744 public void populate() { 714 if (getLayers() != null) { 715 for (Layer layer: getLayers()) { 716 // make sure the model is registered exactly once 717 // 718 layer.removePropertyChangeListener(this); 719 layer.addPropertyChangeListener(this); 720 } 745 for (Layer layer: getLayers()) { 746 // make sure the model is registered exactly once 747 // 748 layer.removePropertyChangeListener(this); 749 layer.addPropertyChangeListener(this); 721 750 } 722 751 fireContentsChanged(this, 0, getSize()); 723 752 } 724 753 754 /** 755 * Marks <code>layer</code> as selected layer. Ignored, if 756 * layer is null. 757 * 758 * @param layer the layer. 759 */ 725 760 public void setSelectedLayer(Layer layer) { 726 if (layer == null || getLayers() == null)761 if (layer == null) 727 762 return; 728 763 int idx = getLayers().indexOf(layer); … … 734 769 } 735 770 771 /** 772 * Replies the list of currently selected layers. Never null, but may 773 * be empty. 774 * 775 * @return the list of currently selected layers. Never null, but may 776 * be empty. 777 */ 736 778 public List<Layer> getSelectedLayers() { 737 779 ArrayList<Layer> selected = new ArrayList<Layer>(); 738 if (getLayers() == null) return selected;739 780 for (int i=0; i<getLayers().size(); i++) { 740 781 if (selectionModel.isSelectedIndex(i)) { … … 745 786 } 746 787 788 /** 789 * Replies a the list of indices of the selected rows. Never null, 790 * but may be empty. 791 * 792 * @return the list of indices of the selected rows. Never null, 793 * but may be empty. 794 */ 747 795 public List<Integer> getSelectedRows() { 748 796 ArrayList<Integer> selected = new ArrayList<Integer>(); 749 if (getLayers() == null) return selected;750 797 for (int i=0; i<getLayers().size();i++) { 751 798 if (selectionModel.isSelectedIndex(i)) { … … 756 803 } 757 804 758 protected void removeLayer(Layer layer) { 805 /** 806 * Invoked if a layer managed by {@see MapView} is removed 807 * 808 * @param layer the layer which is removed 809 */ 810 protected void onRemoveLayer(Layer layer) { 759 811 if (layer == null) 760 812 return; 813 int size = getSize(); 814 List<Integer> rows = getSelectedRows(); 815 if (rows.isEmpty() && size > 0) { 816 selectionModel.setSelectionInterval(size-1, size-1); 817 } 761 818 fireRefresh(); 762 819 ensureSelectedIsVisible(); 763 820 } 764 821 765 protected void addLayer(Layer layer) { 822 /** 823 * Invoked when a layer managed by {@see MapView} is added 824 * 825 * @param layer the layer 826 */ 827 protected void onAddLayer(Layer layer) { 766 828 if (layer == null) return; 767 829 layer.addPropertyChangeListener(this); … … 769 831 } 770 832 833 /** 834 * Replies the first layer. Null if no layers are present 835 * 836 * @return the first layer. Null if no layers are present 837 */ 771 838 public Layer getFirstLayer() { 772 839 if (getSize() == 0) return null; … … 774 841 } 775 842 843 /** 844 * Replies the layer at position <code>index</code> 845 * 846 * @param index the index 847 * @return the layer at position <code>index</code>. Null, 848 * if index is out of range. 849 */ 776 850 public Layer getLayer(int index) { 777 851 if (index < 0 || index >= getSize()) … … 780 854 } 781 855 856 /** 857 * Replies true if the the currently selected layers can move up 858 * by one position 859 * 860 * @return true if the the currently selected layers can move up 861 * by one position 862 */ 782 863 public boolean canMoveUp() { 783 864 List<Integer> sel = getSelectedRows(); … … 785 866 } 786 867 868 /** 869 * Move up the currently selected layers by one position 870 * 871 */ 787 872 public void moveUp() { 788 873 if (!canMoveUp()) return; … … 802 887 } 803 888 889 /** 890 * Replies true if the currently selected layers can move down 891 * by one position 892 * 893 * @return true if the currently selected layers can move down 894 * by one position 895 */ 804 896 public boolean canMoveDown() { 805 897 List<Integer> sel = getSelectedRows(); … … 807 899 } 808 900 901 /** 902 * Move down the currently selected layers by one position 903 * 904 */ 809 905 public void moveDown() { 810 906 if (!canMoveDown()) return; … … 825 921 } 826 922 923 /** 924 * Make sure the first of the selected layers is visible in the 925 * views of this model. 926 * 927 */ 827 928 protected void ensureSelectedIsVisible() { 828 929 int index = selectionModel.getMinSelectionIndex(); 829 930 if (index <0 )return; 830 if (getLayers() == null) return;831 931 if (index >= getLayers().size()) return; 832 932 Layer layer = getLayers().get(index); … … 834 934 } 835 935 836 public List<Layer> getPossibleMergeTargets(Layer layer) { 936 /** 937 * Replies a list of layers which are possible merge targets 938 * for <code>source</code> 939 * 940 * @param source the source layer 941 * @return a list of layers which are possible merge targets 942 * for <code>source</code>. Never null, but can be empty. 943 */ 944 public List<Layer> getPossibleMergeTargets(Layer source) { 837 945 ArrayList<Layer> targets = new ArrayList<Layer>(); 838 if ( layer== null)946 if (source == null) 839 947 return targets; 840 948 for(Layer target: getLayers()) { 841 if ( layer== target) {949 if (source == target) { 842 950 continue; 843 951 } 844 if (target.isMergable( layer)) {952 if (target.isMergable(source)) { 845 953 targets.add(target); 846 954 } … … 849 957 } 850 958 959 /** 960 * Activates the layer <code>layer</code> 961 * 962 * @param layer the layer 963 */ 851 964 public void activateLayer(Layer layer) { 965 if (layer == null) 966 return; 852 967 Main.map.mapView.moveLayer(layer,0); 853 968 Main.map.mapView.setActiveLayer(layer); … … 857 972 } 858 973 974 /** 975 * Replies the list of layers currently managed by {@see MapView}. 976 * Never null, but can be empty. 977 * 978 * @return the list of layers currently managed by {@see MapView}. 979 * Never null, but can be empty. 980 */ 859 981 protected List<Layer> getLayers() { 860 if (Main.map == null ) return null;861 if (Main.map.mapView == null) return null;982 if (Main.map == null || Main.map.mapView == null) 983 return Collections.<Layer>emptyList(); 862 984 return Main.map.mapView.getAllLayersAsList(); 863 985 } … … 898 1020 899 1021 public void layerAdded(Layer newLayer) { 900 addLayer(newLayer);1022 onAddLayer(newLayer); 901 1023 } 902 1024 903 1025 public void layerRemoved(final Layer oldLayer) { 904 SwingUtilities.invokeLater( 905 new Runnable() { 906 public void run() { 907 removeLayer(oldLayer); 908 } 909 } 910 ); 911 } 912 1026 onRemoveLayer(oldLayer); 1027 } 913 1028 914 1029 /* ------------------------------------------------------------------------------ */ -
trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r1861 r1911 133 133 * @param row The row of the table from which the value is edited. 134 134 */ 135 @SuppressWarnings("unchecked") 135 136 void propertyEdit(int row) { 136 137 Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); … … 488 489 String str = null; 489 490 switch (column) { 490 case 0:491 str = (String) value;492 break;493 case 1:494 Map<String, Integer> v = (Map<String,Integer>) value;495 if (v.size()!=1) {496 str=tr("<different>");497 c.setFont(c.getFont().deriveFont(Font.ITALIC));498 } else {499 str=v.entrySet().iterator().next().getKey();500 }501 break;491 case 0: 492 str = (String) value; 493 break; 494 case 1: 495 Map<String, Integer> v = (Map<String,Integer>) value; 496 if (v.size()!=1) { 497 str=tr("<different>"); 498 c.setFont(c.getFont().deriveFont(Font.ITALIC)); 499 } else { 500 str=v.entrySet().iterator().next().getKey(); 501 } 502 break; 502 503 } 503 504 ((JLabel)c).setText(str); … … 524 525 525 526 membershipTable.getColumnModel().getColumn(1).setCellRenderer(new DefaultTableCellRenderer() { 527 @SuppressWarnings("unchecked") 526 528 @Override public Component getTableCellRendererComponent(JTable table, Object value, 527 529 boolean isSelected, boolean hasFocus, int row, int column) { -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java
r1724 r1911 70 70 71 71 public final void setCoor(LatLon coor) { 72 if(this.coor == null) 72 if(this.coor == null) { 73 73 this.coor = new CachedLatLon(coor); 74 else74 } else { 75 75 this.coor.setCoor(coor); 76 } 76 77 } 77 78 … … 98 99 static { 99 100 Marker.markerProducers.add(new MarkerProducers() { 101 @SuppressWarnings("unchecked") 100 102 public Marker createMarker(WayPoint wpt, File relativePath, MarkerLayer parentLayer, double time, double offset) { 101 103 String uri = null; … … 110 112 111 113 // Try a relative file:// url, if the link is not in an URL-compatible form 112 if (relativePath != null && uri != null && !isWellFormedAddress(uri)) 114 if (relativePath != null && uri != null && !isWellFormedAddress(uri)) { 113 115 uri = new File(relativePath.getParentFile(), uri).toURI().toString(); 116 } 114 117 115 118 String name_desc = ""; … … 147 150 this.time = time; 148 151 Icon symbol = ImageProvider.getIfAvailable("markers",iconName); 149 if (symbol == null) 152 if (symbol == null) { 150 153 symbol = ImageProvider.getIfAvailable("symbols",iconName); 151 if (symbol == null) 154 } 155 if (symbol == null) { 152 156 symbol = ImageProvider.getIfAvailable("nodes",iconName); 157 } 153 158 this.symbol = symbol; 154 159 this.parentLayer = parentLayer; … … 190 195 } 191 196 192 if ((text != null) && (show.equalsIgnoreCase("show"))) 197 if ((text != null) && (show.equalsIgnoreCase("show"))) { 193 198 g.drawString(text, screen.x+4, screen.y+2); 199 } 194 200 } 195 201 -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r1890 r1911 63 63 public GpxLayer fromLayer = null; 64 64 65 @SuppressWarnings("unchecked") 65 66 public MarkerLayer(GpxData indata, String name, File associatedFile, GpxLayer fromLayer) { 66 67
Note:
See TracChangeset
for help on using the changeset viewer.