1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.gwe.utils.web;
18
19
20
21
22
23
24 public enum WebIcon {
25
26
27 STATUS_OK( "ok", "icon_success_sml.gif"),
28 STATUS_WARN( "warn", "icon_warning_sml.gif"),
29 STATUS_INFO( "info", "icon_info_sml.gif"),
30 STATUS_HELP( "help", "icon_help_sml.gif"),
31 STATUS_ERROR("error", "icon_error_sml.gif"),
32
33
34 OPER_PREVIEW("preview", "report_magnify.png"),
35 OPER_QUEUE( "queue", "report_go.png"),
36
37 OPER_UP( "up", "arrow_up.png"),
38 OPER_DOWN( "down", "arrow_down.png"),
39
40 OPER_PAUSE( "pause", "pause.gif"),
41 OPER_RESUME( "resume", "resume_co.gif"),
42 OPER_DELETE( "delete", "trash.gif"),
43
44
45 ENT_GRID("grid", ""),
46 ENT_CLUSTER("cluster", "server.png"),
47 ENT_ORDER("order", "report.png"),
48 ENT_JOB("job", "page.png"),
49 ENT_EXEC("execution", ""),
50 ENT_PERM("permutation", ""),
51 ENT_STMT("statement", "");
52
53 public static WebIcon getImageById(String id) {
54 if (id != null) {
55 id = id.toLowerCase();
56 for (WebIcon icon : WebIcon.values())
57 if (icon.toString().equals(id))
58 return icon;
59 }
60
61 return null;
62 }
63
64 public static WebIcon getImageFor(Object value) {
65 if (value == null) return STATUS_ERROR;
66 if (value instanceof Boolean)
67 return ((Boolean)value) ? STATUS_OK : STATUS_ERROR;
68 return STATUS_OK;
69 }
70
71 private String id;
72 private String fileName;
73
74 WebIcon(String id, String fileName) {
75 this.id = id;
76 this.fileName = "img/" + fileName;
77 }
78
79 public String toString() {
80 return fileName;
81 }
82 }
83