View Javadoc
1 /* 2 3 4 Copyright (C) 2003 Together 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public 8 License as published by the Free Software Foundation; either 9 version 2.1 of the License, or (at your option) any later version. 10 11 This library is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Lesser General Public License for more details. 15 16 You should have received a copy of the GNU Lesser General Public 17 License along with this library; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 21 package org.webdocwf.util.loader.wizard; 22 23 import java.io.File; 24 25 /*** 26 * DomlFilter restricts file sets to only those files that are 27 * .doml files. Use this with JFileChooser to create a directory 28 * chooser. 29 * 30 * 31 * @author Radoslav Dutina 32 * @author Zoran Milakovic 33 */ 34 public class OctopusFileFilter extends javax.swing.filechooser.FileFilter { 35 36 public static final int OLJ = 0; 37 public static final int OPF = 1; 38 int type = 0; 39 40 /*** 41 * Create a FileFilter for use with the FileChooser dialog. 42 * Default is olj file filter. 43 */ 44 public OctopusFileFilter() { 45 this.type = 0; 46 } 47 48 /*** 49 * Create a DomlFilter for use with the FileChooser dialog. 50 */ 51 public OctopusFileFilter(int type) { 52 this.type = type; 53 } 54 55 /*** 56 * Check to see if the passed file is a directory. 57 * 58 * @param f File to check. 59 * 60 * @return True if the file is a doml file (.doml). 61 * 62 */ 63 public boolean accept(File f) { 64 switch(type) { 65 case 0: 66 return f.getName().endsWith(".olj") || f.isDirectory(); 67 case 1: 68 return f.getName().endsWith(".opf") || f.isDirectory(); 69 default: 70 return f.getName().endsWith(".olj") || f.isDirectory(); 71 } 72 } 73 74 /*** 75 * Get a description of this filter. 76 * 77 * @return The description of this filter. 78 * 79 */ 80 public String getDescription() { 81 switch(type) { 82 case 0: 83 return new String(".olj"); 84 case 1: 85 return new String(".opf"); 86 default: 87 return new String(".olj"); 88 } 89 } 90 }

This page was automatically generated by Maven