Revision 1872
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.util/org.gvsig.tools.util.api/src/main/java/org/gvsig/filedialogchooser/FileDialogChooser.java | ||
---|---|---|
6 | 6 |
package org.gvsig.filedialogchooser; |
7 | 7 |
|
8 | 8 |
import java.awt.Component; |
9 |
import java.beans.PropertyChangeListener; |
|
9 | 10 |
import java.io.File; |
11 |
import javax.swing.JComponent; |
|
10 | 12 |
import javax.swing.JFileChooser; |
11 | 13 |
import javax.swing.filechooser.FileFilter; |
12 | 14 |
|
... | ... | |
87 | 89 |
public void addChoosableFileFilter(FileFilter next); |
88 | 90 |
|
89 | 91 |
public FileFilter getFileFilter(); |
92 |
|
|
93 |
public void setAccessory(JComponent newAccessory); |
|
94 |
|
|
95 |
public void addPropertyChangeListener(PropertyChangeListener listener); |
|
90 | 96 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/filedialogchooser/impl/VFSJFileChooserBased.java | ||
---|---|---|
8 | 8 |
import com.googlecode.vfsjfilechooser2.VFSJFileChooser; |
9 | 9 |
import com.googlecode.vfsjfilechooser2.filechooser.AbstractVFSFileFilter; |
10 | 10 |
import java.awt.Component; |
11 |
import java.beans.PropertyChangeListener; |
|
11 | 12 |
import java.io.File; |
13 |
import javax.swing.JComponent; |
|
12 | 14 |
import javax.swing.filechooser.FileFilter; |
13 | 15 |
import org.apache.commons.vfs2.FileObject; |
14 | 16 |
import org.apache.commons.vfs2.provider.local.LocalFile; |
... | ... | |
197 | 199 |
this.jfc.addChoosableFileFilter(new FileFilterAdapter(next)); |
198 | 200 |
} |
199 | 201 |
|
202 |
@Override |
|
203 |
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
204 |
this.jfc.addPropertyChangeListener(listener); |
|
205 |
} |
|
206 |
|
|
207 |
@Override |
|
208 |
public void setAccessory(JComponent newAccessory) { |
|
209 |
this.jfc.setAccessory(newAccessory); |
|
210 |
} |
|
211 |
|
|
200 | 212 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/filedialogchooser/impl/JFileChooserBased.java | ||
---|---|---|
50 | 50 |
manager.setLastPath(fileChooserID, this.getCurrentDirectory()); |
51 | 51 |
} |
52 | 52 |
return r; |
53 |
} |
|
53 |
}
|
|
54 | 54 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/folders/impl/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(); |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/folders/FoldersManager.java | ||
---|---|---|
26 | 26 |
import java.io.File; |
27 | 27 |
import java.io.IOException; |
28 | 28 |
import java.util.Iterator; |
29 |
import java.util.Map; |
|
29 | 30 |
|
30 | 31 |
|
31 | 32 |
/** |
... | ... | |
144 | 145 |
|
145 | 146 |
public File getLastPath(String pathId, File defaultValue); |
146 | 147 |
|
148 |
public Iterator<Map.Entry<String,File>> lastPathsIterator(); |
|
149 |
|
|
147 | 150 |
public void setLastPath(String pathId, File value); |
148 | 151 |
} |
Also available in: Unified diff