Changeset 4465 in josm


Ignore:
Timestamp:
Sep 25, 2011 7:48:57 PM (20 months ago)
Author:
simon04
Message:

fix #6892 - JOSM crashed while selecting area. use OpenBrowser to display attribution (patch by Don-vip)

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java

    r4336 r4465  
    33 
    44import java.awt.Color; 
    5 import java.awt.Desktop; 
    65import java.awt.Dimension; 
    76import java.awt.Graphics; 
     
    1211import java.io.File; 
    1312import java.io.IOException; 
    14 import java.net.URI; 
    15 import java.net.URISyntaxException; 
    1613import java.util.ArrayList; 
    1714import java.util.Arrays; 
     
    4037import org.openstreetmap.josm.data.preferences.StringProperty; 
    4138import org.openstreetmap.josm.gui.layer.TMSLayer; 
     39import org.openstreetmap.josm.tools.OpenBrowser; 
    4240 
    4341public class SlippyMapBBoxChooser extends JMapViewer implements BBoxChooser{ 
     
    223221        /* TODO: Somehow indicate the link is clickable state to user */ 
    224222 
    225         try { 
    226             if((attrImageBounds != null && attrImageBounds.contains(p)) 
    227             || (attrTextBounds != null && attrTextBounds.contains(p))) { 
    228                 if(click) 
    229                     Desktop.getDesktop().browse(new URI(ts.getAttributionLinkURL())); 
    230                 /*else 
    231                     Main.warn(ts.getAttributionLinkURL());*/ 
    232                 return true; 
    233             } else if(attrToUBounds != null && attrToUBounds.contains(p)) { 
    234                 if(click) 
    235                     Desktop.getDesktop().browse(new URI(ts.getTermsOfUseURL())); 
    236                 /*else 
    237                     Main.warn(ts.getTermsOfUseURL());*/ 
    238                 return true; 
    239             } 
    240         } catch (IOException e1) { 
    241             e1.printStackTrace(); 
    242         } catch (URISyntaxException e1) { 
    243             e1.printStackTrace(); 
     223        if ((attrImageBounds != null && attrImageBounds.contains(p)) 
     224                || (attrTextBounds != null && attrTextBounds.contains(p))) { 
     225            if (click) 
     226                OpenBrowser.displayUrl(ts.getAttributionLinkURL()); 
     227            /*else 
     228                Main.warn(ts.getAttributionLinkURL());*/ 
     229            return true; 
     230        } else if (attrToUBounds != null && attrToUBounds.contains(p)) { 
     231            if (click) 
     232                OpenBrowser.displayUrl(ts.getTermsOfUseURL()); 
     233            /*else 
     234                Main.warn(ts.getTermsOfUseURL());*/ 
     235            return true; 
    244236        } 
    245237        return false; 
  • trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java

    r4432 r4465  
    2020import java.io.File; 
    2121import java.io.IOException; 
    22 import java.net.URI; 
    23 import java.net.URISyntaxException; 
    2422import java.util.ArrayList; 
    2523import java.util.Collections; 
     
    7068import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 
    7169import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 
     70import org.openstreetmap.josm.tools.OpenBrowser; 
    7271 
    7372/** 
     
    478477                            tileOptionMenu.show(e.getComponent(), e.getX(), e.getY()); 
    479478                        } else if (e.getButton() == MouseEvent.BUTTON1) { 
    480                             if(!tileSource.requiresAttribution()) 
     479                            if (!tileSource.requiresAttribution()) 
    481480                                return; 
    482481 
    483                             if((attrImageBounds != null && attrImageBounds.contains(e.getPoint())) 
    484                             || (attrTextBounds != null && attrTextBounds.contains(e.getPoint()))) { 
    485                                 try { 
    486                                     java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); 
    487                                     desktop.browse(new URI(tileSource.getAttributionLinkURL())); 
    488                                 } catch (IOException e1) { 
    489                                     e1.printStackTrace(); 
    490                                 } catch (URISyntaxException e1) { 
    491                                     e1.printStackTrace(); 
    492                                 } 
    493                             } else if(attrToUBounds != null && attrToUBounds.contains(e.getPoint())) { 
    494                                 try { 
    495                                     java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); 
    496                                     desktop.browse(new URI(tileSource.getTermsOfUseURL())); 
    497                                 } catch (IOException e1) { 
    498                                     e1.printStackTrace(); 
    499                                 } catch (URISyntaxException e1) { 
    500                                     e1.printStackTrace(); 
    501                                 } 
     482                            if ((attrImageBounds != null && attrImageBounds.contains(e.getPoint())) 
     483                                    || (attrTextBounds != null && attrTextBounds.contains(e.getPoint()))) { 
     484                                OpenBrowser.displayUrl(tileSource.getAttributionLinkURL()); 
     485                            } else if (attrToUBounds != null && attrToUBounds.contains(e.getPoint())) { 
     486                                OpenBrowser.displayUrl(tileSource.getTermsOfUseURL()); 
    502487                            } 
    503488                        } 
Note: See TracChangeset for help on using the changeset viewer.