Changeset 18838 in osm for applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
- Timestamp:
- 2009-11-28T17:05:44+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
r18720 r18838 106 106 // till here 107 107 108 if (reply == JOptionPane.OK_OPTION) { 109 return loadCache(file, wmsLayer.getLambertZone()); 110 } else 111 file.delete(); 108 if (reply == JOptionPane.OK_OPTION && loadCache(file, wmsLayer.getLambertZone())) { 109 return true; 110 } else { 111 delete(file); 112 } 112 113 } 113 114 } catch (Exception e) { … … 122 123 if (Main.proj instanceof LambertCC9Zones) 123 124 extension = cLambertCC9Z + extension; 124 File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + extension); 125 if (file.exists()) 126 file.delete(); 125 delete(new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + extension)); 127 126 } catch (Exception e) { 128 127 e.printStackTrace(System.out); 129 128 } 130 129 } 130 131 private void delete(File file) { 132 System.out.println("Delete file "+file); 133 if (file.exists()) 134 file.delete(); 135 while (file.exists()) // wait until file is really gone (otherwise appends to existing one) 136 CadastrePlugin.safeSleep(500); 137 } 131 138 132 139 public boolean loadCache(File file, int currentLambertZone) { 140 boolean successfulRead = false; 133 141 try { 134 142 FileInputStream fis = new FileInputStream(file); 135 143 ObjectInputStream ois = new ObjectInputStream(fis); 136 if (wmsLayer.read(ois, currentLambertZone) == false) 137 return false; 144 successfulRead = wmsLayer.read(ois, currentLambertZone); 138 145 ois.close(); 139 146 fis.close(); 140 147 } catch (Exception ex) { 141 148 ex.printStackTrace(System.out); 142 JOptionPane.showMessageDialog(Main.parent, tr("Error loading file"), tr("Error"), JOptionPane.ERROR_MESSAGE); 149 JOptionPane.showMessageDialog(Main.parent, tr("Error loading file.\nProbably an old version of the cache file."), tr("Error"), JOptionPane.ERROR_MESSAGE); 143 150 return false; 144 151 } 145 if (wmsLayer.isRaster()) { 152 if (successfulRead && wmsLayer.isRaster()) { 146 153 // serialized raster bufferedImage hangs-up on Java6. Recreate them here 147 154 wmsLayer.images.get(0).image = RasterImageModifier.fixRasterImage(wmsLayer.images.get(0).image); 148 155 } 149 return true;156 return successfulRead; 150 157 } 151 158
Note:
See TracChangeset
for help on using the changeset viewer.
