2 * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
\r
4 * This file is part of GSS.
\r
6 * GSS is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * GSS is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
\r
19 package gr.ebs.gss.client;
\r
21 import gr.ebs.gss.client.animation.FadeIn;
\r
22 import gr.ebs.gss.client.animation.FadeOut;
\r
24 import com.google.gwt.core.client.GWT;
\r
25 import com.google.gwt.user.client.DOM;
\r
26 import com.google.gwt.user.client.ui.AbstractImagePrototype;
\r
27 import com.google.gwt.user.client.ui.ClickListener;
\r
28 import com.google.gwt.user.client.ui.Composite;
\r
29 import com.google.gwt.user.client.ui.HTML;
\r
30 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
\r
31 import com.google.gwt.user.client.ui.HasVerticalAlignment;
\r
32 import com.google.gwt.user.client.ui.HorizontalPanel;
\r
33 import com.google.gwt.user.client.ui.ImageBundle;
\r
34 import com.google.gwt.user.client.ui.SimplePanel;
\r
35 import com.google.gwt.user.client.ui.Widget;
\r
38 * A panel that displays various system messages.
\r
40 public class MessagePanel extends Composite {
\r
42 * An image bundle for this widget's images.
\r
44 public interface Images extends ImageBundle {
\r
45 @Resource("gr/ebs/gss/resources/messagebox_info.png")
\r
46 AbstractImagePrototype info();
\r
48 @Resource("gr/ebs/gss/resources/messagebox_warning.png")
\r
49 AbstractImagePrototype warn();
\r
51 @Resource("gr/ebs/gss/resources/messagebox_critical.png")
\r
52 AbstractImagePrototype error();
\r
56 * The widget's images.
\r
58 public static Images images;
\r
61 * The system message to be displayed.
\r
63 private HTML message = new HTML(" ");
\r
66 * A link to clear the displayed message.
\r
68 private HTML clearMessageLink = new HTML("<a class='gss-clearMessage' href='javascript:;'>Clear</a>");
\r
71 * The panel that contains the messages.
\r
73 private HorizontalPanel inner = new HorizontalPanel();
\r
76 * The panel that enables special effects for this widget.
\r
78 private SimplePanel simplePanel = new SimplePanel();
\r
81 * The widget's constructor.
\r
83 * @param newImages a bundle that provides the images for this widget
\r
85 public MessagePanel(final Images newImages) {
\r
88 simplePanel.setStyleName("effectPanel");
\r
89 inner.setStyleName("effectPanel-inner");
\r
90 DOM.setStyleAttribute(simplePanel.getElement(), "zoom", "1");
\r
91 simplePanel.add(inner);
\r
92 initWidget(simplePanel);
\r
96 * Build the panel that contains the icon, the message and the 'clear' link.
\r
98 private void buildPanel() {
\r
99 inner.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
\r
100 inner.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
\r
101 inner.setSpacing(4);
\r
102 inner.add(message);
\r
103 inner.add(clearMessageLink);
\r
104 inner.setCellVerticalAlignment(message, HasVerticalAlignment.ALIGN_MIDDLE);
\r
106 clearMessageLink.addClickListener(new ClickListener() {
\r
108 public void onClick(final Widget sender) {
\r
109 FadeOut anim = new FadeOut(simplePanel){
\r
111 protected void onComplete() {
\r
112 super.onComplete();
\r
122 * Display an error message.
\r
124 * @param msg the message to display
\r
126 public void displayError(final String msg) {
\r
127 GWT.log(msg, null);
\r
128 message = new HTML("<table class='gss-errorMessage'><tr><td>" + images.error().getHTML() + "</td><td>" + msg + "</td></tr></table>");
\r
129 message.addClickListener(new ClickListener() {
\r
131 public void onClick(final Widget sender) {
\r
132 FadeOut anim = new FadeOut(simplePanel){
\r
135 protected void onComplete() {
\r
136 super.onComplete();
\r
145 FadeIn anim = new FadeIn(simplePanel);
\r
150 * Display a warning message.
\r
152 * @param msg the message to display
\r
154 public void displayWarning(final String msg) {
\r
155 message = new HTML("<table class='gss-warnMessage'><tr><td>" + images.warn().getHTML() + "</td><td>" + msg + "</td></tr></table>");
\r
156 message.addClickListener(new ClickListener() {
\r
158 public void onClick(final Widget sender) {
\r
159 FadeOut anim = new FadeOut(simplePanel){
\r
162 protected void onComplete() {
\r
163 super.onComplete();
\r
173 FadeIn anim = new FadeIn(simplePanel);
\r
178 * Display an informational message.
\r
180 * @param msg the message to display
\r
182 public void displayInformation(final String msg) {
\r
183 message = new HTML("<table class='gss-infoMessage'><tr><td>" + images.info().getHTML() + "</td><td>" + msg + "</td></tr></table>");
\r
184 message.addClickListener(new ClickListener() {
\r
186 public void onClick(final Widget sender) {
\r
187 FadeOut anim = new FadeOut(simplePanel){
\r
190 protected void onComplete() {
\r
191 super.onComplete();
\r
201 FadeIn anim = new FadeIn(simplePanel);
\r
206 * Clear the displayed message and hide the panel.
\r
208 public void hideMessage() {
\r
210 message = new HTML(" ");
\r
211 this.setVisible(false);
\r