Index: applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/Browser.java
===================================================================
--- applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/Browser.java	(revision 13497)
+++ applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/Browser.java	(revision 13582)
@@ -21,5 +21,5 @@
     static
     {
-    Logger.getLogger("org.lobobrowser").setLevel(Level.WARNING);
+        Logger.getLogger("org.lobobrowser").setLevel(Level.WARNING);
     }
 
@@ -28,34 +28,36 @@
     Dimension oldSize = null;
 
-    public Browser(String uri) {
-    super();
+    public Browser(String uri, MyHtmlBlockPanel.ViewUpdateListener vul) {
+        super();
 
-    UserAgentContext ucontext = new CacheableUserAgentContext();
-    rcontext = new SimpleHtmlRendererContext(this, ucontext);
-    addNotify();
+        view_update_listener = vul;
 
-    process( uri );
+        UserAgentContext ucontext = new CacheableUserAgentContext();
+        rcontext = new SimpleHtmlRendererContext(this, ucontext);
+        addNotify();
+
+        process( uri );
     }
 
     private void process(String uri) {
-    try {
-        URL url;
         try {
-        url = new URL(uri);
-        } catch (java.net.MalformedURLException mfu) {
-        int idx = uri.indexOf(':');
-        if (idx == -1 || idx == 1) {
-            // try file
-            url = new URL("file:" + uri);
-        } else {
-            throw mfu;
+            URL url;
+            try {
+            url = new URL(uri);
+            } catch (java.net.MalformedURLException mfu) {
+            int idx = uri.indexOf(':');
+            if (idx == -1 || idx == 1) {
+                // try file
+                url = new URL("file:" + uri);
+            } else {
+                throw mfu;
+            }
+            }
+            // Call SimpleHtmlRendererContext.navigate()
+            // which implements incremental rendering.
+            this.rcontext.navigate(url, null);
+        } catch (Exception err) {
+            err.printStackTrace();
         }
-        }
-        // Call SimpleHtmlRendererContext.navigate()
-        // which implements incremental rendering.
-        this.rcontext.navigate(url, null);
-    } catch (Exception err) {
-        err.printStackTrace();
-    }
     }
 
@@ -63,40 +65,41 @@
     public void setSize(final Dimension newSize)
     {
-    if (!newSize.equals(oldSize)) {
-        oldSize = newSize;
-        super.setSize(newSize);
-        validate();
+        if (!newSize.equals(oldSize)) {
+            oldSize = newSize;
+            super.setSize(newSize);
+            validate();
 
-        executeAsyncScript("resizeMap(" + newSize.width + "," + newSize.height + ");");
-    }
+            executeAsyncScript("resizeMap(" + newSize.width + "," + newSize.height + ");");
+        }
     }
 
     public void executeAsyncScript(final String script)
     {
-    EventQueue.invokeLater(new Runnable() {
-        public void run() {
-        executeScript(script);
-        }
-    });
+        EventQueue.invokeLater(new Runnable() {
+            public void run() {
+            executeScript(script);
+            }
+        });
     }
 
     public Object executeScript(String script)
     {
-    System.out.println("Executing script " + script);
-    try {
-        Window window = Window.getWindow(rcontext);
-        if( window.getDocumentNode() == null )
-        return null; // Document not loaded yet
+        System.out.println("Executing script " + script);
+        try {
+            Window window = Window.getWindow(rcontext);
+            if( window.getDocumentNode() == null )
+            return null; // Document not loaded yet
 
-        return window.eval(script);
-    } catch (EcmaError ecmaError) {
-        logger.log(Level.WARNING, "Javascript error at " + ecmaError.sourceName() + ":" + ecmaError.lineNumber() + ": " + ecmaError.getMessage());
-    } catch (Throwable err) {
-        logger.log(Level.WARNING, "Unable to evaluate Javascript code", err);
+            return window.eval(script);
+        } catch (EcmaError ecmaError) {
+            logger.log(Level.WARNING, "Javascript error at " + ecmaError.sourceName() + ":" + ecmaError.lineNumber() + ": " + ecmaError.getMessage());
+        } catch (Throwable err) {
+            logger.log(Level.WARNING, "Unable to evaluate Javascript code", err);
+        }
+
+        return null;
     }
 
-    return null;
-    }
-
+    MyHtmlBlockPanel.ViewUpdateListener view_update_listener;
 
     /**
@@ -105,5 +108,14 @@
     @Override
     protected HtmlBlockPanel createHtmlBlockPanel(UserAgentContext ucontext, HtmlRendererContext rcontext) {
-    return new MyHtmlBlockPanel(java.awt.Color.WHITE, true, ucontext, rcontext, this);
+        return new MyHtmlBlockPanel(java.awt.Color.WHITE, true,
+        ucontext, rcontext, this, view_update_listener);
+    }
+
+    /**
+     * Get page loading status from the bottom status bar.
+     */
+    public String getStatus() {
+        /* TODO */
+        return "Tile loaded";
     }
 }
Index: applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/CacheableHttpRequest.java
===================================================================
--- applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/CacheableHttpRequest.java	(revision 13497)
+++ applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/CacheableHttpRequest.java	(revision 13582)
@@ -44,117 +44,117 @@
 
     public CacheableHttpRequest(UserAgentContext context, Proxy proxy) {
-    this.context = context;
-    this.proxy = proxy;
+        this.context = context;
+        this.proxy = proxy;
     }
 
     public synchronized int getReadyState() {
-    return this.readyState;
+        return this.readyState;
     }
 
     public synchronized String getResponseText() {
-    if( response == null ) return null;
-
-    byte[] bytes = this.response.responseBytes;
-    String encoding = this.response.encoding;
-
-    try {
-        return bytes == null ? null : new String(bytes, encoding);
-    } catch (UnsupportedEncodingException uee) {
-        logger.log(Level.WARNING, "getResponseText(): Charset '" + encoding + "' did not work. Retrying with ISO-8859-1.", uee);
+        if( response == null ) return null;
+
+        byte[] bytes = this.response.responseBytes;
+        String encoding = this.response.encoding;
+
         try {
-        return new String(bytes, "ISO-8859-1");
-        } catch (UnsupportedEncodingException uee2) {
-        // Ignore this time
-        return null;
-        }
-    }
+            return bytes == null ? null : new String(bytes, encoding);
+        } catch (UnsupportedEncodingException uee) {
+            logger.log(Level.WARNING, "getResponseText(): Charset '" + encoding + "' did not work. Retrying with ISO-8859-1.", uee);
+            try {
+            return new String(bytes, "ISO-8859-1");
+            } catch (UnsupportedEncodingException uee2) {
+            // Ignore this time
+            return null;
+            }
+        }
     }
 
     public synchronized Document getResponseXML() {
-    if( response == null ) return null;
-
-    byte[] bytes = this.response.responseBytes;
-    if (bytes == null) return null;
-
-    InputStream in = new ByteArrayInputStream(bytes);
-    try {
-        return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
-    } catch (Exception err) {
-        logger.log(Level.WARNING, "Unable to parse response as XML.", err);
-        return null;
-    }
+        if( response == null ) return null;
+
+        byte[] bytes = this.response.responseBytes;
+        if (bytes == null) return null;
+
+        InputStream in = new ByteArrayInputStream(bytes);
+        try {
+            return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
+        } catch (Exception err) {
+            logger.log(Level.WARNING, "Unable to parse response as XML.", err);
+            return null;
+        }
     }
 
     public synchronized byte[] getResponseBytes() {
-    if( response == null ) return null;
-    return this.response.responseBytes;
+        if( response == null ) return null;
+        return this.response.responseBytes;
     }
 
     public synchronized Image getResponseImage() {
-    if( response == null ) return null;
-
-    byte[] bytes = this.response.responseBytes;
-    if (bytes == null) return null;
-
-    return Toolkit.getDefaultToolkit().createImage(bytes);
+        if( response == null ) return null;
+
+        byte[] bytes = this.response.responseBytes;
+        if (bytes == null) return null;
+
+        return Toolkit.getDefaultToolkit().createImage(bytes);
     }
 
     public synchronized int getStatus() {
-    if( response == null ) return 0;
-    return this.response.status;
+        if( response == null ) return 0;
+        return this.response.status;
     }
 
     public synchronized String getStatusText() {
-    if( response == null ) return null;
-    return this.response.statusText;
+        if( response == null ) return null;
+        return this.response.statusText;
     }
 
     public synchronized String getAllResponseHeaders() {
-    if( response == null ) return null;
-    return this.response.responseHeaders;
+        if( response == null ) return null;
+        return this.response.responseHeaders;
     }
 
     public synchronized String getResponseHeader(String headerName) {
-    if( response == null ) return null;
-    Map headers = this.response.responseHeadersMap;
-    return headers == null ? null : (String) headers.get(headerName);
+        if( response == null ) return null;
+        Map headers = this.response.responseHeadersMap;
+        return headers == null ? null : (String) headers.get(headerName);
     }
 
     public void open(String method, String url) throws IOException {
-    this.open(method, url, true);
+        this.open(method, url, true);
     }
 
     public void open(String method, URL url) throws IOException {
-    this.open(method, url, true, null, null);
+        this.open(method, url, true, null, null);
     }
 
     public void open(String method, URL url, boolean asyncFlag) throws IOException {
-    this.open(method, url, asyncFlag, null, null);
+        this.open(method, url, asyncFlag, null, null);
     }
 
     public void open(String method, String url, boolean asyncFlag) throws IOException {
-    URL urlObj = Urls.createURL(null, url);
-    this.open(method, urlObj, asyncFlag, null);
+        URL urlObj = Urls.createURL(null, url);
+        this.open(method, urlObj, asyncFlag, null);
     }
 
     public void open(String method, URL url, boolean asyncFlag, String userName) throws IOException {
-    this.open(method, url, asyncFlag, userName, null);
+        this.open(method, url, asyncFlag, userName, null);
     }
 
     public void abort() {
-    URLConnection c;
-    synchronized (this) {
-        c = this.connection;
-        response = null;
-    }
-    if (c instanceof HttpURLConnection) {
-        ((HttpURLConnection) c).disconnect();
-    } else if (c != null) {
-        try {
-        c.getInputStream().close();
-        } catch (IOException ioe) {
-        ioe.printStackTrace();
-        }
-    }
+        URLConnection c;
+        synchronized (this) {
+            c = this.connection;
+            response = null;
+        }
+        if (c instanceof HttpURLConnection) {
+            ((HttpURLConnection) c).disconnect();
+        } else if (c != null) {
+            try {
+            c.getInputStream().close();
+            } catch (IOException ioe) {
+            ioe.printStackTrace();
+            }
+        }
     }
 
@@ -170,29 +170,29 @@
      */
     public void open(final String method, final URL url, boolean asyncFlag, final String userName, final String password) throws IOException {
-    this.abort();
-
-    HttpResponse response = HttpResponse.lookup(url);
-    URLConnection c = null;
-
-    if( response == null )
-    {
-        c = proxy == null || proxy == Proxy.NO_PROXY ? url.openConnection() : url.openConnection(proxy);
-        response = new HttpResponse();
-    }
-
-    synchronized (this) {
-        this.connection = c;
-        this.isAsync = asyncFlag;
-        this.requestMethod = method;
-        this.requestUserName = userName;
-        this.requestPassword = password;
-        this.requestURL = url;
-        this.response = response;
-
-        if( response.loaded )
-        changeState(HttpRequest.STATE_LOADING);
-        else
-        changeState(HttpRequest.STATE_LOADING, 0, null, null);
-    }
+        this.abort();
+
+        HttpResponse response = HttpResponse.lookup(url);
+        URLConnection c = null;
+
+        if( response == null )
+        {
+            c = proxy == null || proxy == Proxy.NO_PROXY ? url.openConnection() : url.openConnection(proxy);
+            response = new HttpResponse();
+        }
+
+        synchronized (this) {
+            this.connection = c;
+            this.isAsync = asyncFlag;
+            this.requestMethod = method;
+            this.requestUserName = userName;
+            this.requestPassword = password;
+            this.requestURL = url;
+            this.response = response;
+
+            if( response.loaded )
+            changeState(HttpRequest.STATE_LOADING);
+            else
+            changeState(HttpRequest.STATE_LOADING, 0, null, null);
+        }
     }
 
@@ -206,23 +206,23 @@
      */
     public void send(final String content) throws IOException {
-    final URL url = this.requestURL;
-    if (url == null) {
-        throw new IOException("No URL has been provided.");
-    }
-    if (this.isAsync) {
-        // Should use a thread pool instead
-        new Thread("SimpleHttpRequest-" + url.getHost()) {
-        @Override
-        public void run() {
-            try {
+        final URL url = this.requestURL;
+        if (url == null) {
+            throw new IOException("No URL has been provided.");
+        }
+        if (this.isAsync) {
+            // Should use a thread pool instead
+            new Thread("SimpleHttpRequest-" + url.getHost()) {
+                @Override
+                public void run() {
+                    try {
+                    sendSync(content);
+                    } catch (Throwable thrown) {
+                    logger.log(Level.WARNING,"send(): Error in asynchronous request on " + url, thrown);
+                    }
+                }
+            }.start();
+        } else {
             sendSync(content);
-            } catch (Throwable thrown) {
-            logger.log(Level.WARNING,"send(): Error in asynchronous request on " + url, thrown);
-            }
-        }
-        }.start();
-    } else {
-        sendSync(content);
-    }
+        }
     }
 
@@ -232,5 +232,5 @@
      */
     protected String getPostCharset() {
-    return "UTF-8";
+        return "UTF-8";
     }
 
@@ -243,56 +243,56 @@
      */
     protected void sendSync(String content) throws IOException {
-    if( response.loaded )
-    {
-        // Response from cache
-        changeState(HttpRequest.STATE_LOADED);
-        changeState(HttpRequest.STATE_INTERACTIVE);
-        changeState(HttpRequest.STATE_COMPLETE);
-        return;
-    }
-
-    try {
-        URLConnection c;
-        synchronized (this) {
-        c = this.connection;
-        }
-        c.setRequestProperty("User-Agent", this.context.getUserAgent());
-        int istatus = 0;
-        String istatusText = "";
-        InputStream err = null;
-
-        if (c instanceof HttpURLConnection) {
-        HttpURLConnection hc = (HttpURLConnection) c;
-        String method = requestMethod.toUpperCase();
-        hc.setRequestMethod(method);
-        if ("POST".equals(method) && content != null) {
-            hc.setDoOutput(true);
-            byte[] contentBytes = content.getBytes(this.getPostCharset());
-            hc.setFixedLengthStreamingMode(contentBytes.length);
-            OutputStream out = hc.getOutputStream();
-            try {
-            out.write(contentBytes);
-            } finally {
-            out.flush();
-            }
-        }
-        istatus = hc.getResponseCode();
-        istatusText = hc.getResponseMessage();
-        err = hc.getErrorStream();
-        }
-
-        response.setConnectionInfo(c);
-        changeState(HttpRequest.STATE_LOADED, istatus, istatusText, null);
-        InputStream in = err == null ? c.getInputStream() : err;
-        int contentLength = c.getContentLength();
-        changeState(HttpRequest.STATE_INTERACTIVE, istatus, istatusText, null);
-        byte[] bytes = IORoutines.load(in, contentLength == -1 ? 4096 : contentLength);
-        changeState(HttpRequest.STATE_COMPLETE, istatus, istatusText, bytes);
-        response.store(requestURL);
-    } finally {
-        synchronized (this) {
-        this.connection = null;
-        }
-    }
+        if( response.loaded )
+        {
+            // Response from cache
+            changeState(HttpRequest.STATE_LOADED);
+            changeState(HttpRequest.STATE_INTERACTIVE);
+            changeState(HttpRequest.STATE_COMPLETE);
+            return;
+        }
+
+        try {
+            URLConnection c;
+            synchronized (this) {
+            c = this.connection;
+            }
+            c.setRequestProperty("User-Agent", this.context.getUserAgent());
+            int istatus = 0;
+            String istatusText = "";
+            InputStream err = null;
+
+            if (c instanceof HttpURLConnection) {
+            HttpURLConnection hc = (HttpURLConnection) c;
+            String method = requestMethod.toUpperCase();
+            hc.setRequestMethod(method);
+            if ("POST".equals(method) && content != null) {
+                hc.setDoOutput(true);
+                byte[] contentBytes = content.getBytes(this.getPostCharset());
+                hc.setFixedLengthStreamingMode(contentBytes.length);
+                OutputStream out = hc.getOutputStream();
+                try {
+                out.write(contentBytes);
+                } finally {
+                out.flush();
+                }
+            }
+            istatus = hc.getResponseCode();
+            istatusText = hc.getResponseMessage();
+            err = hc.getErrorStream();
+            }
+
+            response.setConnectionInfo(c);
+            changeState(HttpRequest.STATE_LOADED, istatus, istatusText, null);
+            InputStream in = err == null ? c.getInputStream() : err;
+            int contentLength = c.getContentLength();
+            changeState(HttpRequest.STATE_INTERACTIVE, istatus, istatusText, null);
+            byte[] bytes = IORoutines.load(in, contentLength == -1 ? 4096 : contentLength);
+            changeState(HttpRequest.STATE_COMPLETE, istatus, istatusText, bytes);
+            response.store(requestURL);
+        } finally {
+            synchronized (this) {
+            this.connection = null;
+            }
+        }
     }
 
@@ -300,9 +300,9 @@
 
     public void addReadyStateChangeListener( final ReadyStateChangeListener listener) {
-    readyEvent.addListener(new GenericEventListener() {
-        public void processEvent(EventObject event) {
-        listener.readyStateChanged();
-        }
-    });
+        readyEvent.addListener(new GenericEventListener() {
+            public void processEvent(EventObject event) {
+            listener.readyStateChanged();
+            }
+        });
     }
 
Index: applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/CacheableUserAgentContext.java
===================================================================
--- applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/CacheableUserAgentContext.java	(revision 13497)
+++ applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/CacheableUserAgentContext.java	(revision 13582)
@@ -14,5 +14,5 @@
     @Override
     public HttpRequest createHttpRequest() {
-    return new CacheableHttpRequest(this, this.getProxy());
+        return new CacheableHttpRequest(this, this.getProxy());
     }
 }
Index: applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/HttpResponse.java
===================================================================
--- applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/HttpResponse.java	(revision 13497)
+++ applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/HttpResponse.java	(revision 13582)
@@ -56,5 +56,5 @@
      */
     public synchronized void changeState(int status, String statusMessage, byte[] bytes) {
-    this.status = status;
+        this.status = status;
         this.statusText = statusMessage;
         this.responseBytes = bytes;
@@ -68,18 +68,18 @@
     private String getAllResponseHeaders(URLConnection c) {
         int idx = 0;
-    String value;
-    StringBuffer buf = new StringBuffer();
-    while((value = c.getHeaderField(idx)) != null) {
-        String key = c.getHeaderFieldKey(idx);
-        if( key != null )
-        {
-        buf.append(key);
-        buf.append("=");
+        String value;
+        StringBuffer buf = new StringBuffer();
+        while((value = c.getHeaderField(idx)) != null) {
+            String key = c.getHeaderFieldKey(idx);
+            if( key != null )
+            {
+            buf.append(key);
+            buf.append("=");
+            }
+            buf.append(value);
+            buf.append("\n");
+            idx++;
         }
-        buf.append(value);
-        buf.append("\n");
-        idx++;
-    }
-    return buf.toString();
+        return buf.toString();
     }
 
@@ -89,6 +89,6 @@
      */
     public void store(URL requestURL) {
-    loaded = true;
-    StorageManager.getInstance().put(requestURL, this);
+        loaded = true;
+        StorageManager.getInstance().put(requestURL, this);
     }
 
@@ -99,5 +99,5 @@
      */
     public static HttpResponse lookup(URL requestURL) {
-    return StorageManager.getInstance().get(requestURL);
+        return StorageManager.getInstance().get(requestURL);
     }
 }
Index: applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/MyHtmlBlockPanel.java
===================================================================
--- applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/MyHtmlBlockPanel.java	(revision 13497)
+++ applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/MyHtmlBlockPanel.java	(revision 13582)
@@ -18,4 +18,9 @@
     private static final long serialVersionUID = -4778865358510293592L;
 
+    public interface ViewUpdateListener {
+        void region_update(int x, int y, int w, int h);
+    }
+    ViewUpdateListener view_update_listener;
+
     /**
      * Constructor
@@ -26,6 +31,8 @@
      * @param frameContext
      */
-    public MyHtmlBlockPanel(Color background, boolean opaque, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext) {
+    public MyHtmlBlockPanel(Color background, boolean opaque, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext,
+    ViewUpdateListener vul) {
         super(background, opaque, pcontext, rcontext, frameContext);
+        view_update_listener = vul;
     }
 
@@ -48,3 +55,8 @@
         this.repaint();
     }
+
+    public void repaint(int x, int y, int width, int height) {
+        super.repaint(x, y, width, height);
+        view_update_listener.region_update(x, y, width, height);
+    }
 }
Index: applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/OpenLayersLayer.java
===================================================================
--- applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/OpenLayersLayer.java	(revision 13497)
+++ applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/OpenLayersLayer.java	(revision 13582)
@@ -25,5 +25,6 @@
  *
  */
-public class OpenLayersLayer extends Layer implements PreferenceChangedListener, PropertyChangeListener {
+public class OpenLayersLayer extends Layer implements PreferenceChangedListener,
+    PropertyChangeListener, MyHtmlBlockPanel.ViewUpdateListener {
 
     private Browser browser;
@@ -33,14 +34,15 @@
      */
     public OpenLayersLayer() {
-    super("OpenLayers");
+        super("OpenLayers");
 
-    this.browser = new Browser(OpenLayersPlugin.pluginDir + "yahoo.html");
+        this.browser = new Browser(OpenLayersPlugin.pluginDir + "yahoo.html", this);
 
-    if( Main.map != null )
-    {
-        LatLon bottomLeft = Main.map.mapView.getLatLon(0,Main.map.mapView.getHeight());
-        LatLon topRight = Main.map.mapView.getLatLon(Main.map.mapView.getWidth(), 0);
-        browser.executeAsyncScript("zoomMapToExtent(" + bottomLeft.lon() + "," + bottomLeft.lat() + "," + topRight.lon() + "," + topRight.lat() + ")");
-    }
+        if( Main.map != null )
+        {
+            LatLon bottomLeft = Main.map.mapView.getLatLon(0,Main.map.mapView.getHeight());
+            LatLon topRight = Main.map.mapView.getLatLon(Main.map.mapView.getWidth(), 0);
+            browser.executeAsyncScript("zoomMapToExtent(" + bottomLeft.lon() + ","
+            + bottomLeft.lat() + "," + topRight.lon() + "," + topRight.lat() + ")");
+        }
     }
 
@@ -50,6 +52,6 @@
     @Override
     public void paint(Graphics g, MapView mv) {
-    setSize(Main.map.mapView.getSize());
-    browser.paint(g);
+        setSize(Main.map.mapView.getSize());
+        browser.paint(g);
     }
 
@@ -58,37 +60,37 @@
      */
     public void setSize(Dimension dim) {
-    browser.setSize(dim);
+        browser.setSize(dim);
     }
 
     @Override
     public Icon getIcon() {
-    return ImageProvider.get("OpenLayers.png");
+        return ImageProvider.get("OpenLayers");
     }
 
     @Override
     public Object getInfoComponent() {
-    return null;
+        return null;
     }
 
     @Override
     public Component[] getMenuEntries() {
-    return new Component[] {
-        new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)),
-        new JMenuItem(new LayerListDialog.DeleteLayerAction(this)),
-        new JSeparator(),
-        // color,
-        new JMenuItem(new RenameLayerAction(associatedFile, this)),
-        new JSeparator(),
-        new JMenuItem(new LayerListPopup.InfoAction(this)) };
+        return new Component[] {
+            new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)),
+            new JMenuItem(new LayerListDialog.DeleteLayerAction(this)),
+            new JSeparator(),
+            // color,
+            new JMenuItem(new RenameLayerAction(associatedFile, this)),
+            new JSeparator(),
+            new JMenuItem(new LayerListPopup.InfoAction(this)) };
     }
 
     @Override
     public String getToolTipText() {
-    return null;
+        return null;
     }
 
     @Override
     public boolean isMergable(Layer other) {
-    return false;
+        return false;
     }
 
@@ -103,11 +105,11 @@
     @Override
     public void destroy() {
-    Main.pref.listener.remove(this);
+        Main.pref.listener.remove(this);
 
-    if( Main.map != null )
-        Main.map.mapView.removePropertyChangeListener(this);
+        if( Main.map != null )
+            Main.map.mapView.removePropertyChangeListener(this);
 
-    OpenLayersPlugin.layer = null;
-    StorageManager.flush();
+        OpenLayersPlugin.layer = null;
+        StorageManager.flush();
     }
 
@@ -116,11 +118,11 @@
 
     public void propertyChange(PropertyChangeEvent evt) {
-    if( !visible )
-        return;
+        if( !visible )
+            return;
 
-        String prop = evt.getPropertyName();
-    if ("center".equals(prop) || "scale".equals(prop)) {
-        zoomToMapView();
-    }
+            String prop = evt.getPropertyName();
+        if ("center".equals(prop) || "scale".equals(prop)) {
+            zoomToMapView();
+        }
     }
 
@@ -130,7 +132,7 @@
         LatLon topRight = Main.map.mapView.getLatLon(Main.map.mapView.getWidth(), 0);
         Object value = browser.executeScript("zoomMapToExtent(" + bottomLeft.lon() + "," + bottomLeft.lat() + "," + topRight.lon() + "," + topRight.lat() + ")");
-        if( value != null && false)
-        {
-            // TODO wrong calculations
+        if (value != null && false) {
+            // TODO: should not be touching Main.map.mapView here as this
+            // causes endless recurrency - should do the scalling ourselves
 
             // Get actual extent from browser
@@ -140,13 +142,21 @@
             double right  = ((Double)array.get(2, null)).doubleValue();
             double top    = ((Double)array.get(3, null)).doubleValue();
-        bottomLeft = new LatLon( bottom, left );
-        topRight   = new LatLon( top, right);
+            bottomLeft = new LatLon(bottom, left);
+            topRight   = new LatLon(top, right);
 
-        BoundingXYVisitor v = new BoundingXYVisitor();
-        v.visit(Main.proj.latlon2eastNorth(bottomLeft));
-        v.visit(Main.proj.latlon2eastNorth(topRight));
-        System.out.println("Recalculating position (" + left + "," + bottom + "," + right + "," + top + ")");
-        Main.map.mapView.recalculateCenterScale(v);
+            BoundingXYVisitor v = new BoundingXYVisitor();
+            v.visit(Main.proj.latlon2eastNorth(bottomLeft));
+            v.visit(Main.proj.latlon2eastNorth(topRight));
+            System.out.println("Recalculating position (" + left + "," + bottom + "," + right + "," + top + ")");
+            Main.map.mapView.recalculateCenterScale(v);
         }
     }
+
+    public void region_update(int x, int y, int w, int h) {
+        String status = browser.getStatus();
+
+        org.openstreetmap.josm.Main.map.mapView.repaint(x, y, w, h);
+
+        org.openstreetmap.josm.Main.map.statusLine.setHelpText(status);
+    }
 }
Index: applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/OpenLayersPlugin.java
===================================================================
--- applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/OpenLayersPlugin.java	(revision 13497)
+++ applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/OpenLayersPlugin.java	(revision 13582)
@@ -25,28 +25,28 @@
 
     public OpenLayersPlugin() {
-    pluginDir = getPluginDir();
-    try {
-        copy("/resources/yahoo.html", "yahoo.html");
-    } catch (FileNotFoundException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
-    } catch (IOException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
-    }
-    StorageManager.initStorage( pluginDir );
-    refreshMenu();
+        pluginDir = getPluginDir();
+        try {
+            copy("/resources/yahoo.html", "yahoo.html");
+        } catch (FileNotFoundException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        StorageManager.initStorage( pluginDir );
+        refreshMenu();
     }
 
     public static void refreshMenu() {
-    JMenuBar menuBar = Main.main.menu;
-    if (menu == null) {
-        menu = new JMenu(tr("OpenLayers"));
-        menuBar.add(menu, 5);
-    } else {
-        menu.removeAll();
-    }
+        JMenuBar menuBar = Main.main.menu;
+        if (menu == null) {
+            menu = new JMenu(tr("OpenLayers"));
+            menuBar.add(menu, 5);
+        } else {
+            menu.removeAll();
+        }
 
-    menu.add(new JMenuItem(new ShowOpenLayersAction("Yahoo")));
+        menu.add(new JMenuItem(new ShowOpenLayersAction("Yahoo")));
     }
 
@@ -58,6 +58,5 @@
     @Override
     public PreferenceSetting getPreferenceSetting() {
-    return null;
+        return null;
     }
-
 }
Index: applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/ShowOpenLayersAction.java
===================================================================
--- applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/ShowOpenLayersAction.java	(revision 13497)
+++ applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/ShowOpenLayersAction.java	(revision 13582)
@@ -10,22 +10,21 @@
 
     public ShowOpenLayersAction(String name) {
-    super(name, "OpenLayers", "Show layer" + name, 0, 0, false);
+        super(name, "OpenLayers", "Show layer "+name, null, false);
     }
 
     public void actionPerformed(ActionEvent e) {
-    final OpenLayersLayer layer = OpenLayersPlugin.layer != null ? OpenLayersPlugin.layer : new OpenLayersLayer();
-    OpenLayersPlugin.layer = layer;
-    Main.main.addLayer(layer);
+        final OpenLayersLayer layer = OpenLayersPlugin.layer != null ? OpenLayersPlugin.layer : new OpenLayersLayer();
+        OpenLayersPlugin.layer = layer;
+        Main.main.addLayer(layer);
 
-    EventQueue.invokeLater(new Runnable() {
-        public void run() {
-        layer.setSize(Main.map.mapView.getSize());
-        }
-    });
+        EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                layer.setSize(Main.map.mapView.getSize());
+            }
+        });
 
-    // Get notifications of scale and position
-    Main.map.mapView.addPropertyChangeListener("scale", layer);
-    Main.map.mapView.addPropertyChangeListener("center", layer);
-
+        // Get notifications of scale and position
+        Main.map.mapView.addPropertyChangeListener("scale", layer);
+        Main.map.mapView.addPropertyChangeListener("center", layer);
     }
 };
Index: applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/StorageManager.java
===================================================================
--- applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/StorageManager.java	(revision 13497)
+++ applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/StorageManager.java	(revision 13582)
@@ -22,40 +22,40 @@
     public static void initStorage(String basedir)
     {
-    if( storage != null ) storage.dispose();
+        if( storage != null ) storage.dispose();
 
-    storage = new StorageManager(basedir);
+        storage = new StorageManager(basedir);
     }
 
     protected StorageManager(String basedir)
     {
-    System.setProperty("net.sf.ehcache.enableShutdownHook", "true");
-    cache = new Cache("OpenLayers", 500, MemoryStoreEvictionPolicy.LRU, true, basedir + "cache", false, 300*24*7, 300, true, 3600*24*7, null);
-    CacheManager.getInstance().addCache(cache);
+        System.setProperty("net.sf.ehcache.enableShutdownHook", "true");
+        cache = new Cache("OpenLayers", 500, MemoryStoreEvictionPolicy.LRU, true, basedir + "cache", false, 300*24*7, 300, true, 3600*24*7, null);
+        CacheManager.getInstance().addCache(cache);
     }
 
     protected void dispose()
     {
-    if( cache != null )
-        cache.dispose();
+        if( cache != null )
+            cache.dispose();
     }
 
     public static StorageManager getInstance()
     {
-    return storage;
+        return storage;
     }
 
     public HttpResponse get(URL key)
     {
-    Element element = cache.get(key);
-    if( element != null )
-        return (HttpResponse)element.getObjectValue();
+        Element element = cache.get(key);
+        if( element != null )
+            return (HttpResponse)element.getObjectValue();
 
-    return null;
+        return null;
     }
 
     public void put(URL key, HttpResponse value)
     {
-    Element element = new Element(key, value);
-    cache.put(element);
+        Element element = new Element(key, value);
+        cache.put(element);
     }
 
@@ -64,6 +64,6 @@
      */
     public static void flush() {
-    if( storage != null )
-        storage.cache.flush();
+        if( storage != null )
+            storage.cache.flush();
     }
 }
