01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.client.gui.image;
19:
20: import java.io.File;
21:
22: import javax.swing.Icon;
23: import javax.swing.ImageIcon;
24: import javax.swing.filechooser.FileView;
25:
26: import de.finix.contelligent.client.gui.file.Utils;
27: import de.finix.contelligent.client.i18n.Resources;
28:
29: public class ImageFileView extends FileView {
30: ImageIcon jpgIcon = Resources.jpegIcon;
31:
32: ImageIcon gifIcon = Resources.gifIcon;
33:
34: ImageIcon tiffIcon = Resources.tiffIcon;
35:
36: public String getName(File f) {
37: return null; // let the L&F FileView figure this out
38: }
39:
40: public String getDescription(File f) {
41: return null; // let the L&F FileView figure this out
42: }
43:
44: public Boolean isTraversable(File f) {
45: return null; // let the L&F FileView figure this out
46: }
47:
48: public String getTypeDescription(File f) {
49: String extension = Utils.getExtension(f);
50: String type = null;
51:
52: if (extension != null) {
53: if (extension.equals(Utils.jpeg)
54: || extension.equals(Utils.jpg)) {
55: type = "JPEG Image";
56: } else if (extension.equals(Utils.gif)) {
57: type = "GIF Image";
58: } else if (extension.equals(Utils.tiff)
59: || extension.equals(Utils.tif)) {
60: type = "TIFF Image";
61: }
62: }
63: return type;
64: }
65:
66: public Icon getIcon(File f) {
67: String extension = Utils.getExtension(f);
68: Icon icon = null;
69:
70: if (extension != null) {
71: if (extension.equals(Utils.jpeg)
72: || extension.equals(Utils.jpg)) {
73: icon = jpgIcon;
74: } else if (extension.equals(Utils.gif)) {
75: icon = gifIcon;
76: } else if (extension.equals(Utils.tiff)
77: || extension.equals(Utils.tif)) {
78: icon = tiffIcon;
79: }
80: }
81: return icon;
82: }
83: }
|