01: package org.contineo.core.util;
02:
03: /**
04: * utility class to select an icon based on a file extension
05: * @author Sebastian Stein
06: */
07: public class IconSelector {
08:
09: /** returns path to menu icon by parsing the provided file extension */
10: public static String selectIcon(String ext) {
11: String icon = "";
12: ext = ext.toLowerCase();
13:
14: if (ext == null || ext.equalsIgnoreCase(""))
15: icon = "document.gif";
16: else if (ext.equals("pdf"))
17: icon = "pdf.gif";
18: else if (ext.equals("doc") || ext.equals("dot")
19: || ext.equals("rtf") || ext.equals("sxw")
20: || ext.equals("txt") || ext.equals("wpd")
21: || ext.equals("kwd") || ext.equals("abw")
22: || ext.equals("zabw") || ext.equals("odt"))
23: icon = "textdoc.gif";
24: else if (ext.equals("xls") || ext.equals("xlt")
25: || ext.equals("sxc") || ext.equals("dbf")
26: || ext.equals("ksp") || ext.equals("ods")
27: || ext.equals("odb"))
28: icon = "tabledoc.gif";
29: else if (ext.equals("ppt") || ext.equals("pps")
30: || ext.equals("pot") || ext.equals("sxi")
31: || ext.equals("kpr") || ext.equals("odp"))
32: icon = "presentdoc.gif";
33: else if (ext.equals("apf") || ext.equals("bmp")
34: || ext.equals("cur") || ext.equals("dib")
35: || ext.equals("gif") || ext.equals("jpg")
36: || ext.equals("psd") || ext.equals("tif")
37: || ext.equals("tiff"))
38: icon = "picture.gif";
39: else if (ext.equals("htm") || ext.equals("html")
40: || ext.equals("xml"))
41: icon = "internet.gif";
42: else if (ext.equals("mail"))
43: icon = "mail.gif";
44: else
45: icon = "document.gif";
46:
47: return icon;
48: }
49: }
|