Ignore:
Timestamp:
2012-04-04T20:35:27+02:00 (12 years ago)
Author:
donvip
Message:

[josm_opendata] fix #josm7573 - NullPointerException when right-clicking a layer without handler

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdDataLayer.java

    r28114 r28185  
    142142                        result.add(entry);
    143143                }
    144                 if (this.handler.getWikiURL() != null || this.handler.getLocalPortalURL() != null || this.handler.getNationalPortalURL() != null) {
    145                         result.add(SeparatorLayerAction.INSTANCE);
    146                 }
    147                 if (this.handler.getWikiURL() != null) {
    148                         result.add(new OpenLinkAction(this.handler.getWikiURL(), ICON_OSM_24,
    149                                         tr("View OSM Wiki page"), tr("Launch browser to the OSM Wiki page of the selected data set")));
    150                 }
    151                 if (this.handler.getLocalPortalURL() != null) {
    152                         result.add(new OpenLinkAction(this.handler.getLocalPortalURL(), this.handler.getLocalPortalIconName(),
    153                                         tr("View Local Portal page"), tr("Launch browser to the local portal page of the selected data set")));
    154                 }
    155                 if (this.handler.getNationalPortalURL() != null) {
    156                         result.add(new OpenLinkAction(this.handler.getNationalPortalURL(), this.handler.getNationalPortalIconName(),
    157                                         tr("View National Portal page"), tr("Launch browser to the national portal page of the selected data set")));
    158                 }
    159                 if (this.handler.getLicense() != null) {
    160                         License lic = this.handler.getLicense();
    161                         if (lic.getURL() != null && lic.getURL().getProtocol().startsWith("http")) {
    162                                 result.add(new OpenLinkAction(lic.getURL(), ICON_AGREEMENT_24,
    163                                                 tr("View License"), tr("Launch browser to the license page of the selected data set")));
     144                if (this.handler != null) {
     145                        if (this.handler.getWikiURL() != null || this.handler.getLocalPortalURL() != null || this.handler.getNationalPortalURL() != null) {
     146                                result.add(SeparatorLayerAction.INSTANCE);
    164147                        }
    165                         if (lic.getSummaryURL() != null && lic.getSummaryURL().getProtocol().startsWith("http")) {
    166                                 result.add(new OpenLinkAction(lic.getSummaryURL(), ICON_AGREEMENT_24,
    167                                                 tr("View License (summary)"), tr("Launch browser to the summary license page of the selected data set")));
     148                        if (this.handler.getWikiURL() != null) {
     149                                result.add(new OpenLinkAction(this.handler.getWikiURL(), ICON_OSM_24,
     150                                                tr("View OSM Wiki page"), tr("Launch browser to the OSM Wiki page of the selected data set")));
    168151                        }
    169                         if ((lic.getURL() != null && !lic.getURL().getProtocol().startsWith("http")) || (lic.getSummaryURL() != null && !lic.getSummaryURL().getProtocol().startsWith("http"))) {
    170                                 result.add(new ViewLicenseAction(lic, tr("View License"), tr("View the license of the selected data set")));
     152                        if (this.handler.getLocalPortalURL() != null) {
     153                                result.add(new OpenLinkAction(this.handler.getLocalPortalURL(), this.handler.getLocalPortalIconName(),
     154                                                tr("View Local Portal page"), tr("Launch browser to the local portal page of the selected data set")));
     155                        }
     156                        if (this.handler.getNationalPortalURL() != null) {
     157                                result.add(new OpenLinkAction(this.handler.getNationalPortalURL(), this.handler.getNationalPortalIconName(),
     158                                                tr("View National Portal page"), tr("Launch browser to the national portal page of the selected data set")));
     159                        }
     160                        if (this.handler.getLicense() != null) {
     161                                License lic = this.handler.getLicense();
     162                                if (lic.getURL() != null && lic.getURL().getProtocol().startsWith("http")) {
     163                                        result.add(new OpenLinkAction(lic.getURL(), ICON_AGREEMENT_24,
     164                                                        tr("View License"), tr("Launch browser to the license page of the selected data set")));
     165                                }
     166                                if (lic.getSummaryURL() != null && lic.getSummaryURL().getProtocol().startsWith("http")) {
     167                                        result.add(new OpenLinkAction(lic.getSummaryURL(), ICON_AGREEMENT_24,
     168                                                        tr("View License (summary)"), tr("Launch browser to the summary license page of the selected data set")));
     169                                }
     170                                if ((lic.getURL() != null && !lic.getURL().getProtocol().startsWith("http")) || (lic.getSummaryURL() != null && !lic.getSummaryURL().getProtocol().startsWith("http"))) {
     171                                        result.add(new ViewLicenseAction(lic, tr("View License"), tr("View the license of the selected data set")));
     172                                }
    171173                        }
    172174                }
Note: See TracChangeset for help on using the changeset viewer.