1 | // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others
|
---|
2 | package cadastre_fr;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.io.File;
|
---|
7 |
|
---|
8 | import javax.swing.filechooser.FileFilter;
|
---|
9 |
|
---|
10 | public class CacheFileUTM20NFilter extends FileFilter {
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Derived from ExtensionFileFilter writen by imi
|
---|
14 | */
|
---|
15 | private final String extension;
|
---|
16 | private final String description;
|
---|
17 |
|
---|
18 | public static CacheFileUTM20NFilter[] filters = {
|
---|
19 | new CacheFileUTM20NFilter("utm1", tr("Guadeloupe Fort-Marigot cache file (.UTM1)")),
|
---|
20 | new CacheFileUTM20NFilter("utm2", tr("Guadeloupe Ste-Anne cache file (.UTM2)")),
|
---|
21 | new CacheFileUTM20NFilter("utm3", tr("Martinique Fort Desaix cache file (.UTM3)"))
|
---|
22 | };
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Construct an extension file filter by giving the extension to check after.
|
---|
26 | *
|
---|
27 | */
|
---|
28 | private CacheFileUTM20NFilter(String extension, String description) {
|
---|
29 | this.extension = extension;
|
---|
30 | this.description = description;
|
---|
31 | }
|
---|
32 |
|
---|
33 | public boolean acceptName(String filename) {
|
---|
34 | String name = filename.toLowerCase();
|
---|
35 | for (String ext : extension.split(","))
|
---|
36 | if (name.endsWith("." + ext))
|
---|
37 | return true;
|
---|
38 | return false;
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Override
|
---|
42 | public boolean accept(File pathname) {
|
---|
43 | if (pathname.isDirectory())
|
---|
44 | return true;
|
---|
45 | return acceptName(pathname.getName());
|
---|
46 | }
|
---|
47 |
|
---|
48 | @Override
|
---|
49 | public String getDescription() {
|
---|
50 | return description;
|
---|
51 | }
|
---|
52 |
|
---|
53 | }
|
---|