Changeset 32554 in osm
- Timestamp:
- 2016-07-04T13:45:59+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/IncompleteMembersDownloadThread.java
r32522 r32554 21 21 } 22 22 23 @SuppressWarnings("unused")24 private void realRun() {25 // TODO26 }27 23 28 24 @Override … … 40 36 if (RouteUtils.isTwoDirectionRoute(currentRelation)) { 41 37 list.add(currentRelation); 42 // for (RelationMember rm : currentRelation.getMembers()) {43 // if (rm.hasRole("stop") || rm.hasRole("stop_entry_only") || rm.hasRole("stop_exit_only")44 // || rm.hasRole("platform") || rm.hasRole("platform_entry_only")45 // || rm.hasRole("platform_exit_only")) {46 // List<OsmPrimitive> referrers = rm.getMember().getReferrers();47 // for (OsmPrimitive referrer : referrers) {48 // if (referrer.getType().equals(OsmPrimitiveType.RELATION)49 // && referrer.hasTag("public_transport", "stop_area")) {50 // list.add(referrer);51 // }52 // }53 // }54 // }55 38 } 56 39 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/IncompleteMembersDownloadDialog.java
r32522 r32554 6 6 import javax.swing.JOptionPane; 7 7 import javax.swing.JPanel; 8 import javax.swing.SwingUtilities;9 8 10 9 public class IncompleteMembersDownloadDialog extends JPanel { … … 26 25 private int selectedOption; 27 26 28 public IncompleteMembersDownloadDialog(long id) { 27 public IncompleteMembersDownloadDialog() { 28 29 29 selectedOption = Integer.MIN_VALUE; 30 31 // message = tr("The relation (id={0}) has incomplete members.\n"+32 // "They need to be downloaded to proceed with validation of this relation.\nDo you want to download incomplete members?", id);33 30 message = tr("Route relations have incomplete members.\nThey need to be downloaded to proceed with validation.\nDo you want to download them?"); 34 31 checkbox = new JCheckBox(tr("Remember my choice and do not ask me again in this session")); … … 56 53 } 57 54 58 // this.createDialog(); // FIXME59 55 60 61 56 Object[] params = {message, checkbox}; 62 57 selectedOption = JOptionPane.showOptionDialog(this, params, tr("PT_Assistant Fetch Request"), JOptionPane.YES_NO_OPTION, … … 74 69 } 75 70 76 @SuppressWarnings("unused")77 private void createDialog() {78 if (!SwingUtilities.isEventDispatchThread()) {79 Object[] params = {message, checkbox};80 selectedOption = JOptionPane.showOptionDialog(null, params, tr("Fetch Request"), JOptionPane.YES_NO_OPTION,81 JOptionPane.QUESTION_MESSAGE, null, options, 0);82 } else {83 SwingUtilities.invokeLater(new Runnable() {84 @Override85 public void run() {86 createDialog();87 }88 });89 90 }91 }92 93 71 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssitantValidatorTest.java
r32522 r32554 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.lang.reflect.InvocationTargetException; 5 6 import java.util.ArrayList; 6 7 import java.util.List; 7 8 8 9 import javax.swing.JOptionPane; 10 import javax.swing.SwingUtilities; 9 11 10 12 import org.openstreetmap.josm.command.Command; … … 40 42 layer = new PTAssistantLayer(); 41 43 DataSet.addSelectionListener(layer); 42 44 43 45 } 44 46 … … 50 52 } 51 53 52 // Download incomplete members. If the download does not work, finish. 54 // Download incomplete members. If the download does not work, return 55 // and do not do any testing. 53 56 if (r.hasIncompleteMembers()) { 54 boolean downloadSuccessful = this.downloadIncompleteMembers(r); 57 58 boolean downloadSuccessful = this.downloadIncompleteMembers(); 55 59 if (!downloadSuccessful) { 56 60 return; 57 61 } 62 58 63 } 59 64 … … 61 66 return; 62 67 } 63 64 68 65 69 // Check individual ways using the oneway direction test and the road … … 86 90 * @return true if successful, false if not successful 87 91 */ 88 private boolean downloadIncompleteMembers(Relation r) { 89 IncompleteMembersDownloadDialog incompleteMembersDownloadDialog = new IncompleteMembersDownloadDialog( 90 r.getId()); 91 92 int userInput = incompleteMembersDownloadDialog.getUserSelection(); 93 94 if (userInput == JOptionPane.YES_OPTION) { 92 private boolean downloadIncompleteMembers() { 93 94 final int[] userSelection = { 0 }; 95 96 try { 97 98 if (SwingUtilities.isEventDispatchThread()) { 99 100 userSelection[0] = realDownloadIncompleteMembers(); 101 102 } else { 103 104 SwingUtilities.invokeAndWait(new Runnable() { 105 @Override 106 public void run() { 107 try { 108 userSelection[0] = realDownloadIncompleteMembers(); 109 } catch (InterruptedException e) { 110 e.printStackTrace(); 111 } 112 113 } 114 }); 115 116 } 117 118 } catch (InterruptedException | InvocationTargetException e) { 119 return false; 120 } 121 122 if (userSelection[0] == JOptionPane.YES_OPTION) { 95 123 96 124 Thread t = new IncompleteMembersDownloadThread(); … … 100 128 t.wait(); 101 129 } catch (InterruptedException e) { 102 // TODO: give the user a message that testing stops103 130 return false; 104 131 } 105 132 } 106 return true; 107 } 108 109 return false; 133 134 } 135 136 return true; 137 138 } 139 140 /** 141 * Shows the dialog asking the user about an incomplete member download 142 * 143 * @return user's selection 144 * @throws InterruptedException 145 */ 146 private int realDownloadIncompleteMembers() throws InterruptedException { 147 148 IncompleteMembersDownloadDialog incompleteMembersDownloadDialog = new IncompleteMembersDownloadDialog(); 149 return incompleteMembersDownloadDialog.getUserSelection(); 150 110 151 } 111 152 … … 229 270 List<Command> commands = new ArrayList<>(); 230 271 231 if (testError.getCode() == ERROR_CODE_ROAD_TYPE 232 || testError.getCode() == ERROR_CODE_CONSTRUCTION) { 272 if (testError.getCode() == ERROR_CODE_ROAD_TYPE || testError.getCode() == ERROR_CODE_CONSTRUCTION) { 233 273 commands.add(WayChecker.fixErrorByRemovingWay(testError)); 234 274 } 235 275 236 276 if (testError.getCode() == ERROR_CODE_DIRECTION) { 237 277 commands.add(WayChecker.fixErrorByZooming(testError)); 278 238 279 } 239 280 … … 279 320 } 280 321 281 282 322 @SuppressWarnings("unused") 283 323 private void performDummyTest(Relation r) { -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/WayChecker.java
r32497 r32554 7 7 import java.util.List; 8 8 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.actions.AutoScaleAction; 9 11 import org.openstreetmap.josm.command.ChangeCommand; 10 12 import org.openstreetmap.josm.command.Command; … … 19 21 import org.openstreetmap.josm.data.validation.Test; 20 22 import org.openstreetmap.josm.data.validation.TestError; 23 import org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor; 24 import org.openstreetmap.josm.gui.dialogs.relation.RelationDialogManager; 21 25 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType; 22 26 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionTypeCalculator; 27 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 23 28 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 24 29 … … 275 280 } 276 281 277 // Collection<? extends OsmPrimitive> primitives = testError.getPrimitives(); 278 // Relation originalRelation = (Relation) primitives.iterator().next(); 282 long startTime = System.currentTimeMillis(); 283 284 Collection<? extends OsmPrimitive> primitives = testError.getPrimitives(); 285 Relation originalRelation = (Relation) primitives.iterator().next(); 279 286 Collection<?> highlighted = testError.getHighlighted(); 280 287 Way wayToHighlight = (Way) highlighted.iterator().next(); 281 288 ArrayList<OsmPrimitive> primitivesToHighlight = new ArrayList<>(1); 282 289 primitivesToHighlight.add(wayToHighlight); 283 290 291 long endTime = System.currentTimeMillis(); 292 System.out.println("obtaining primitives: " + (endTime - startTime)); 293 startTime = endTime; 294 284 295 SelectCommand command = new SelectCommand(primitivesToHighlight); 285 296 297 endTime = System.currentTimeMillis(); 298 System.out.println("constructing command: " + (endTime - startTime)); 299 startTime = endTime; 300 301 AutoScaleAction.zoomTo(primitivesToHighlight); 302 303 endTime = System.currentTimeMillis(); 304 System.out.println("AutoScaleAction done: " + (endTime - startTime)); 305 startTime = endTime; 306 307 List<OsmDataLayer> listOfLayers = Main.getLayerManager().getLayersOfType(OsmDataLayer.class); 308 for (OsmDataLayer osmDataLayer: listOfLayers) { 309 if (osmDataLayer.data == originalRelation.getDataSet()) { 310 endTime = System.currentTimeMillis(); 311 System.out.println("getting to the necessary layer: " + (endTime - startTime)); 312 startTime = endTime; 313 314 GenericRelationEditor editor = new GenericRelationEditor(osmDataLayer, originalRelation, originalRelation.getMembersFor(primitivesToHighlight)); 315 endTime = System.currentTimeMillis(); 316 System.out.println("creating relation editor: " + (endTime - startTime)); 317 startTime = endTime; 318 319 RelationDialogManager.getRelationDialogManager().register(osmDataLayer, originalRelation, editor); 320 321 endTime = System.currentTimeMillis(); 322 System.out.println("registering relation editor: " + (endTime - startTime)); 323 startTime = endTime; 324 325 editor.setVisible(true); 326 327 endTime = System.currentTimeMillis(); 328 System.out.println("setting editor visible: " + (endTime - startTime)); 329 startTime = endTime; 330 331 break; 332 } 333 } 334 335 endTime = System.currentTimeMillis(); 336 System.out.println("whatever else: " + (endTime - startTime)); 337 startTime = endTime; 338 286 339 return command; 287 340
Note:
See TracChangeset
for help on using the changeset viewer.