Changeset 32238 in osm for applications/editors/josm/plugins/pt_assistant/src
- Timestamp:
- 2016-06-14T19:03:34+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/IncompleteMembersDownloadThread.java
r32237 r32238 3 3 import java.util.ArrayList; 4 4 5 import org.openstreetmap.josm.Main;6 5 import org.openstreetmap.josm.data.osm.PrimitiveId; 7 6 import org.openstreetmap.josm.data.osm.Relation; 8 import org.openstreetmap.josm.data.osm.RelationMember;9 7 import org.openstreetmap.josm.gui.io.DownloadPrimitivesWithReferrersTask; 10 8 … … 24 22 synchronized (this) { 25 23 26 ArrayList<PrimitiveId> list = new ArrayList<>(); 27 for (RelationMember rm : relation.getMembers()) { 28 list.add(rm); 29 } 24 ArrayList<PrimitiveId> list = new ArrayList<>(1); 25 list.add(relation); 30 26 31 27 DownloadPrimitivesWithReferrersTask task = new DownloadPrimitivesWithReferrersTask(false, list, false, true, -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssitantValidatorTest.java
r32237 r32238 6 6 import java.util.List; 7 7 8 import javax.swing.JCheckBox;9 8 import javax.swing.JOptionPane; 10 9 … … 21 20 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionTypeCalculator; 22 21 import org.openstreetmap.josm.plugins.pt_assistant.actions.IncompleteMembersDownloadThread; 22 import org.openstreetmap.josm.plugins.pt_assistant.gui.IncompleteMembersDownloadDialog; 23 23 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 24 24 … … 39 39 } 40 40 41 // Download incomplete members. If the download does not work, finish. 41 42 if (r.hasIncompleteMembers()) { 42 43 // IncompleteMembersDownloadDialog incompleteDialog = new 44 // IncompleteMembersDownloadDialog(r.getId()); 45 // 46 // int userInput = incompleteDialog.getUserSelection(); 47 48 String message = tr("The relation (id=" + r.getId() 49 + ") has incomplete members.\nThey need to be downloaded to proceed with validation of this relation.\nDo you want to download incomplete members?"); 50 JCheckBox checkbox = new JCheckBox(tr("Remember my choice and don't ask me again in this session")); 51 Object[] params = { message, checkbox }; 52 String[] options = { tr("Yes"), tr("No") }; 53 54 int userInput = Integer.MIN_VALUE; 55 userInput = JOptionPane.showOptionDialog(null, params, tr("Fetch Request"), JOptionPane.YES_NO_OPTION, 56 JOptionPane.QUESTION_MESSAGE, null, options, 0); 57 58 if (userInput == 0) { 59 60 Thread t = new IncompleteMembersDownloadThread(r); 61 t.start(); 62 synchronized (t) { 63 try { 64 t.wait(); 65 } catch (InterruptedException e) { 66 return; 67 } 68 } 69 43 boolean downloadSuccessful = this.downloadIncompleteMembers(r); 44 if (!downloadSuccessful) { 45 return; 70 46 } 71 47 } 72 48 49 performDummyTest(r); 50 51 52 53 54 55 } 56 57 /** 58 * Downloads incomplete relation members in an extra thread (user input 59 * required) 60 * 61 * @return true if successful, false if not successful 62 */ 63 private boolean downloadIncompleteMembers(Relation r) { 64 IncompleteMembersDownloadDialog incompleteMembersDownloadDialog = new IncompleteMembersDownloadDialog( 65 r.getId()); 66 67 int userInput = incompleteMembersDownloadDialog.getUserSelection(); 68 69 if (userInput == JOptionPane.YES_OPTION) { 70 71 Thread t = new IncompleteMembersDownloadThread(r); 72 t.start(); 73 synchronized (t) { 74 try { 75 t.wait(); 76 } catch (InterruptedException e) { 77 return false; 78 } 79 } 80 return true; 81 } 82 83 return false; 84 } 85 86 /** 87 * Checks if the test error is fixable 88 */ 89 @Override 90 public boolean isFixable(TestError testError) { 91 return false; 92 } 93 94 @Override 95 public Command fixError(TestError testError) { 96 return null; 97 } 98 99 private void performDirectionTest(Relation r) { 73 100 List<RelationMember> waysToCheck = new ArrayList<>(); 74 101 … … 82 109 return; 83 110 } 84 111 85 112 WayConnectionTypeCalculator connectionTypeCalculator = new WayConnectionTypeCalculator(); 86 113 final List<WayConnectionType> links = connectionTypeCalculator.updateLinks(waysToCheck); … … 113 140 } 114 141 } 115 116 // List<Relation> primitives = new ArrayList<>(1);117 // primitives.add(r);118 // errors.add(new TestError(this, Severity.WARNING, tr("PT: test warning"), ERROR_CODE_DIRECTION, primitives));119 120 142 } 121 122 /** 123 * Checks if the test error is fixable 124 */ 125 @Override 126 public boolean isFixable(TestError testError) { 127 return false; 128 } 129 130 @Override 131 public Command fixError(TestError testError) { 132 return null; 143 144 private void performDummyTest(Relation r) { 145 List<Relation> primitives = new ArrayList<>(1); 146 primitives.add(r); 147 errors.add(new TestError(this, Severity.WARNING, tr("PT: dummy test warning"), ERROR_CODE_DIRECTION, primitives)); 133 148 } 134 149
Note:
See TracChangeset
for help on using the changeset viewer.