Changeset 20412 in osm for applications


Ignore:
Timestamp:
2010-03-11T00:58:51+01:00 (15 years ago)
Author:
pieren
Message:

improve download cancellation

Location:
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java

    r19267 r20412  
    6565    final  int cRetriesGetCookie = 10; // 10 times every 3 seconds means 30 seconds trying to get a cookie
    6666
    67     public boolean retrieveInterface(WMSLayer wmsLayer) throws DuplicateLayerException {
     67    public boolean retrieveInterface(WMSLayer wmsLayer) throws DuplicateLayerException, WMSException {
    6868        if (wmsLayer.getName().equals(""))
    6969            return false;
     
    7575            if (cookie == null || isCookieExpired())
    7676                getCookie();
    77             if (cookie != null && interfaceRef == null) {
     77            if (cookie == null)
     78                throw new WMSException(tr("Cannot open a new client session.\nServer in maintenance or temporary overloaded."));
     79            if (interfaceRef == null) {
    7880                    getInterface(wmsLayer);
    7981                    this.lastWMSLayerName = wmsLayer.getName();
    80             } else {
    81                 JOptionPane.showMessageDialog(Main.parent,
    82                         tr("Cannot open a new client session.\nServer in maintenance or temporary overloaded."));
    83                 return false;
    8482            }
    8583            openInterface();
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java

    r20390 r20412  
    9090 * 1.6 28-Nov-2009 - Fix minor issues if Grab is called without layer (possible since projection rework)
    9191 * 1.7 12-Dec-2009 - Change URL's changes for cookie and downgrade imgs resolution due to WMS changes
    92  * 1.8 09-Mar-2010 - filter the mouse button 1 during georeferencing
     92 * 1.8 11-Mar-2010 - filter the mouse button 1 during georeferencing
    9393 *                 - retry if getting a new cookie failed (10 times during 30 seconds)
    9494 *                 - cookie expiration automatically detected and renewed (after 30 minutes)
     
    101101 *                 - image resolution configurable (high, medium, low) like the online interface
    102102 *                 - layer selection configurable for vectorized images
     103 *                 - improved download cancellation
    103104 *                 - from Erik Amzallag:
    104105 *                 -     possibility to modify the auto-sourcing text just before upload
    105106 *                 - from Clément Ménier:
    106107 *                 -     new option allowing an auto-selection of the first cadastre layer for grab
    107  *                 -     non-modal JDialog in MenuActionGrabPlanImage 
     108 *                 -     non-modal JDialog in MenuActionGrabPlanImage
     109 *                 -     new options in the image filter (bilinear, bicubic)
    108110 */
    109111public class CadastrePlugin extends Plugin {
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java

    r20390 r20412  
    4242    private static EastNorthBound currentView = null;
    4343    private EastNorthBound viewBox = null;
     44    private static String errorMessage;
     45
    4446
    4547    public DownloadSVGBuilding(WMSLayer wmsLayer) {
     
    5355    public void realRun() throws IOException, OsmTransferException {
    5456        progressMonitor.indeterminateSubTask(tr("Contacting WMS Server..."));
     57        errorMessage = null;
    5558        try {
    5659            if (wmsInterface.retrieveInterface(wmsLayer)) {
     
    6568        } catch (DuplicateLayerException e) {
    6669            System.err.println("removed a duplicated layer");
     70        } catch (WMSException e) {
     71            errorMessage = e.getMessage();
     72            grabber.getWmsInterface().resetCookie();
    6773        }
    6874    }
     
    272278        }
    273279        Main.worker.execute(new DownloadSVGBuilding(wmsLayer));
     280        if (errorMessage != null)
     281            JOptionPane.showMessageDialog(Main.parent, errorMessage);
    274282    }
    275283
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGTask.java

    r20390 r20412  
    4646    private String svg = null;
    4747    private EastNorthBound viewBox = null;
     48    private static String errorMessage;
    4849
    4950    public DownloadSVGTask(WMSLayer wmsLayer) {
     
    5758    public void realRun() throws IOException, OsmTransferException {
    5859        progressMonitor.indeterminateSubTask(tr("Contacting WMS Server..."));
     60        errorMessage = null;
    5961        try {
    6062            if (wmsInterface.retrieveInterface(wmsLayer)) {
     
    7173        } catch (DuplicateLayerException e) {
    7274            System.err.println("removed a duplicated layer");
     75        } catch (WMSException e) {
     76            errorMessage = e.getMessage();
     77            grabber.getWmsInterface().resetCookie();
    7378        }
    7479    }
     
    218223        }
    219224        Main.worker.execute(new DownloadSVGTask(wmsLayer));
     225        if (errorMessage != null)
     226            JOptionPane.showMessageDialog(Main.parent, errorMessage);
    220227    }
    221228
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSPlanImage.java

    r20390 r20412  
    2121    private Bounds bounds;
    2222    private boolean dontGeoreference = false;
     23    private static String errorMessage;
    2324   
    2425    private class Task extends PleaseWaitRunnable {
     
    3132        public void realRun() throws IOException {
    3233            progressMonitor.indeterminateSubTask(tr("Contacting cadastre WMS ..."));
     34            errorMessage = null;
    3335            try {
    3436                if (grabber.getWmsInterface().retrieveInterface(wmsLayer)) {
     
    8587                // we tried to grab onto a duplicated layer (removed)
    8688                System.err.println("removed a duplicated layer");
     89            } catch (WMSException e) {
     90                errorMessage = e.getMessage();
     91                grabber.getWmsInterface().resetCookie();
    8792            }
    8893        }
     
    108113        this.bounds = bounds;
    109114        task = Main.worker.submit(t, t);
     115        if (errorMessage != null)
     116            JOptionPane.showMessageDialog(Main.parent, errorMessage);
    110117    }
    111118
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java

    r20390 r20412  
    55
    66import java.io.IOException;
     7
     8import javax.swing.JOptionPane;
    79
    810import org.openstreetmap.josm.Main;
     
    1416
    1517    private WMSLayer wmsLayer;
    16 
    17     private Bounds bounds;
    18    
    19     private CadastreGrabber grabber = CadastrePlugin.cadastreGrabber;
     18    private Bounds bounds;   
     19    private CadastreGrabber grabber = CadastrePlugin.cadastreGrabber;   
     20    private static String errorMessage;
    2021
    2122    public DownloadWMSVectorImage(WMSLayer wmsLayer, Bounds bounds, boolean buildingsOnly) {
     
    3031    public void realRun() throws IOException {
    3132        progressMonitor.indeterminateSubTask(tr("Contacting WMS Server..."));
     33        errorMessage = null;
    3234        try {
    3335            if (grabber.getWmsInterface().retrieveInterface(wmsLayer)) {
     
    6264            // we tried to grab onto a duplicated layer (removed)
    6365            System.err.println("removed a duplicated layer");
     66        } catch (WMSException e) {
     67            errorMessage = e.getMessage();
     68            grabber.getWmsInterface().resetCookie();
    6469        }
    6570    }
     
    6873    protected void cancel() {
    6974        grabber.getWmsInterface().cancel();
     75        if (wmsLayer != null)
     76            wmsLayer.cancelled = true;
    7077    }
    7178
     
    7986
    8087        Main.worker.execute(new DownloadWMSVectorImage(wmsLayer, bounds, buildingsOnly));
    81 
     88        if (errorMessage != null)
     89            JOptionPane.showMessageDialog(Main.parent, errorMessage);
    8290    }
    8391}
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java

    r20390 r20412  
    7272    public EastNorthBound communeBBox = new EastNorthBound(new EastNorth(0,0), new EastNorth(0,0));
    7373
     74    public boolean cancelled;
     75
    7476    private boolean isRaster = false;
    7577    private boolean isAlreadyGeoreferenced = false;
     
    132134   
    133135    public void grab(CadastreGrabber grabber, Bounds b, boolean useFactor) throws IOException {
     136        cancelled = false;
    134137        if (useFactor) {
    135138            if (isRaster) {
     
    146149        int lastSavedImage = images.size();
    147150        for (EastNorthBound n : dividedBbox) {
     151            if (cancelled)
     152                return;
    148153            GeorefImage newImage;
    149154            try {
Note: See TracChangeset for help on using the changeset viewer.