001 /* steelme theme manager for Java
002 * Copyright (C) 2000 - 2004 T.J. Willis
003 *
004 * This program is free software; you can redistribute it and/or
005 * modify it under the terms of the GNU General Public License
006 * as published by the Free Software Foundation; either version 2
007 * of the License, or (at your option) any later version.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012 * GNU General Public License for more details.
013 *
014 * You should have received a copy of the GNU General Public License
015 * along with this program; if not, write to the Free Software
016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
017 *
018 * $Header: /cvsroot/steelme/steelme/src/net/sourceforge/steelme/ThemeFileFilter.java,v 1.1.1.1 2004/05/10 14:28:30 tj_willis Exp $
019 */
020 package net.sourceforge.steelme;
021
022 import java.io.File;
023
024
025
026 /**
027 * A FileFilter that accepts only Theme files.
028 *
029 * @author <a href="mailto:tj_willis@users.sourceforge.net">T.J. Willis</a>
030 * @version $Revision: 1.1.1.1 $
031 */
032 public class ThemeFileFilter
033 extends javax.swing.filechooser.FileFilter
034 implements java.io.FileFilter {
035
036 /**
037 * Returns true if f is a Theme file.
038 *
039 * @param f a <code>File</code> value
040 * @return a <code>boolean</code> value
041 */
042 public boolean accept(File f) {
043 if(f==null)
044 return false;
045 return checkName(f.getName());
046
047
048 }
049
050 /**
051 * Determines if name represents a Theme file/entry name.
052 *
053 * @param name a <code>String</code> value
054 * @return a <code>boolean</code> value
055 */
056 protected boolean checkName(String name) {
057 if(name==null)
058 return false;
059 if(name.endsWith(".theme"))
060 return true;
061 if(name.endsWith(".THEME"))
062 return true;
063 if(name.endsWith(".Theme"))
064 return true;
065 return false;
066 }
067
068 /**
069 * Returns description of this file filter.
070 *
071 * @return a <code>String</code> value
072 */
073 public String getDescription() {
074 return "Steelme Themes";
075 }
076
077
078 }