Changeset 32632 in osm for applications


Ignore:
Timestamp:
2016-07-11T18:05:24+02:00 (8 years ago)
Author:
darya
Message:

fix #13123

Location:
applications/editors/josm/plugins/pt_assistant
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pt_assistant/build.xml

    r32431 r32632  
    1212  <property name="plugin.icon" value="..."/>
    1313  <property name="plugin.link" value="https://wiki.openstreetmap.org/wiki/JOSM/Plugins/PT_Assistant"/>
     14  <property name="plugin.canloadatruntime" value="true"/>
    1415 
    1516  <!-- ** include targets that all plugins have in common ** -->
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/RouteUtils.java

    r32622 r32632  
    3030         */
    3131        public static boolean isTwoDirectionRoute(Relation r) {
     32               
     33                if (r == null) {
     34                        return false;
     35                }
     36               
    3237                if (!r.hasKey("route") || !r.hasTag("public_transport:version", "2")) {
    3338                        return false;
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssistantValidatorTest.java

    r32616 r32632  
    1818import org.openstreetmap.josm.data.validation.Test;
    1919import org.openstreetmap.josm.data.validation.TestError;
    20 import org.openstreetmap.josm.plugins.pt_assistant.actions.DownloadReferrersThread;
    2120import org.openstreetmap.josm.plugins.pt_assistant.actions.FixTask;
    2221import org.openstreetmap.josm.plugins.pt_assistant.actions.IncompleteMembersDownloadThread;
    23 import org.openstreetmap.josm.plugins.pt_assistant.gui.DownloadReferrersDialog;
    2422import org.openstreetmap.josm.plugins.pt_assistant.gui.IncompleteMembersDownloadDialog;
    2523import org.openstreetmap.josm.plugins.pt_assistant.gui.PTAssistantLayer;
     
    4038
    4139        private PTAssistantLayer layer;
    42         private static boolean nodeReferrersDownloaded;
    43         @SuppressWarnings("unused")
    44         private static boolean incompleteRelationsDowloaded;
    4540
    4641
     
    5146                layer = new PTAssistantLayer();
    5247                DataSet.addSelectionListener(layer);
    53                 nodeReferrersDownloaded = false;
    54                 incompleteRelationsDowloaded = false;
    5548
    5649        }
     
    6154                if (n.isIncomplete()) {
    6255                        return;
    63                 }
    64 
    65                 if (!nodeReferrersDownloaded) {
    66                         this.downloadReferrers(n);
    67                         nodeReferrersDownloaded = true;
    6856                }
    6957
     
    7664
    7765                // check that platforms are not part of any way:
    78                 if (n.hasTag("highway", "bus_stop") || n.hasTag("public_transport", "platform")
    79                                 || n.hasTag("highway", "platform") || n.hasTag("railway", "platform")) {
     66                if (n.hasTag("public_transport", "platform")) {
    8067                        nodeChecker.performPlatformPartOfWayTest();
    8168                }
     
    8572        }
    8673       
    87 
    88         /**
    89          * Downloads incomplete relation members in an extra thread (user input
    90          * required)
    91          *
    92          * @return true if successful, false if not successful
    93          */
    94         private boolean downloadReferrers(Node n) {
    95 
    96                 final int[] userSelection = { 0 };
    97 
    98                 try {
    99 
    100                         if (SwingUtilities.isEventDispatchThread()) {
    101 
    102                                 userSelection[0] = showDownloadReferrersDialog();
    103 
    104                         } else {
    105 
    106                                 SwingUtilities.invokeAndWait(new Runnable() {
    107                                         @Override
    108                                         public void run() {
    109                                                 try {
    110                                                         userSelection[0] = showDownloadReferrersDialog();
    111                                                 } catch (InterruptedException e) {
    112                                                         e.printStackTrace();
    113                                                 }
    114 
    115                                         }
    116                                 });
    117 
    118                         }
    119 
    120                 } catch (InterruptedException | InvocationTargetException e) {
    121                         return false;
    122                 }
    123 
    124                 if (userSelection[0] == JOptionPane.YES_OPTION) {
    125 
    126                         Thread t = new DownloadReferrersThread(n);
    127                         t.start();
    128                         synchronized (t) {
    129                                 try {
    130                                         t.wait();
    131                                 } catch (InterruptedException e) {
    132                                         return false;
    133                                 }
    134                         }
    135 
    136                 }
    137 
    138                 return true;
    139 
    140         }
    141 
    142         /**
    143          * Shows the dialog asking the user about an incomplete member download
    144          *
    145          * @return user's selection
    146          * @throws InterruptedException
    147          */
    148         private int showDownloadReferrersDialog() throws InterruptedException {
    149 
    150                 DownloadReferrersDialog downloadReferrersDialog = new DownloadReferrersDialog();
    151                 return downloadReferrersDialog.getUserSelection();
    152 
    153         }
    15474
    15575        @Override
     
    16888                                return;
    16989                        }
    170                         incompleteRelationsDowloaded = true;
    171 
    17290                }
    17391
     
    471389        }
    472390       
    473     public void endTest() {
    474         super.endTest();
    475         nodeReferrersDownloaded = false;
    476         incompleteRelationsDowloaded = false;
    477     }
    478 
    479391}
Note: See TracChangeset for help on using the changeset viewer.