gvsig-3d / 2.1 / branches / org.gvsig.view3d_vector_and_extrusion_2.3 / org.gvsig.view3d / org.gvsig.view3d / org.gvsig.view3d.swing / org.gvsig.view3d.swing.impl / src / main / java / org / gvsig / view3d / swing / impl / data / DefaultConfigurableDataFileStore.java @ 708
History | View | Annotate | Download (1.73 KB)
1 |
package org.gvsig.view3d.swing.impl.data; |
---|---|
2 |
|
3 |
import gov.nasa.worldwind.cache.BasicDataFileStore; |
4 |
|
5 |
import java.io.File; |
6 |
|
7 |
import org.gvsig.view3d.swing.api.View3DSwingLocator; |
8 |
import org.gvsig.view3d.swing.api.View3DSwingManager; |
9 |
import org.gvsig.view3d.swing.api.properties.GeneralProperties3D; |
10 |
|
11 |
public class DefaultConfigurableDataFileStore extends BasicDataFileStore |
12 |
implements ConfigurableFileStore {
|
13 |
|
14 |
|
15 |
public DefaultConfigurableDataFileStore() {
|
16 |
super();
|
17 |
|
18 |
setDefaultCachePath(); |
19 |
} |
20 |
|
21 |
public DefaultConfigurableDataFileStore(File directoryPath ){ |
22 |
super(directoryPath);
|
23 |
|
24 |
setDefaultCachePath(); |
25 |
} |
26 |
|
27 |
private void setDefaultCachePath() { |
28 |
|
29 |
View3DSwingManager swingManager = View3DSwingLocator.getManager(); |
30 |
GeneralProperties3D general3dProperties = swingManager.getGeneral3DProperties(); |
31 |
|
32 |
setWriteLocation(general3dProperties.getCachePath()); |
33 |
} |
34 |
|
35 |
public void setWriteLocation(File writeLocation) { |
36 |
|
37 |
if(!writeLocation.exists()){
|
38 |
writeLocation.mkdirs(); |
39 |
} |
40 |
|
41 |
if (writeLocation.isDirectory() && writeLocation.canWrite()
|
42 |
&& writeLocation.canRead()) { |
43 |
|
44 |
// Remove the writable location from search path if it already
|
45 |
// exists.
|
46 |
StoreLocation oldLocation = |
47 |
this.storeLocationFor(this.writeLocation.getFile().getAbsolutePath()); |
48 |
if (oldLocation != null) |
49 |
this.readLocations.remove(oldLocation);
|
50 |
|
51 |
this.writeLocation = new StoreLocation(writeLocation); |
52 |
|
53 |
// Writable location is always first in search path.
|
54 |
this.readLocations.add(0, this.writeLocation); |
55 |
} |
56 |
} |
57 |
} |