- Timestamp:
- 2012-02-18T14:26:14+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
r4825 r4985 20 20 import java.io.StringReader; 21 21 import java.net.URL; 22 import java.util.*; 22 import java.util.ArrayList; 23 import java.util.Collections; 24 import java.util.HashSet; 25 import java.util.LinkedList; 26 import java.util.List; 27 import java.util.Map; 23 28 import java.util.Map.Entry; 29 import java.util.Scanner; 24 30 import java.util.concurrent.Callable; 25 31 import java.util.regex.Matcher; … … 39 45 import org.openstreetmap.gui.jmapviewer.MemoryTileCache; 40 46 import org.openstreetmap.gui.jmapviewer.OsmFileCacheTileLoader; 47 import org.openstreetmap.gui.jmapviewer.OsmFileCacheTileLoader.TileClearController; 41 48 import org.openstreetmap.gui.jmapviewer.OsmTileLoader; 42 49 import org.openstreetmap.gui.jmapviewer.Tile; … … 64 71 import org.openstreetmap.josm.gui.MapView; 65 72 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 73 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 66 74 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 67 75 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 76 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 77 import org.openstreetmap.josm.gui.progress.ProgressMonitor.CancelListener; 68 78 import org.openstreetmap.josm.io.CacheCustomContent; 79 import org.openstreetmap.josm.io.OsmTransferException; 69 80 import org.openstreetmap.josm.io.UTFInputStreamReader; 70 81 import org.xml.sax.InputSource; 82 import org.xml.sax.SAXException; 71 83 72 84 /** … … 137 149 return tileCache; 138 150 } 139 140 void clearTileCache() 151 152 private class TmsTileClearController implements TileClearController, CancelListener { 153 154 private final ProgressMonitor monitor; 155 private boolean cancel = false; 156 157 public TmsTileClearController(ProgressMonitor monitor) { 158 this.monitor = monitor; 159 this.monitor.addCancelListener(this); 160 } 161 162 @Override 163 public void initClearDir(File dir) { 164 } 165 166 @Override 167 public void initClearFiles(File[] files) { 168 monitor.setTicksCount(files.length); 169 monitor.setTicks(0); 170 } 171 172 @Override 173 public boolean cancel() { 174 return cancel; 175 } 176 177 @Override 178 public void fileDeleted(File file) { 179 monitor.setTicks(monitor.getTicks()+1); 180 } 181 182 @Override 183 public void clearFinished() { 184 monitor.finishTask(); 185 } 186 187 @Override 188 public void operationCanceled() { 189 cancel = true; 190 } 191 } 192 193 void clearTileCache(ProgressMonitor monitor) 141 194 { 142 195 tileCache.clear(); 143 196 if (tileLoader instanceof OsmFileCacheTileLoader) { 144 ((OsmFileCacheTileLoader)tileLoader).clearCache(tileSource );197 ((OsmFileCacheTileLoader)tileLoader).clearCache(tileSource, new TmsTileClearController(monitor)); 145 198 } 146 199 } … … 512 565 @Override 513 566 public void actionPerformed(ActionEvent ae) { 514 clearTileCache(); 567 new PleaseWaitRunnable(tr("Flush Tile Cache")) { 568 569 @Override 570 protected void realRun() throws SAXException, IOException, 571 OsmTransferException { 572 clearTileCache(getProgressMonitor()); 573 } 574 575 @Override 576 protected void finish() { 577 } 578 579 @Override 580 protected void cancel() { 581 } 582 }.run(); 583 515 584 } 516 585 }));
Note:
See TracChangeset
for help on using the changeset viewer.