01: /*
02: * SalomeTMF is a Test Management Framework
03: * Copyright (C) 2005 France Telecom R&D
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2 of the License, or (at your option) any later version.
09: *
10: * This library 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 GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: *
19: * @author Marche Mikael
20: *
21: * Contact: mikael.marche@rd.francetelecom.com
22: */
23:
24: package salomeTMF_plug.abbotScriptRunner;
25:
26: import java.io.File;
27:
28: import javax.swing.filechooser.FileFilter;
29:
30: public class abbotFileFilter extends FileFilter {
31: /** Le texte qui sera affiché dans le comboBox du JFileChooser. */
32: private String description;
33: /** Extension de notre fichier (inclus le '.') */
34: private String[] extensions;
35:
36: /**
37: * Constructeur.
38: * @param description, le texte de description pour l'utilisateur.
39: * @param extentions, les extension du fichier
40: */
41: public abbotFileFilter(String description, String[] extensions) {
42: super ();
43: this .description = description;
44: this .extensions = extensions;
45: }
46:
47: /**
48: * Constructeur.
49: * @param description, le texte de description pour l'utilisateur.
50: * @param extention, l'extention du fichier (commencant par '.')
51: */
52: public abbotFileFilter(String description, String extension) {
53: this (description, new String[] { extension });
54: }
55:
56: /**
57: * Indique si le fichier est accepté par le filtre.
58: * @return vrai si le fichier est accepté.
59: */
60: public boolean accept(File file) {
61: if (file.isDirectory()) {
62: return true;
63: }
64:
65: String nomFichier = file.getPath().toLowerCase();
66: int n = extensions.length;
67: for (int i = 0; i < n; i++) {
68: if (nomFichier.endsWith(extensions[i])) {
69: return true;
70: }
71: }
72: return false;
73: }
74:
75: public String getDescription() {
76: return (this.description);
77: }
78: }
|