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 package org.utgenome.gwt.utgb.client.ui;
26
27 import org.utgenome.gwt.widget.client.Style;
28
29 import com.google.gwt.user.client.ui.Composite;
30 import com.google.gwt.user.client.ui.Label;
31
32
33
34
35
36
37
38 public class Message extends Composite {
39
40 private Label messageLabel = new Label();
41 private MessageType messageType = MessageType.INFO;
42
43 public Message() {
44 this("");
45 }
46
47 public Message(String text) {
48 this(MessageType.INFO, text);
49 }
50
51 public Message(MessageType type, String text) {
52 setMessage(type, text);
53 Style.bold(messageLabel);
54 initWidget(messageLabel);
55 }
56
57 public void setMessage(MessageType type, String text) {
58 this.messageType = type;
59 messageLabel.setText(text);
60
61 switch (type) {
62 case INFO:
63 Style.fontColor(messageLabel, "#666666");
64 break;
65 case WARN:
66 Style.fontColor(messageLabel, "#FFCC99");
67 break;
68 case ERROR:
69 Style.fontColor(messageLabel, "#FF9999");
70 break;
71 }
72 }
73
74 public void info(String text) {
75 setMessage(MessageType.INFO, text);
76 }
77
78 public void warn(String text) {
79 setMessage(MessageType.WARN, text);
80 }
81
82 public void error(String text) {
83 setMessage(MessageType.ERROR, text);
84 }
85
86 }