Changeset 7534 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2014-09-14T17:11:14+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
r7052 r7534 48 48 49 49 /** 50 * Join Areas (i.e. closed ways and multipolygons) 50 * Join Areas (i.e. closed ways and multipolygons). 51 * @since 2575 51 52 */ 52 53 public class JoinAreasAction extends JosmAction { … … 57 58 58 59 /** 59 * This helper class describes join are s action result.60 * This helper class describes join areas action result. 60 61 * @author viesturs 61 *62 62 */ 63 63 public static class JoinAreasResult { … … 394 394 395 395 /** 396 * Gets called whenever the shortcut is pressed or the menu entry is selected 397 * Checks whether the selected objects are suitable to join and joins them if so 396 * Gets called whenever the shortcut is pressed or the menu entry is selected. 397 * Checks whether the selected objects are suitable to join and joins them if so. 398 398 */ 399 399 @Override 400 400 public void actionPerformed(ActionEvent e) { 401 LinkedList<Way> ways = new LinkedList<>(Main.main.getCurrentDataSet().getSelectedWays()); 401 join(Main.main.getCurrentDataSet().getSelectedWays()); 402 } 403 404 /** 405 * Joins the given ways. 406 * @param ways Ways to join 407 * @since 7534 408 */ 409 public void join(Collection<Way> ways) { 402 410 addedRelations.clear(); 403 411 … … 471 479 } 472 480 DataSet ds = Main.main.getCurrentDataSet(); 473 ds.setSelected(allWays); 474 Main.map.mapView.repaint(); 481 if (ds != null) { 482 ds.setSelected(allWays); 483 Main.map.mapView.repaint(); 484 } 475 485 } else { 476 486 new Notification( … … 479 489 .show(); 480 490 } 481 } 482 catch (UserCancelException exception) { 491 } catch (UserCancelException exception) { 483 492 //revert changes 484 493 //FIXME: this is dirty hack … … 915 924 /** 916 925 * This is a method splits way into smaller parts, using the prepared nodes list as split points. 917 * Uses SplitWayAction.splitWayfor the heavy lifting.926 * Uses {@link SplitWayAction#splitWay} for the heavy lifting. 918 927 * @return list of split ways (or original ways if no splitting is done). 919 928 */ … … 924 933 925 934 if (chunks.size() > 1) { 926 SplitWayResult split = SplitWayAction.splitWay( Main.main.getEditLayer(), way, chunks, Collections.<OsmPrimitive>emptyList());935 SplitWayResult split = SplitWayAction.splitWay(getEditLayer(), way, chunks, Collections.<OsmPrimitive>emptyList()); 927 936 928 937 //execute the command, we need the results … … 1254 1263 * @return list of polygons, or null if too complex relation encountered. 1255 1264 */ 1256 private List<Multipolygon> collectMultipolygons( List<Way> selectedWays) {1265 private List<Multipolygon> collectMultipolygons(Collection<Way> selectedWays) { 1257 1266 1258 1267 List<Multipolygon> result = new ArrayList<>(); … … 1380 1389 1381 1390 /** 1382 * Removes a given OsmPrimitive from all relations 1391 * Removes a given OsmPrimitive from all relations. 1383 1392 * @param osm Element to remove from all relations 1384 1393 * @return List of relations with roles the primitives was part of -
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r6890 r7534 84 84 putValue("toolbar", toolbarId); 85 85 } 86 if (registerInToolbar ) {86 if (registerInToolbar && Main.toolbar != null) { 87 87 Main.toolbar.register(this); 88 88 } … … 205 205 */ 206 206 protected static OsmDataLayer getEditLayer() { 207 return Main.main .getEditLayer();207 return Main.main != null ? Main.main.getEditLayer() : null; 208 208 } 209 209 … … 214 214 */ 215 215 protected static DataSet getCurrentDataSet() { 216 return Main.main .getCurrentDataSet();216 return Main.main != null ? Main.main.getCurrentDataSet() : null; 217 217 } 218 218 -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r7005 r7534 358 358 newWays.add(wayToAdd); 359 359 wayToAdd.setNodes(chunkIt.next()); 360 commandList.add(new AddCommand(layer, wayToAdd));360 commandList.add(new AddCommand(layer, wayToAdd)); 361 361 newSelection.add(wayToAdd); 362 363 362 } 364 363 boolean warnmerole = false; … … 381 380 if (rm.isWay() && rm.getMember() == way) { 382 381 boolean insert = true; 383 if ("restriction".equals(type)) 384 { 382 if ("restriction".equals(type)) { 385 383 /* this code assumes the restriction is correct. No real error checking done */ 386 384 String role = rm.getRole(); 387 if("from".equals(role) || "to".equals(role)) 388 { 385 if("from".equals(role) || "to".equals(role)) { 389 386 OsmPrimitive via = null; 390 387 for (RelationMember rmv : r.getMembers()) { 391 if ("via".equals(rmv.getRole())){388 if ("via".equals(rmv.getRole())){ 392 389 via = rmv.getMember(); 393 390 } 394 391 } 395 392 List<Node> nodes = new ArrayList<>(); 396 if (via != null) {397 if (via instanceof Node) {393 if (via != null) { 394 if (via instanceof Node) { 398 395 nodes.add((Node)via); 399 } else if (via instanceof Way) {396 } else if (via instanceof Way) { 400 397 nodes.add(((Way)via).lastNode()); 401 398 nodes.add(((Way)via).firstNode()); … … 403 400 } 404 401 Way res = null; 405 for (Node n : nodes) {402 for (Node n : nodes) { 406 403 if(changedWay.isFirstLastNode(n)) { 407 404 res = way; 408 405 } 409 406 } 410 if(res == null) 411 { 407 if (res == null) { 412 408 for (Way wayToAdd : newWays) { 413 409 for(Node n : nodes) { … … 417 413 } 418 414 } 419 if(res != null) 420 { 415 if (res != null) { 421 416 if (c == null) { 422 417 c = new Relation(r); … … 429 424 insert = false; 430 425 } 431 } 432 else if(!"via".equals(role)) { 426 } else if(!"via".equals(role)) { 433 427 warnme = true; 434 428 } 435 } 436 else if (!("route".equals(type)) && !("multipolygon".equals(type))) { 429 } else if (!("route".equals(type)) && !("multipolygon".equals(type))) { 437 430 warnme = true; 438 431 } … … 441 434 } 442 435 443 if(insert) 444 { 436 if (insert) { 445 437 if (rm.hasRole() && !nowarnroles.contains(rm.getRole())) { 446 438 warnmerole = true; … … 484 476 } 485 477 } 486 i_c++; i_r++; 478 i_c++; 479 i_r++; 487 480 } 488 481 489 482 if (c != null) { 490 commandList.add(new ChangeCommand(layer, r, c));483 commandList.add(new ChangeCommand(layer, r, c)); 491 484 } 492 485 } -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r7484 r7534 923 923 924 924 protected void refreshTitle() { 925 boolean dirty = editLayer != null && (editLayer.requiresSaveToFile() || (editLayer.requiresUploadToServer() && !editLayer.isUploadDiscouraged())); 926 ((JFrame) Main.parent).setTitle((dirty ? "* " : "") + tr("Java OpenStreetMap Editor")); 927 ((JFrame) Main.parent).getRootPane().putClientProperty("Window.documentModified", dirty); 925 if (Main.parent != null) { 926 boolean dirty = editLayer != null && 927 (editLayer.requiresSaveToFile() || (editLayer.requiresUploadToServer() && !editLayer.isUploadDiscouraged())); 928 ((JFrame) Main.parent).setTitle((dirty ? "* " : "") + tr("Java OpenStreetMap Editor")); 929 ((JFrame) Main.parent).getRootPane().putClientProperty("Window.documentModified", dirty); 930 } 928 931 } 929 932
Note:
See TracChangeset
for help on using the changeset viewer.