Ticket #6642: tmslayer.patch

File tmslayer.patch, 4.7 KB (added by cmuelle8, 14 years ago)

patch in Show Errors option to hide error messages on tiles in the view pane

  • src/org/openstreetmap/josm/gui/layer/TMSLayer.java

     
    8989
    9090    public static final BooleanProperty PROP_DEFAULT_AUTOZOOM = new BooleanProperty(PREFERENCE_PREFIX + ".default_autozoom", true);
    9191    public static final BooleanProperty PROP_DEFAULT_AUTOLOAD = new BooleanProperty(PREFERENCE_PREFIX + ".default_autoload", true);
     92    public static final BooleanProperty PROP_DEFAULT_SHOWERRORS = new BooleanProperty(PREFERENCE_PREFIX + ".default_showerrors", true);
    9293    public static final IntegerProperty PROP_MIN_ZOOM_LVL = new IntegerProperty(PREFERENCE_PREFIX + ".min_zoom_lvl", DEFAULT_MIN_ZOOM);
    9394    public static final IntegerProperty PROP_MAX_ZOOM_LVL = new IntegerProperty(PREFERENCE_PREFIX + ".max_zoom_lvl", DEFAULT_MAX_ZOOM);
    9495    //public static final BooleanProperty PROP_DRAW_DEBUG = new BooleanProperty(PREFERENCE_PREFIX + ".draw_debug", false);
     
    155156    private JPopupMenu tileOptionMenu;
    156157    JCheckBoxMenuItem autoZoomPopup;
    157158    JCheckBoxMenuItem autoLoadPopup;
     159    JCheckBoxMenuItem showErrorsPopup;
    158160    Tile showMetadataTile;
    159161    private Image attrImage;
    160162    private String attrTermsUrl;
     
    170172
    171173    protected boolean autoZoom;
    172174    protected boolean autoLoad;
     175    protected boolean showErrors;
    173176
    174177    void redraw()
    175178    {
     
    320323        super(info);
    321324
    322325        if(!isProjectionSupported(Main.getProjection())) {
    323               JOptionPane.showMessageDialog(Main.parent,
    324                   tr("TMS layers do not support the projection {0}.\n{1}\n"
    325                   + "Change the projection or remove the layer.",
    326                       Main.getProjection().toCode(), nameSupportedProjections()),
    327                       tr("Warning"),
    328                       JOptionPane.WARNING_MESSAGE);
     326            JOptionPane.showMessageDialog(Main.parent,
     327                    tr("TMS layers do not support the projection {0}.\n{1}\n"
     328                            + "Change the projection or remove the layer.",
     329                            Main.getProjection().toCode(), nameSupportedProjections()),
     330                            tr("Warning"),
     331                            JOptionPane.WARNING_MESSAGE);
    329332        }
    330333
    331334        setBackgroundLayer(true);
     
    360363        autoLoadPopup.setSelected(autoLoad);
    361364        tileOptionMenu.add(autoLoadPopup);
    362365
     366        showErrors = PROP_DEFAULT_SHOWERRORS.get();
     367        showErrorsPopup = new JCheckBoxMenuItem();
     368        showErrorsPopup.setAction(new AbstractAction(tr("Show Errors")) {
     369            @Override
     370            public void actionPerformed(ActionEvent ae) {
     371                showErrors = !showErrors;
     372            }
     373        });
     374        showErrorsPopup.setSelected(showErrors);
     375        tileOptionMenu.add(showErrorsPopup);
     376
    363377        tileOptionMenu.add(new JMenuItem(new AbstractAction(tr("Load Tile")) {
    364378            @Override
    365379            public void actionPerformed(ActionEvent ae) {
     
    460474                                return;
    461475
    462476                            if((attrImageBounds != null && attrImageBounds.contains(e.getPoint()))
    463                             || (attrTextBounds != null && attrTextBounds.contains(e.getPoint()))) {
     477                                    || (attrTextBounds != null && attrTextBounds.contains(e.getPoint()))) {
    464478                                try {
    465479                                    java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
    466480                                    desktop.browse(new URI(tileSource.getAttributionLinkURL()));
     
    586600            }*/
    587601            currentZoomLevel--;
    588602            zoomChanged();
    589         } else {
     603        } else
    590604            /*Main.debug("Current zoom level could not be decreased. Min. zoom level "+minZoom+" reached.");*/
    591605            return false;
    592         }
    593606        return true;
    594607    }
    595608
     
    853866            texty += 1 + fontHeight;
    854867        }*/
    855868
    856         if (tile.hasError()) {
     869        if (tile.hasError() && showErrors) {
    857870            myDrawString(g, tr("Error") + ": " + tr(tile.getErrorMessage()), p.x + 2, texty);
    858871            texty += 1 + fontHeight;
    859872        }
     
    10841097        EastNorth topLeft = mv.getEastNorth(0, 0);
    10851098        EastNorth botRight = mv.getEastNorth(mv.getWidth(), mv.getHeight());
    10861099
    1087         if (botRight.east() == 0.0 || botRight.north() == 0) {
     1100        if (botRight.east() == 0.0 || botRight.north() == 0)
    10881101            /*Main.debug("still initializing??");*/
    10891102            // probably still initializing
    10901103            return;
    1091         }
    10921104
    10931105        needRedraw = false;
    10941106