1 35 36 39 package demo.swingset; 40 import swingwtx.swing.*; 41 import swingwtx.swing.filechooser.*; 42 43 import java.io.File ; 44 import java.util.Hashtable ; 45 46 69 public class ExampleFileView extends Object { 70 private Hashtable icons = new Hashtable (5); 71 private Hashtable fileDescriptions = new Hashtable (5); 72 private Hashtable typeDescriptions = new Hashtable (5); 73 74 80 public String getName(File f) { 81 return null; 82 } 83 84 87 public void putDescription(File f, String fileDescription) { 88 fileDescriptions.put(fileDescription, f); 89 } 90 91 96 public String getDescription(File f) { 97 return (String ) fileDescriptions.get(f); 98 }; 99 100 104 public void putTypeDescription(String extension, String typeDescription) { 105 typeDescriptions.put(typeDescription, extension); 106 } 107 108 113 public void putTypeDescription(File f, String typeDescription) { 114 putTypeDescription(getExtension(f), typeDescription); 115 } 116 117 122 public String getTypeDescription(File f) { 123 return (String ) typeDescriptions.get(getExtension(f)); 124 } 125 126 130 public String getExtension(File f) { 131 String name = f.getName(); 132 if(name != null) { 133 int extensionIndex = name.lastIndexOf('.'); 134 if(extensionIndex < 0) { 135 return null; 136 } 137 return name.substring(extensionIndex+1).toLowerCase(); 138 } 139 return null; 140 } 141 142 146 public void putIcon(String extension, Icon icon) { 147 icons.put(extension, icon); 148 } 149 150 157 public Icon getIcon(File f) { 158 Icon icon = null; 159 String extension = getExtension(f); 160 if(extension != null) { 161 icon = (Icon) icons.get(extension); 162 } 163 return icon; 164 } 165 166 172 public Boolean isHidden(File f) { 173 String name = f.getName(); 174 if(name != null && !name.equals("") && name.charAt(0) == '.') { 175 return Boolean.TRUE; 176 } else { 177 return Boolean.FALSE; 178 } 179 }; 180 181 193 public Boolean isTraversable(File f) { 194 return null; }; 199 200 } 201 | Popular Tags |