00001 package edu.ksu.cis.bandera.bui;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 import javax.swing.*;
00036 import javax.swing.filechooser.*;
00037
00038 public class FileChooser extends JFileChooser {
00039 public static FileChooser chooser;
00040 public static FileFilter ALL;
00041 public static FileFilter JAVA;
00042 public static FileFilter CLASSPATH;
00043 public static FileFilter PATTERN;
00044 public static FileFilter DIRECTORY;
00045 public static FileFilter SESSION;
00046 public static FileFilter SPECIFICATION;
00047 public static FileFilter ABSTRACTION;
00048 public static FileFilter BASL;
00049 public static FileFilter CLASS;
00050
00051
00052
00053 private FileChooser() {
00054 }
00055
00056
00057
00058 public static void initialize() {
00059 chooser = new FileChooser();
00060 class AllFilter extends FileFilter {
00061 public String ext = "*.*";
00062 public String description = "All files";
00063 public boolean accept(java.io.File f) {
00064 if (f != null) {
00065 if (f.isDirectory())
00066 return true;
00067 else
00068 if (ext == null)
00069 return false;
00070 else
00071 if (("*.*".equals(ext)) || f.getAbsolutePath().endsWith(ext))
00072 return true;
00073 }
00074 return false;
00075 }
00076 public String getDescription() {
00077 return description;
00078 }
00079 };
00080 class JavaFilter extends FileFilter {
00081 public boolean accept(java.io.File f) {
00082 if (f != null) {
00083 if (f.isDirectory())
00084 return true;
00085 else
00086 if (f.getAbsolutePath().endsWith(".java"))
00087 return true;
00088 }
00089 return false;
00090 }
00091 public String getDescription() {
00092 return "Java source code";
00093 }
00094 };
00095 class ClasspathFilter extends FileFilter {
00096 public boolean accept(java.io.File f) {
00097 if (f != null) {
00098 if (f.isDirectory())
00099 return true;
00100 else
00101 if (f.getAbsolutePath().endsWith(".jar") || f.getAbsolutePath().endsWith(".zip"))
00102 return true;
00103 }
00104 return false;
00105 }
00106 public String getDescription() {
00107 return "Jar files, Zip files and directories";
00108 }
00109 };
00110 class PatternFilter extends FileFilter {
00111 public boolean accept(java.io.File f) {
00112 if (f != null) {
00113 if (f.isDirectory())
00114 return true;
00115 else
00116 if (f.getAbsolutePath().endsWith(".pattern"))
00117 return true;
00118 }
00119 return false;
00120 }
00121 public String getDescription() {
00122 return "Pattern file";
00123 }
00124 };
00125 class SpecificationFilter extends FileFilter {
00126 public boolean accept(java.io.File f) {
00127 if (f != null) {
00128 if (f.isDirectory())
00129 return true;
00130 else
00131 if (f.getAbsolutePath().endsWith(".specification"))
00132 return true;
00133 }
00134 return false;
00135 }
00136 public String getDescription() {
00137 return "Specification file";
00138 }
00139 };
00140 class DirectoryFilter extends FileFilter {
00141 public boolean accept(java.io.File f) {
00142 if (f != null) {
00143 if (f.isDirectory())
00144 return true;
00145 else
00146 return false;
00147 }
00148 return false;
00149 }
00150 public String getDescription() {
00151 return "Directory";
00152 }
00153 };
00154 class SessionFilter extends FileFilter {
00155 public boolean accept(java.io.File f) {
00156 if (f != null) {
00157 if (f.isDirectory())
00158 return true;
00159 else
00160 if (f.getAbsolutePath().endsWith(".session"))
00161 return true;
00162 }
00163 return false;
00164 }
00165 public String getDescription() {
00166 return "Session file";
00167 }
00168 };
00169 class AbstractionFilter extends FileFilter {
00170 public boolean accept(java.io.File f) {
00171 if (f != null) {
00172 if (f.isDirectory())
00173 return true;
00174 else
00175 if (f.getAbsolutePath().endsWith(".abstraction"))
00176 return true;
00177 }
00178 return false;
00179 }
00180 public String getDescription() {
00181 return "Abstraction file";
00182 }
00183 };
00184 class BASLFilter extends FileFilter {
00185 public boolean accept(java.io.File f) {
00186 if (f != null) {
00187 if (f.isDirectory())
00188 return true;
00189 else
00190 if (f.getAbsolutePath().endsWith(".basl"))
00191 return true;
00192 }
00193 return false;
00194 }
00195 public String getDescription() {
00196 return "BASL file";
00197 }
00198 };
00199 class ClassFilter extends FileFilter {
00200 public boolean accept(java.io.File f) {
00201 if (f != null) {
00202 if (f.isDirectory())
00203 return true;
00204 else
00205 if (f.getAbsolutePath().endsWith(".class"))
00206 return true;
00207 }
00208 return false;
00209 }
00210 public String getDescription() {
00211 return "Java class file";
00212 }
00213 };
00214 ALL = new AllFilter();
00215 JAVA = new JavaFilter();
00216 CLASSPATH = new ClasspathFilter();
00217 PATTERN = new PatternFilter();
00218 SPECIFICATION = new SpecificationFilter();
00219 DIRECTORY = new DirectoryFilter();
00220 SESSION = new SessionFilter();
00221 ABSTRACTION = new AbstractionFilter();
00222 BASL = new BASLFilter();
00223 CLASS = new ClassFilter();
00224 }
00225 }