01: /*
02: JSmooth: a VM wrapper toolkit for Windows
03: Copyright (C) 2003 Rodrigo Reyes <reyes@charabia.net>
04:
05: This program is free software; you can redistribute it and/or modify
06: it under the terms of the GNU General Public License as published by
07: the Free Software Foundation; either version 2 of the License, or
08: (at your option) any later version.
09:
10: This program is distributed in the hope that it will be useful,
11: but WITHOUT ANY WARRANTY; without even the implied warranty of
12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: GNU General Public License for more details.
14:
15: You should have received a copy of the GNU General Public License
16: along with this program; if not, write to the Free Software
17: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18:
19: */
20:
21: package net.charabia.jsmoothgen.application.gui.util;
22:
23: public class SimpleFileFilter extends
24: javax.swing.filechooser.FileFilter {
25: private String m_suffix;
26: private String m_description;
27:
28: /** Creates a new instance of SimpleFileFilter */
29: public SimpleFileFilter(String suffix, String desc) {
30: m_suffix = suffix;
31: m_description = desc;
32: }
33:
34: public boolean accept(java.io.File f) {
35: String suffix = getSuffix(f);
36: if (suffix.equalsIgnoreCase(m_suffix))
37: return true;
38: if (f.isDirectory())
39: return true;
40:
41: return false;
42: }
43:
44: public String getDescription() {
45: return m_description;
46: }
47:
48: private String getSuffix(java.io.File f) {
49: String fstr = f.getAbsolutePath();
50: int lastDot = fstr.lastIndexOf('.');
51: if ((lastDot >= 0) && ((lastDot + 1) < fstr.length())) {
52: return fstr.substring(lastDot + 1);
53: }
54: return "";
55: }
56:
57: }
|