View Javadoc

1   /* OpenLogViewer
2    *
3    * Copyright 2011
4    *
5    * This file is part of the OpenLogViewer project.
6    *
7    * OpenLogViewer software is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU General Public License as published by
9    * the Free Software Foundation, either version 3 of the License, or
10   * (at your option) any later version.
11   *
12   * OpenLogViewer software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with any OpenLogViewer software.  If not, see http://www.gnu.org/licenses/
19   *
20   * I ask that if you make any changes to this file you fork the code on github.com!
21   *
22   */
23  package org.diyefi.openlogviewer.filefilters;
24  
25  import java.io.File;
26  import java.util.ResourceBundle;
27  
28  import javax.swing.filechooser.FileFilter;
29  
30  import org.diyefi.openlogviewer.FileExtensions;
31  import org.diyefi.openlogviewer.Text;
32  import org.diyefi.openlogviewer.utils.Utilities;
33  
34  public class MSTypeFileFilter extends FileFilter {
35  	private final ResourceBundle labels;
36  
37  	public MSTypeFileFilter(final ResourceBundle labels) {
38  		this.labels = labels;
39  	}
40  
41  	@Override
42  	public final String getDescription() {
43  		return labels.getString(Text.MS_COMPATIBLE_LOGS);
44  	}
45  
46  	@Override
47  	public final boolean accept(final File file) {
48  		if (file.isDirectory()) {
49  			return true;
50  		}
51  
52  		final String extension = Utilities.getExtension(file);
53  
54  		if (FileExtensions.LOG.equals(extension)) {
55  			return true;
56  		} else if (FileExtensions.CSV.equals(extension)) {
57  			return true;
58  		} else if (FileExtensions.XLS.equals(extension)) {
59  			return true;
60  		} else if (FileExtensions.MSL.equals(extension)) {
61  			return true;
62  		}
63  
64  		return false;
65  	}
66  }