Changeset 32395 in osm for applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadChosenRelationAction.java
- Timestamp:
- 2016-06-24T09:10:57+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadChosenRelationAction.java
r30737 r32395 1 // License: GPL. For details, see LICENSE file. 1 2 package relcontext.actions; 2 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 import java.awt.event.ActionEvent; 5 7 import java.util.Collections; 6 8 import java.util.HashSet; 7 9 import java.util.Set; 10 8 11 import javax.swing.AbstractAction; 12 9 13 import org.openstreetmap.josm.Main; 10 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 14 18 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationTask; 15 19 import org.openstreetmap.josm.tools.ImageProvider; 20 16 21 import relcontext.ChosenRelation; 17 22 import relcontext.ChosenRelationListener; … … 19 24 /** 20 25 * Downloads or updates chosen relation members, depending on completeness. 21 * 26 * 22 27 * @author Zverik 23 28 */ … … 25 30 private ChosenRelation rel; 26 31 27 public DownloadChosenRelationAction( ChosenRelation rel) {32 public DownloadChosenRelationAction(ChosenRelation rel) { 28 33 super(); 29 // putValue(NAME, "D"); 34 // putValue(NAME, "D"); 30 35 putValue(SMALL_ICON, ImageProvider.get("relcontext", "download")); 31 36 putValue(SHORT_DESCRIPTION, tr("Download incomplete members for the chosen relation")); … … 35 40 } 36 41 37 public void actionPerformed( ActionEvent e ) { 42 @Override 43 public void actionPerformed(ActionEvent e) { 38 44 Relation relation = rel.get(); 39 if (relation == null || relation.isNew() ) return;45 if (relation == null || relation.isNew() ) return; 40 46 int total = relation.getMembersCount(); 41 47 int incomplete = relation.getIncompleteMembers().size(); 42 // if (incomplete <= 5 || (incomplete <= 10 && incomplete * 3 < total) )43 if (incomplete <= 10 && incomplete * 3 < total )48 // if (incomplete <= 5 || (incomplete <= 10 && incomplete * 3 < total) ) 49 if (incomplete <= 10 && incomplete * 3 < total ) { 44 50 downloadIncomplete(relation); 45 else51 } else { 46 52 downloadMembers(relation); 53 } 47 54 } 48 55 49 public void chosenRelationChanged( Relation oldRelation, Relation newRelation ) { 56 @Override 57 public void chosenRelationChanged(Relation oldRelation, Relation newRelation) { 50 58 boolean incomplete = false; 51 if (newRelation != null) {52 for (RelationMember m : newRelation.getMembers()) {53 if (m.getMember().isIncomplete()) {59 if (newRelation != null) { 60 for (RelationMember m : newRelation.getMembers()) { 61 if (m.getMember().isIncomplete()) { 54 62 incomplete = true; 55 63 break; … … 60 68 } 61 69 62 protected void downloadMembers( Relation rel) {63 if (!rel.isNew()) {70 protected void downloadMembers(Relation rel) { 71 if (!rel.isNew()) { 64 72 Main.worker.submit(new DownloadRelationTask(Collections.singletonList(rel), Main.main.getEditLayer())); 65 73 } 66 74 } 67 75 68 protected void downloadIncomplete( Relation rel) {69 if (rel.isNew() ) return;76 protected void downloadIncomplete(Relation rel) { 77 if (rel.isNew() ) return; 70 78 Set<OsmPrimitive> ret = new HashSet<>(); 71 79 ret.addAll(rel.getIncompleteMembers()); 72 if (ret.isEmpty() ) return;80 if (ret.isEmpty() ) return; 73 81 Main.worker.submit(new DownloadRelationMemberTask(Collections.singletonList(rel), ret, Main.main.getEditLayer())); 74 82 }
Note:
See TracChangeset
for help on using the changeset viewer.
