1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 package net.sf.tm.plugin;
34
35 import net.sf.tm.WebContext;
36 import net.sf.tm.WebContextStatus;
37 import net.sf.tm.tomcat.TomcatServer;
38
39 import org.eclipse.jface.viewers.LabelProvider;
40 import org.eclipse.swt.graphics.Image;
41
42 /***
43 * Label provider for the Tomcat Manager tree view.
44 *
45 * @author Andreas Pataki
46 * @version $Id: WebContextLabelProvider.java,v 1.6 2004/02/10 20:06:15 apataki Exp $
47 */
48 public class WebContextLabelProvider extends LabelProvider {
49
50 /***
51 * Image for a Tomcat server
52 */
53 private Image serverImage;
54 /***
55 * Image for a started context
56 */
57 private Image startedContextImage;
58 /***
59 * Image for a stoped Context
60 */
61 private Image stopedContextImage;
62 /***
63 * Image for a pending Context
64 */
65 private Image pendingContextImage;
66
67 /***
68 * Default Constructor
69 */
70 public WebContextLabelProvider() {
71 serverImage =
72 ContextManagerPlugin
73 .getDefault()
74 .getImageDescriptor("icons/server.gif")
75 .createImage();
76
77 startedContextImage =
78 ContextManagerPlugin
79 .getDefault()
80 .getImageDescriptor("icons/context_on.gif")
81 .createImage();
82
83 stopedContextImage =
84 ContextManagerPlugin
85 .getDefault()
86 .getImageDescriptor("icons/context_off.gif")
87 .createImage();
88
89 pendingContextImage =
90 ContextManagerPlugin
91 .getDefault()
92 .getImageDescriptor("icons/context_pending.gif")
93 .createImage();
94
95 }
96
97 /***
98 * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
99 */
100 public String getText(Object obj) {
101 String text = null;
102 if (obj instanceof TreeNode) {
103 TreeNode node = (TreeNode) obj;
104
105 if (node.getContent() instanceof TomcatServer) {
106
107 TomcatServer server = (TomcatServer) node.getContent();
108 text = server.getName();
109
110 } else if (node.getContent() instanceof WebContext) {
111
112 text = ((WebContext) node.getContent()).getPath();
113
114 } else {
115
116 text = ((TreeNode) obj).getContent().toString();
117 }
118
119 } else {
120 text = obj.toString();
121 }
122 return text;
123 }
124
125 /***
126 * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
127 */
128 public Image getImage(Object obj) {
129 Image image = null;
130 if (obj instanceof TreeNode && ((TreeNode) obj).getParent() == null) {
131 image = serverImage;
132 } else {
133 WebContext context = (WebContext) ((TreeNode) obj).getContent();
134
135 if (context.getStatus().equals(WebContextStatus.RUNNING)) {
136 image = startedContextImage;
137 } else if (context.getStatus().equals(WebContextStatus.STOPPED)) {
138 image = stopedContextImage;
139 } else if (context.getStatus().equals(WebContextStatus.PENDING)) {
140 image = stopedContextImage;
141 image = pendingContextImage;
142 } else {
143 image = startedContextImage;
144 }
145
146 }
147
148 return image;
149 }
150
151 }