root / src / gr / ebs / gss / client / MessagePanel.java @ bed4db0d
History | View | Annotate | Download (5.8 kB)
1 | 14ad7326 | pastith | /*
|
---|---|---|---|
2 | 14ad7326 | pastith | * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
|
3 | 14ad7326 | pastith | *
|
4 | 14ad7326 | pastith | * This file is part of GSS.
|
5 | 14ad7326 | pastith | *
|
6 | 14ad7326 | pastith | * GSS is free software: you can redistribute it and/or modify
|
7 | 14ad7326 | pastith | * it under the terms of the GNU General Public License as published by
|
8 | 14ad7326 | pastith | * the Free Software Foundation, either version 3 of the License, or
|
9 | 14ad7326 | pastith | * (at your option) any later version.
|
10 | 14ad7326 | pastith | *
|
11 | 14ad7326 | pastith | * GSS is distributed in the hope that it will be useful,
|
12 | 14ad7326 | pastith | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 14ad7326 | pastith | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 | 14ad7326 | pastith | * GNU General Public License for more details.
|
15 | 14ad7326 | pastith | *
|
16 | 14ad7326 | pastith | * You should have received a copy of the GNU General Public License
|
17 | 14ad7326 | pastith | * along with GSS. If not, see <http://www.gnu.org/licenses/>.
|
18 | 14ad7326 | pastith | */
|
19 | 14ad7326 | pastith | package gr.ebs.gss.client; |
20 | 14ad7326 | pastith | |
21 | 14ad7326 | pastith | import gr.ebs.gss.client.animation.FadeIn; |
22 | 14ad7326 | pastith | import gr.ebs.gss.client.animation.FadeOut; |
23 | 14ad7326 | pastith | |
24 | 14ad7326 | pastith | import com.google.gwt.core.client.GWT; |
25 | 14ad7326 | pastith | import com.google.gwt.user.client.DOM; |
26 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.AbstractImagePrototype; |
27 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.ClickListener; |
28 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.Composite; |
29 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.HTML; |
30 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
31 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.HasVerticalAlignment; |
32 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.HorizontalPanel; |
33 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.ImageBundle; |
34 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.SimplePanel; |
35 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.Widget; |
36 | 14ad7326 | pastith | |
37 | 14ad7326 | pastith | /**
|
38 | 14ad7326 | pastith | * A panel that displays various system messages.
|
39 | 14ad7326 | pastith | */
|
40 | 14ad7326 | pastith | public class MessagePanel extends Composite { |
41 | 14ad7326 | pastith | /**
|
42 | 14ad7326 | pastith | * An image bundle for this widget's images.
|
43 | 14ad7326 | pastith | */
|
44 | 14ad7326 | pastith | public interface Images extends ImageBundle { |
45 | 14ad7326 | pastith | @Resource("gr/ebs/gss/resources/messagebox_info.png") |
46 | 14ad7326 | pastith | AbstractImagePrototype info(); |
47 | 14ad7326 | pastith | |
48 | 14ad7326 | pastith | @Resource("gr/ebs/gss/resources/messagebox_warning.png") |
49 | 14ad7326 | pastith | AbstractImagePrototype warn(); |
50 | 14ad7326 | pastith | |
51 | 14ad7326 | pastith | @Resource("gr/ebs/gss/resources/messagebox_critical.png") |
52 | 14ad7326 | pastith | AbstractImagePrototype error(); |
53 | 14ad7326 | pastith | } |
54 | 14ad7326 | pastith | |
55 | 14ad7326 | pastith | /**
|
56 | 14ad7326 | pastith | * The widget's images.
|
57 | 14ad7326 | pastith | */
|
58 | 5c6b4b2c | Panagiotis Astithas | public static Images images; |
59 | 14ad7326 | pastith | |
60 | 14ad7326 | pastith | /**
|
61 | 14ad7326 | pastith | * The system message to be displayed.
|
62 | 14ad7326 | pastith | */
|
63 | 14ad7326 | pastith | private HTML message = new HTML(" "); |
64 | 14ad7326 | pastith | |
65 | 14ad7326 | pastith | /**
|
66 | 14ad7326 | pastith | * A link to clear the displayed message.
|
67 | 14ad7326 | pastith | */
|
68 | 14ad7326 | pastith | private HTML clearMessageLink = new HTML("<a class='gss-clearMessage' href='javascript:;'>Clear</a>"); |
69 | 14ad7326 | pastith | |
70 | 14ad7326 | pastith | /**
|
71 | 14ad7326 | pastith | * The panel that contains the messages.
|
72 | 14ad7326 | pastith | */
|
73 | 14ad7326 | pastith | private HorizontalPanel inner = new HorizontalPanel(); |
74 | 14ad7326 | pastith | |
75 | 14ad7326 | pastith | /**
|
76 | 14ad7326 | pastith | * The panel that enables special effects for this widget.
|
77 | 14ad7326 | pastith | */
|
78 | 14ad7326 | pastith | private SimplePanel simplePanel = new SimplePanel(); |
79 | f290fdfa | pastith | |
80 | 14ad7326 | pastith | /**
|
81 | 14ad7326 | pastith | * The widget's constructor.
|
82 | 14ad7326 | pastith | *
|
83 | 14ad7326 | pastith | * @param newImages a bundle that provides the images for this widget
|
84 | 14ad7326 | pastith | */
|
85 | 14ad7326 | pastith | public MessagePanel(final Images newImages) { |
86 | 14ad7326 | pastith | images = newImages; |
87 | 14ad7326 | pastith | buildPanel(); |
88 | 14ad7326 | pastith | simplePanel.setStyleName("effectPanel");
|
89 | 14ad7326 | pastith | inner.setStyleName("effectPanel-inner");
|
90 | 14ad7326 | pastith | DOM.setStyleAttribute(simplePanel.getElement(), "zoom", "1"); |
91 | 14ad7326 | pastith | simplePanel.add(inner); |
92 | 14ad7326 | pastith | initWidget(simplePanel); |
93 | 14ad7326 | pastith | } |
94 | 14ad7326 | pastith | |
95 | 14ad7326 | pastith | /**
|
96 | 14ad7326 | pastith | * Build the panel that contains the icon, the message and the 'clear' link.
|
97 | 14ad7326 | pastith | */
|
98 | 14ad7326 | pastith | private void buildPanel() { |
99 | 14ad7326 | pastith | inner.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); |
100 | 14ad7326 | pastith | inner.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); |
101 | 14ad7326 | pastith | inner.setSpacing(4);
|
102 | 14ad7326 | pastith | inner.add(message); |
103 | 14ad7326 | pastith | inner.add(clearMessageLink); |
104 | 14ad7326 | pastith | inner.setCellVerticalAlignment(message, HasVerticalAlignment.ALIGN_MIDDLE); |
105 | 14ad7326 | pastith | |
106 | 14ad7326 | pastith | clearMessageLink.addClickListener(new ClickListener() {
|
107 | 14ad7326 | pastith | |
108 | 14ad7326 | pastith | public void onClick(final Widget sender) { |
109 | 14ad7326 | pastith | FadeOut anim = new FadeOut(simplePanel){
|
110 | f290fdfa | pastith | @Override
|
111 | 14ad7326 | pastith | protected void onComplete() { |
112 | 14ad7326 | pastith | super.onComplete();
|
113 | 14ad7326 | pastith | hideMessage(); |
114 | 14ad7326 | pastith | } |
115 | 14ad7326 | pastith | }; |
116 | 14ad7326 | pastith | anim.run(1000);
|
117 | 14ad7326 | pastith | } |
118 | 14ad7326 | pastith | }); |
119 | 14ad7326 | pastith | } |
120 | 14ad7326 | pastith | |
121 | 14ad7326 | pastith | /**
|
122 | 14ad7326 | pastith | * Display an error message.
|
123 | 14ad7326 | pastith | *
|
124 | 14ad7326 | pastith | * @param msg the message to display
|
125 | 14ad7326 | pastith | */
|
126 | 14ad7326 | pastith | public void displayError(final String msg) { |
127 | 14ad7326 | pastith | GWT.log(msg, null);
|
128 | 14ad7326 | pastith | message = new HTML("<table class='gss-errorMessage'><tr><td>" + images.error().getHTML() + "</td><td>" + msg + "</td></tr></table>"); |
129 | 9a774fd7 | koutsoub | message.addClickListener(new ClickListener() {
|
130 | 9a774fd7 | koutsoub | |
131 | 9a774fd7 | koutsoub | public void onClick(final Widget sender) { |
132 | 9a774fd7 | koutsoub | FadeOut anim = new FadeOut(simplePanel){
|
133 | 9a774fd7 | koutsoub | |
134 | f290fdfa | pastith | @Override
|
135 | 9a774fd7 | koutsoub | protected void onComplete() { |
136 | 9a774fd7 | koutsoub | super.onComplete();
|
137 | 9a774fd7 | koutsoub | hideMessage(); |
138 | 9a774fd7 | koutsoub | } |
139 | 9a774fd7 | koutsoub | }; |
140 | 9a774fd7 | koutsoub | anim.run(1000);
|
141 | 9a774fd7 | koutsoub | } |
142 | 9a774fd7 | koutsoub | }); |
143 | 14ad7326 | pastith | buildPanel(); |
144 | 14ad7326 | pastith | setVisible(true);
|
145 | 14ad7326 | pastith | FadeIn anim = new FadeIn(simplePanel);
|
146 | 14ad7326 | pastith | anim.run(1000);
|
147 | 14ad7326 | pastith | } |
148 | 14ad7326 | pastith | |
149 | 14ad7326 | pastith | /**
|
150 | 14ad7326 | pastith | * Display a warning message.
|
151 | 14ad7326 | pastith | *
|
152 | 14ad7326 | pastith | * @param msg the message to display
|
153 | 14ad7326 | pastith | */
|
154 | 14ad7326 | pastith | public void displayWarning(final String msg) { |
155 | 14ad7326 | pastith | message = new HTML("<table class='gss-warnMessage'><tr><td>" + images.warn().getHTML() + "</td><td>" + msg + "</td></tr></table>"); |
156 | 9a774fd7 | koutsoub | message.addClickListener(new ClickListener() {
|
157 | 9a774fd7 | koutsoub | |
158 | 9a774fd7 | koutsoub | public void onClick(final Widget sender) { |
159 | 9a774fd7 | koutsoub | FadeOut anim = new FadeOut(simplePanel){
|
160 | 9a774fd7 | koutsoub | |
161 | f290fdfa | pastith | @Override
|
162 | 9a774fd7 | koutsoub | protected void onComplete() { |
163 | 9a774fd7 | koutsoub | super.onComplete();
|
164 | 9a774fd7 | koutsoub | hideMessage(); |
165 | 9a774fd7 | koutsoub | } |
166 | 9a774fd7 | koutsoub | }; |
167 | 9a774fd7 | koutsoub | anim.run(1000);
|
168 | 9a774fd7 | koutsoub | } |
169 | 9a774fd7 | koutsoub | }); |
170 | 9a774fd7 | koutsoub | |
171 | 14ad7326 | pastith | buildPanel(); |
172 | 14ad7326 | pastith | setVisible(true);
|
173 | 14ad7326 | pastith | FadeIn anim = new FadeIn(simplePanel);
|
174 | 14ad7326 | pastith | anim.run(1000);
|
175 | 14ad7326 | pastith | } |
176 | 14ad7326 | pastith | |
177 | 14ad7326 | pastith | /**
|
178 | 14ad7326 | pastith | * Display an informational message.
|
179 | 14ad7326 | pastith | *
|
180 | 14ad7326 | pastith | * @param msg the message to display
|
181 | 14ad7326 | pastith | */
|
182 | 14ad7326 | pastith | public void displayInformation(final String msg) { |
183 | 14ad7326 | pastith | message = new HTML("<table class='gss-infoMessage'><tr><td>" + images.info().getHTML() + "</td><td>" + msg + "</td></tr></table>"); |
184 | 9a774fd7 | koutsoub | message.addClickListener(new ClickListener() {
|
185 | 9a774fd7 | koutsoub | |
186 | 9a774fd7 | koutsoub | public void onClick(final Widget sender) { |
187 | 9a774fd7 | koutsoub | FadeOut anim = new FadeOut(simplePanel){
|
188 | 9a774fd7 | koutsoub | |
189 | f290fdfa | pastith | @Override
|
190 | 9a774fd7 | koutsoub | protected void onComplete() { |
191 | 9a774fd7 | koutsoub | super.onComplete();
|
192 | 9a774fd7 | koutsoub | hideMessage(); |
193 | 9a774fd7 | koutsoub | } |
194 | 9a774fd7 | koutsoub | }; |
195 | 9a774fd7 | koutsoub | anim.run(1000);
|
196 | 9a774fd7 | koutsoub | } |
197 | 9a774fd7 | koutsoub | }); |
198 | 9a774fd7 | koutsoub | |
199 | 14ad7326 | pastith | buildPanel(); |
200 | 14ad7326 | pastith | setVisible(true);
|
201 | 14ad7326 | pastith | FadeIn anim = new FadeIn(simplePanel);
|
202 | 14ad7326 | pastith | anim.run(1000);
|
203 | 14ad7326 | pastith | } |
204 | 14ad7326 | pastith | |
205 | 14ad7326 | pastith | /**
|
206 | 14ad7326 | pastith | * Clear the displayed message and hide the panel.
|
207 | 14ad7326 | pastith | */
|
208 | 14ad7326 | pastith | public void hideMessage() { |
209 | 14ad7326 | pastith | inner.clear(); |
210 | 14ad7326 | pastith | message = new HTML(" "); |
211 | 14ad7326 | pastith | this.setVisible(false); |
212 | 14ad7326 | pastith | } |
213 | 14ad7326 | pastith | |
214 | 14ad7326 | pastith | } |