- Timestamp:
- 2015-01-09T11:35:10+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
r7668 r7945 36 36 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationTask; 37 37 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 38 import org.openstreetmap.josm.gui.util.GuiHelper; 38 39 import org.openstreetmap.josm.tools.Pair; 39 40 import org.openstreetmap.josm.tools.Shortcut; … … 84 85 private final Relation multipolygonRelation; 85 86 86 p ublicCreateUpdateMultipolygonTask(Collection<Way> selectedWays, Relation multipolygonRelation) {87 private CreateUpdateMultipolygonTask(Collection<Way> selectedWays, Relation multipolygonRelation) { 87 88 this.selectedWays = selectedWays; 88 89 this.multipolygonRelation = multipolygonRelation; … … 140 141 final Collection<Relation> selectedRelations = Main.main.getCurrentDataSet().getSelectedRelations(); 141 142 142 if (selectedWays. size() < 1) {143 if (selectedWays.isEmpty()) { 143 144 // Sometimes it make sense creating multipoly of only one way (so it will form outer way) 144 145 // and then splitting the way later (so there are multiple ways forming outer way) … … 156 157 157 158 // download incomplete relation if necessary 158 if (multipolygonRelation != null && (multipolygonRelation.isIncomplete() || multipolygonRelation.hasIncompleteMembers())) { 159 if (multipolygonRelation != null && !multipolygonRelation.isNew() 160 && (multipolygonRelation.isIncomplete() || multipolygonRelation.hasIncompleteMembers())) { 159 161 Main.worker.submit(new DownloadRelationTask(Collections.singleton(multipolygonRelation), Main.main.getEditLayer())); 160 162 } 161 163 // create/update multipolygon relation 162 164 Main.worker.submit(new CreateUpdateMultipolygonTask(selectedWays, multipolygonRelation)); 163 164 165 } 165 166 … … 172 173 return selectedRelations.iterator().next(); 173 174 } else { 174 final HashSet<Relation> relatedRelations = new HashSet<>();175 final Set<Relation> relatedRelations = new HashSet<>(); 175 176 for (final Way w : selectedWays) { 176 177 relatedRelations.addAll(Utils.filteredCollection(w.getReferrers(), Relation.class)); … … 268 269 269 270 MultipolygonBuilder pol = new MultipolygonBuilder(); 270 String error = pol.makeFromWays(selectedWays);271 final String error = pol.makeFromWays(selectedWays); 271 272 272 273 if (error != null) { 273 274 if (showNotif) { 274 new Notification(error) 275 GuiHelper.runInEDT(new Runnable() { 276 @Override 277 public void run() { 278 new Notification(error) 275 279 .setIcon(JOptionPane.INFORMATION_MESSAGE) 276 280 .show(); 281 } 282 }); 277 283 } 278 284 return null; … … 303 309 private static void addMembers(JoinedPolygon polygon, Relation rel, String role) { 304 310 final int count = rel.getMembersCount(); 305 final HashSet<Way> ways = new HashSet<>(polygon.ways);311 final Set<Way> ways = new HashSet<>(polygon.ways); 306 312 for (int i = 0; i < count; i++) { 307 313 final RelationMember m = rel.getMember(i);
Note:
See TracChangeset
for help on using the changeset viewer.