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.event.dom.client.ClickEvent;
\r
26 import com.google.gwt.event.dom.client.ClickHandler;
\r
27 import com.google.gwt.resources.client.ClientBundle;
\r
28 import com.google.gwt.resources.client.ImageResource;
\r
29 import com.google.gwt.user.client.DOM;
\r
30 import com.google.gwt.user.client.ui.AbstractImagePrototype;
\r
31 import com.google.gwt.user.client.ui.Composite;
\r
32 import com.google.gwt.user.client.ui.HTML;
\r
33 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
\r
34 import com.google.gwt.user.client.ui.HasVerticalAlignment;
\r
35 import com.google.gwt.user.client.ui.HorizontalPanel;
\r
36 import com.google.gwt.user.client.ui.SimplePanel;
\r
39 * A panel that displays various system messages.
\r
41 public class MessagePanel extends Composite {
\r
43 * An image bundle for this widget's images.
\r
45 public interface Images extends ClientBundle {
\r
46 @Source("gr/ebs/gss/resources/messagebox_info.png")
\r
47 ImageResource info();
\r
49 @Source("gr/ebs/gss/resources/messagebox_warning.png")
\r
50 ImageResource warn();
\r
52 @Source("gr/ebs/gss/resources/messagebox_critical.png")
\r
53 ImageResource error();
\r
57 * The widget's images.
\r
59 public static Images images;
\r
62 * The system message to be displayed.
\r
64 private HTML message = new HTML(" ");
\r
67 * A link to clear the displayed message.
\r
69 private HTML clearMessageLink = new HTML("<a class='gss-clearMessage' href='javascript:;'>Clear</a>");
\r
72 * The panel that contains the messages.
\r
74 private HorizontalPanel inner = new HorizontalPanel();
\r
77 * The panel that enables special effects for this widget.
\r
79 private SimplePanel simplePanel = new SimplePanel();
\r
82 * The widget's constructor.
\r
84 * @param newImages a bundle that provides the images for this widget
\r
86 public MessagePanel(final Images newImages) {
\r
89 simplePanel.setStyleName("effectPanel");
\r
90 inner.setStyleName("effectPanel-inner");
\r
91 DOM.setStyleAttribute(simplePanel.getElement(), "zoom", "1");
\r
92 simplePanel.add(inner);
\r
93 initWidget(simplePanel);
\r
97 * Build the panel that contains the icon, the message and the 'clear' link.
\r
99 private void buildPanel() {
\r
100 inner.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
\r
101 inner.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
\r
102 inner.setSpacing(4);
\r
103 inner.add(message);
\r
104 inner.add(clearMessageLink);
\r
105 inner.setCellVerticalAlignment(message, HasVerticalAlignment.ALIGN_MIDDLE);
\r
107 clearMessageLink.addClickHandler(new ClickHandler() {
\r
110 public void onClick(ClickEvent event) {
\r
111 FadeOut anim = new FadeOut(simplePanel){
\r
113 protected void onComplete() {
\r
114 super.onComplete();
\r
125 * Display an error message.
\r
127 * @param msg the message to display
\r
129 public void displayError(final String msg) {
\r
130 GWT.log(msg, null);
\r
131 message = new HTML("<table class='gss-errorMessage'><tr><td>" + AbstractImagePrototype.create(images.error()).getHTML() + "</td><td>" + msg + "</td></tr></table>");
\r
132 message.addClickHandler(new ClickHandler() {
\r
135 public void onClick(ClickEvent event) {
\r
136 FadeOut anim = new FadeOut(simplePanel){
\r
139 protected void onComplete() {
\r
140 super.onComplete();
\r
149 FadeIn anim = new FadeIn(simplePanel);
\r
154 * Display a warning message.
\r
156 * @param msg the message to display
\r
158 public void displayWarning(final String msg) {
\r
159 message = new HTML("<table class='gss-warnMessage'><tr><td>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + msg + "</td></tr></table>");
\r
160 message.addClickHandler(new ClickHandler() {
\r
163 public void onClick(ClickEvent event) {
\r
164 FadeOut anim = new FadeOut(simplePanel){
\r
167 protected void onComplete() {
\r
168 super.onComplete();
\r
178 FadeIn anim = new FadeIn(simplePanel);
\r
183 * Display an informational message.
\r
185 * @param msg the message to display
\r
187 public void displayInformation(final String msg) {
\r
188 message = new HTML("<table class='gss-infoMessage'><tr><td>" + AbstractImagePrototype.create(images.info()).getHTML() + "</td><td>" + msg + "</td></tr></table>");
\r
189 message.addClickHandler(new ClickHandler() {
\r
192 public void onClick(ClickEvent event) {
\r
193 FadeOut anim = new FadeOut(simplePanel){
\r
196 protected void onComplete() {
\r
197 super.onComplete();
\r
207 FadeIn anim = new FadeIn(simplePanel);
\r
212 * Clear the displayed message and hide the panel.
\r
214 public void hideMessage() {
\r
216 message = new HTML(" ");
\r
217 this.setVisible(false);
\r