Revision 1872 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/folders/impl/DefaultFoldersManager.java
DefaultFoldersManager.java | ||
---|---|---|
31 | 31 |
import java.util.HashMap; |
32 | 32 |
import java.util.Iterator; |
33 | 33 |
import java.util.Map; |
34 |
import java.util.Set; |
|
34 | 35 |
import javax.swing.filechooser.FileSystemView; |
35 | 36 |
import org.apache.commons.io.FileUtils; |
36 | 37 |
import org.apache.commons.io.FilenameUtils; |
37 | 38 |
import org.apache.commons.io.IOUtils; |
38 | 39 |
import org.apache.commons.lang3.StringUtils; |
40 |
import org.apache.commons.lang3.tuple.ImmutablePair; |
|
39 | 41 |
import org.gvsig.tools.folders.FoldersManager; |
40 | 42 |
import org.slf4j.Logger; |
41 | 43 |
import org.slf4j.LoggerFactory; |
... | ... | |
82 | 84 |
|
83 | 85 |
@Override |
84 | 86 |
public void setLastPath(String pathId, File path) { |
87 |
if( StringUtils.isBlank(pathId) ) { |
|
88 |
throw new IllegalArgumentException("Invalid argument pathId, it is a blank string."); |
|
89 |
} |
|
85 | 90 |
this.getFolders().put("last.path." + pathId, path); |
86 | 91 |
} |
87 | 92 |
|
88 | 93 |
@Override |
89 | 94 |
public File getLastPath(String pathId, File defaultValue) { |
90 |
File path = this.getFolders().get("last.path." + pathId); |
|
95 |
if( !StringUtils.isBlank(pathId) ) { |
|
96 |
File path = this.getFolders().get("last.path." + pathId); |
|
91 | 97 |
|
92 |
if (path != null) { |
|
93 |
return path; |
|
98 |
if (path != null) { |
|
99 |
return path; |
|
100 |
} |
|
94 | 101 |
} |
95 | 102 |
if (defaultValue != null) { |
96 | 103 |
return defaultValue; |
... | ... | |
98 | 105 |
return FileSystemView.getFileSystemView().getHomeDirectory(); |
99 | 106 |
} |
100 | 107 |
|
108 |
@Override |
|
109 |
public Iterator<Map.Entry<String, File>> lastPathsIterator() { |
|
110 |
final Iterator<Map.Entry<String, File>> it0 = this.getFolders().entrySet().iterator(); |
|
111 |
Iterator<Map.Entry<String, File>> it = new Iterator<Map.Entry<String, File>>() { |
|
112 |
Map.Entry<String, File> last = null; |
|
113 |
@Override |
|
114 |
public boolean hasNext() { |
|
115 |
while(it0.hasNext() ) { |
|
116 |
last = it0.next(); |
|
117 |
if( StringUtils.startsWithIgnoreCase(last.getKey(), "last.path.")) { |
|
118 |
return true; |
|
119 |
} |
|
120 |
} |
|
121 |
return false; |
|
122 |
} |
|
123 |
|
|
124 |
@Override |
|
125 |
public Map.Entry<String, File> next() { |
|
126 |
if( last==null ) { |
|
127 |
return null; |
|
128 |
} |
|
129 |
return new ImmutablePair<>( |
|
130 |
last.getKey().substring(10), |
|
131 |
last.getValue() |
|
132 |
); |
|
133 |
} |
|
134 |
}; |
|
135 |
return it; |
|
136 |
} |
|
137 |
|
|
101 | 138 |
private int getPID() { |
102 | 139 |
try { |
103 | 140 |
RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean(); |
Also available in: Unified diff