1 45 46 package edu.rice.cs.drjava.ui; 47 48 import java.io.File ; 49 import javax.swing.filechooser.FileFilter ; 50 51 52 55 public class ClassPathFilter extends FileFilter { 56 public static final ClassPathFilter ONLY = new ClassPathFilter(); 57 58 protected ClassPathFilter() { } 59 60 61 public boolean accept(File f) { 62 if (f.isDirectory()) return true; 63 String extension = getExtension(f); 64 if (extension != null) return (extension.equals("jar") || extension.equals("zip")); 65 return false; 66 } 67 68 69 public String getDescription() { return "Classpath elements"; } 70 71 72 public static String getExtension(File f) { 73 String ext = null; 74 String s = f.getName(); 75 int i = s.lastIndexOf('.'); 76 if (i > 0 && i < s.length() - 1) ext = s.substring(i + 1).toLowerCase(); 77 return ext; 78 } 79 } 80 | Popular Tags |