Gridarta Editor
HideFileFilterProxy.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
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 along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.utils;
21 
22 import java.io.File;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.Collection;
26 import javax.swing.filechooser.FileFilter;
27 import net.sf.japi.util.filter.file.AbstractFileFilter;
28 import org.jetbrains.annotations.NotNull;
29 
36 public class HideFileFilterProxy extends AbstractFileFilter {
37 
41  @NotNull
42  private final FileFilter other;
43 
47  @NotNull
48  @SuppressWarnings("StaticCollection")
49  private static final Collection<String> REJECTED_DIRECTORY_NAMES = Arrays.asList("CVS", ".git", ".svn");
50 
54  @NotNull
55  private final Collection<String> rejectedDirectoryNames = new ArrayList<>();
56 
61  public HideFileFilterProxy(@NotNull final FileFilter other) {
62  this.other = other;
64  }
65 
70  @NotNull
71  @Override
72  public String getDescription() {
73  return other.getDescription();
74  }
75 
80  @SuppressWarnings("ParameterNameDiffersFromOverriddenParameter")
81  @Override
82  public boolean accept(@NotNull final File pathName) {
83  if (pathName.getName().startsWith(".")) {
84  return false;
85  }
86  // XXX suppression for Bug in IDEA
87  return (!pathName.isDirectory() || !rejectedDirectoryNames.contains(pathName.getName())) && ((java.io.FileFilter) other).accept(pathName);
88  }
89 
90 }
net.sf.gridarta.utils.HideFileFilterProxy.getDescription
String getDescription()
Definition: HideFileFilterProxy.java:72
net.sf.gridarta.utils.HideFileFilterProxy.other
final FileFilter other
Definition: HideFileFilterProxy.java:42
net.sf
net
net.sf.gridarta.utils.HideFileFilterProxy.REJECTED_DIRECTORY_NAMES
static final Collection< String > REJECTED_DIRECTORY_NAMES
Definition: HideFileFilterProxy.java:49
net.sf.gridarta.utils.HideFileFilterProxy.accept
boolean accept(@NotNull final File pathName)
Definition: HideFileFilterProxy.java:82
net.sf.gridarta.utils.HideFileFilterProxy
Definition: HideFileFilterProxy.java:36
net.sf.gridarta.utils.HideFileFilterProxy.rejectedDirectoryNames
final Collection< String > rejectedDirectoryNames
Definition: HideFileFilterProxy.java:55