root / src / gr / grnet / pithos / web / client / MessagePanel.java @ fbb19e02
History | View | Annotate | Download (6.2 kB)
1 | a57faaf0 | Christos Stathis | /*
|
---|---|---|---|
2 | e6e9f6e6 | Christos KK Loverdos | * Copyright 2011-2013 GRNET S.A. All rights reserved.
|
3 | 63366925 | Christos Stathis | *
|
4 | 63366925 | Christos Stathis | * Redistribution and use in source and binary forms, with or
|
5 | 63366925 | Christos Stathis | * without modification, are permitted provided that the following
|
6 | 63366925 | Christos Stathis | * conditions are met:
|
7 | 63366925 | Christos Stathis | *
|
8 | 63366925 | Christos Stathis | * 1. Redistributions of source code must retain the above
|
9 | 63366925 | Christos Stathis | * copyright notice, this list of conditions and the following
|
10 | 63366925 | Christos Stathis | * disclaimer.
|
11 | 63366925 | Christos Stathis | *
|
12 | 63366925 | Christos Stathis | * 2. Redistributions in binary form must reproduce the above
|
13 | 63366925 | Christos Stathis | * copyright notice, this list of conditions and the following
|
14 | 63366925 | Christos Stathis | * disclaimer in the documentation and/or other materials
|
15 | 63366925 | Christos Stathis | * provided with the distribution.
|
16 | 63366925 | Christos Stathis | *
|
17 | 63366925 | Christos Stathis | * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
18 | 63366925 | Christos Stathis | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19 | 63366925 | Christos Stathis | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
20 | 63366925 | Christos Stathis | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
21 | 63366925 | Christos Stathis | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22 | 63366925 | Christos Stathis | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23 | 63366925 | Christos Stathis | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
24 | 63366925 | Christos Stathis | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
25 | 63366925 | Christos Stathis | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
26 | 63366925 | Christos Stathis | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
27 | 63366925 | Christos Stathis | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 | 63366925 | Christos Stathis | * POSSIBILITY OF SUCH DAMAGE.
|
29 | 63366925 | Christos Stathis | *
|
30 | 63366925 | Christos Stathis | * The views and conclusions contained in the software and
|
31 | 63366925 | Christos Stathis | * documentation are those of the authors and should not be
|
32 | 63366925 | Christos Stathis | * interpreted as representing official policies, either expressed
|
33 | 63366925 | Christos Stathis | * or implied, of GRNET S.A.
|
34 | a57faaf0 | Christos Stathis | */
|
35 | a57faaf0 | Christos Stathis | package gr.grnet.pithos.web.client; |
36 | a57faaf0 | Christos Stathis | |
37 | a57faaf0 | Christos Stathis | import com.google.gwt.core.client.GWT; |
38 | a57faaf0 | Christos Stathis | import com.google.gwt.event.dom.client.ClickEvent; |
39 | a57faaf0 | Christos Stathis | import com.google.gwt.event.dom.client.ClickHandler; |
40 | a57faaf0 | Christos Stathis | import com.google.gwt.resources.client.ClientBundle; |
41 | a57faaf0 | Christos Stathis | import com.google.gwt.resources.client.ImageResource; |
42 | 430898e5 | Christos Stathis | import com.google.gwt.user.client.Window; |
43 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.AbstractImagePrototype; |
44 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.Composite; |
45 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.HTML; |
46 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
47 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.HasVerticalAlignment; |
48 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.HorizontalPanel; |
49 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.SimplePanel; |
50 | 3f8622d4 | Christos Stathis | import com.google.gwt.user.client.ui.VerticalPanel; |
51 | a57faaf0 | Christos Stathis | |
52 | a57faaf0 | Christos Stathis | /**
|
53 | a57faaf0 | Christos Stathis | * A panel that displays various system messages.
|
54 | a57faaf0 | Christos Stathis | */
|
55 | a57faaf0 | Christos Stathis | public class MessagePanel extends Composite { |
56 | a57faaf0 | Christos Stathis | /**
|
57 | a57faaf0 | Christos Stathis | * An image bundle for this widget's images.
|
58 | a57faaf0 | Christos Stathis | */
|
59 | a57faaf0 | Christos Stathis | public interface Images extends ClientBundle { |
60 | a57faaf0 | Christos Stathis | @Source("gr/grnet/pithos/resources/messagebox_info.png") |
61 | a57faaf0 | Christos Stathis | ImageResource info(); |
62 | a57faaf0 | Christos Stathis | |
63 | a57faaf0 | Christos Stathis | @Source("gr/grnet/pithos/resources/messagebox_warning.png") |
64 | a57faaf0 | Christos Stathis | ImageResource warn(); |
65 | a57faaf0 | Christos Stathis | |
66 | a57faaf0 | Christos Stathis | @Source("gr/grnet/pithos/resources/messagebox_critical.png") |
67 | a57faaf0 | Christos Stathis | ImageResource error(); |
68 | a57faaf0 | Christos Stathis | } |
69 | a57faaf0 | Christos Stathis | |
70 | a57faaf0 | Christos Stathis | /**
|
71 | a57faaf0 | Christos Stathis | * The widget's images.
|
72 | a57faaf0 | Christos Stathis | */
|
73 | a57faaf0 | Christos Stathis | public static Images images; |
74 | a57faaf0 | Christos Stathis | |
75 | a57faaf0 | Christos Stathis | /**
|
76 | a57faaf0 | Christos Stathis | * The system message to be displayed.
|
77 | a57faaf0 | Christos Stathis | */
|
78 | 3f8622d4 | Christos Stathis | private HTML message; |
79 | a57faaf0 | Christos Stathis | |
80 | a57faaf0 | Christos Stathis | /**
|
81 | a57faaf0 | Christos Stathis | * The panel that contains the messages.
|
82 | a57faaf0 | Christos Stathis | */
|
83 | 3f8622d4 | Christos Stathis | private HorizontalPanel inner;
|
84 | a57faaf0 | Christos Stathis | |
85 | a57faaf0 | Christos Stathis | /**
|
86 | a57faaf0 | Christos Stathis | * The panel that enables special effects for this widget.
|
87 | a57faaf0 | Christos Stathis | */
|
88 | 3f8622d4 | Christos Stathis | protected SimplePanel simplePanel;
|
89 | a57faaf0 | Christos Stathis | |
90 | a57faaf0 | Christos Stathis | /**
|
91 | 3f8622d4 | Christos Stathis | * A link to send feedBack about the error.
|
92 | 3f8622d4 | Christos Stathis | */
|
93 | 3f8622d4 | Christos Stathis | private HTML feedbackLink; |
94 | 430898e5 | Christos Stathis | |
95 | 430898e5 | Christos Stathis | Pithos app; |
96 | 430898e5 | Christos Stathis | |
97 | 3f8622d4 | Christos Stathis | /**
|
98 | a57faaf0 | Christos Stathis | * The widget's constructor.
|
99 | a57faaf0 | Christos Stathis | *
|
100 | a57faaf0 | Christos Stathis | * @param newImages a bundle that provides the images for this widget
|
101 | a57faaf0 | Christos Stathis | */
|
102 | 430898e5 | Christos Stathis | public MessagePanel(Pithos _app, final Images newImages) { |
103 | 430898e5 | Christos Stathis | app = _app; |
104 | a57faaf0 | Christos Stathis | images = newImages; |
105 | 3f8622d4 | Christos Stathis | simplePanel = new SimplePanel();
|
106 | a57faaf0 | Christos Stathis | simplePanel.setStyleName("effectPanel");
|
107 | 3f8622d4 | Christos Stathis | |
108 | 3f8622d4 | Christos Stathis | inner = new HorizontalPanel();
|
109 | a57faaf0 | Christos Stathis | inner.setStyleName("effectPanel-inner");
|
110 | a57faaf0 | Christos Stathis | inner.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); |
111 | a57faaf0 | Christos Stathis | inner.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); |
112 | 3f8622d4 | Christos Stathis | |
113 | 3f8622d4 | Christos Stathis | message = new HTML(" "); |
114 | 3f8622d4 | Christos Stathis | message.addClickHandler(new ClickHandler() {
|
115 | a57faaf0 | Christos Stathis | |
116 | a57faaf0 | Christos Stathis | @Override
|
117 | ebead1b5 | Christos Stathis | public void onClick(ClickEvent event) { |
118 | 28267d27 | Christos Stathis | hideMessage(); |
119 | a57faaf0 | Christos Stathis | } |
120 | a57faaf0 | Christos Stathis | }); |
121 | 3f8622d4 | Christos Stathis | inner.add(message); |
122 | 3f8622d4 | Christos Stathis | inner.setCellVerticalAlignment(message, HasVerticalAlignment.ALIGN_MIDDLE); |
123 | a57faaf0 | Christos Stathis | |
124 | 3f8622d4 | Christos Stathis | VerticalPanel linkPanel = new VerticalPanel();
|
125 | 3f8622d4 | Christos Stathis | linkPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); |
126 | 3f8622d4 | Christos Stathis | /**
|
127 | 3f8622d4 | Christos Stathis | * A link to clear the displayed message.
|
128 | 3f8622d4 | Christos Stathis | */
|
129 | 3f8622d4 | Christos Stathis | HTML clearMessageLink = new HTML("<a class='pithos-clearMessage' href='javascript:;'>Clear</a>"); |
130 | 3f8622d4 | Christos Stathis | clearMessageLink.addClickHandler(new ClickHandler() {
|
131 | a57faaf0 | Christos Stathis | |
132 | a57faaf0 | Christos Stathis | @Override
|
133 | ebead1b5 | Christos Stathis | public void onClick(ClickEvent event) { |
134 | 28267d27 | Christos Stathis | hideMessage(); |
135 | a57faaf0 | Christos Stathis | } |
136 | a57faaf0 | Christos Stathis | }); |
137 | 3f8622d4 | Christos Stathis | linkPanel.add(clearMessageLink); |
138 | 3f8622d4 | Christos Stathis | |
139 | 3f8622d4 | Christos Stathis | feedbackLink = new HTML("<a class='pithos-clearMessage' href='javascript:;'>Send feedback</a>"); |
140 | 3f8622d4 | Christos Stathis | feedbackLink.addClickHandler(new ClickHandler() {
|
141 | 3f8622d4 | Christos Stathis | |
142 | 3f8622d4 | Christos Stathis | @Override
|
143 | ebead1b5 | Christos Stathis | public void onClick(ClickEvent event) { |
144 | 3f8622d4 | Christos Stathis | new FeedbackDialog(app, app.getErrorData()).center();
|
145 | 3f8622d4 | Christos Stathis | } |
146 | 3f8622d4 | Christos Stathis | }); |
147 | 3f8622d4 | Christos Stathis | feedbackLink.setVisible(false);
|
148 | 3f8622d4 | Christos Stathis | linkPanel.add(feedbackLink); |
149 | 3f8622d4 | Christos Stathis | |
150 | 3f8622d4 | Christos Stathis | inner.add(linkPanel); |
151 | 3f8622d4 | Christos Stathis | simplePanel.add(inner); |
152 | 3f8622d4 | Christos Stathis | |
153 | 3f8622d4 | Christos Stathis | initWidget(simplePanel); |
154 | 3f8622d4 | Christos Stathis | } |
155 | 3f8622d4 | Christos Stathis | |
156 | 3f8622d4 | Christos Stathis | /**
|
157 | 3f8622d4 | Christos Stathis | * Display an error message.
|
158 | 3f8622d4 | Christos Stathis | *
|
159 | 3f8622d4 | Christos Stathis | * @param msg the message to display
|
160 | 3f8622d4 | Christos Stathis | */
|
161 | 3f8622d4 | Christos Stathis | public void displayError(final String msg) { |
162 | 3f8622d4 | Christos Stathis | GWT.log(msg, null);
|
163 | 3f8622d4 | Christos Stathis | message.setHTML("<table class='pithos-errorMessage'><tr><td>" + AbstractImagePrototype.create(images.error()).getHTML() + "</td><td>" + msg + "</td></tr></table>"); |
164 | 3f8622d4 | Christos Stathis | feedbackLink.setVisible(true);
|
165 | a57faaf0 | Christos Stathis | setVisible(true);
|
166 | a57faaf0 | Christos Stathis | } |
167 | a57faaf0 | Christos Stathis | |
168 | a57faaf0 | Christos Stathis | /**
|
169 | a57faaf0 | Christos Stathis | * Display a warning message.
|
170 | a57faaf0 | Christos Stathis | *
|
171 | a57faaf0 | Christos Stathis | * @param msg the message to display
|
172 | a57faaf0 | Christos Stathis | */
|
173 | a57faaf0 | Christos Stathis | public void displayWarning(final String msg) { |
174 | 3f8622d4 | Christos Stathis | message.setHTML("<table class='pithos-warnMessage'><tr><td>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + msg + "</td></tr></table>"); |
175 | 3f8622d4 | Christos Stathis | feedbackLink.setVisible(false);
|
176 | a57faaf0 | Christos Stathis | setVisible(true);
|
177 | a57faaf0 | Christos Stathis | } |
178 | a57faaf0 | Christos Stathis | |
179 | a57faaf0 | Christos Stathis | /**
|
180 | a57faaf0 | Christos Stathis | * Display an informational message.
|
181 | a57faaf0 | Christos Stathis | *
|
182 | a57faaf0 | Christos Stathis | * @param msg the message to display
|
183 | a57faaf0 | Christos Stathis | */
|
184 | a57faaf0 | Christos Stathis | public void displayInformation(final String msg) { |
185 | 3f8622d4 | Christos Stathis | message.setHTML("<table class='pithos-infoMessage'><tr><td>" + AbstractImagePrototype.create(images.info()).getHTML() + "</td><td>" + msg + "</td></tr></table>"); |
186 | 3f8622d4 | Christos Stathis | feedbackLink.setVisible(false);
|
187 | a57faaf0 | Christos Stathis | setVisible(true);
|
188 | a57faaf0 | Christos Stathis | } |
189 | a57faaf0 | Christos Stathis | |
190 | a57faaf0 | Christos Stathis | /**
|
191 | a57faaf0 | Christos Stathis | * Clear the displayed message and hide the panel.
|
192 | a57faaf0 | Christos Stathis | */
|
193 | a57faaf0 | Christos Stathis | public void hideMessage() { |
194 | a57faaf0 | Christos Stathis | message = new HTML(" "); |
195 | a57faaf0 | Christos Stathis | this.setVisible(false); |
196 | 430898e5 | Christos Stathis | app.onWindowResized(Window.getClientHeight());
|
197 | a57faaf0 | Christos Stathis | } |
198 | a57faaf0 | Christos Stathis | } |