View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2008 utgenome.org
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *--------------------------------------------------------------------------*/
16  //--------------------------------------
17  // utgb-core Project
18  //
19  // StatusLabel.java
20  // Since: Sep 8, 2008
21  //
22  // $URL$ 
23  // $Author$
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   * for message
34   * 
35   * @author leo
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  }