/*\r
- * Copyright (c) 2011 Greek Research and Technology Network\r
+ * Copyright 2011 GRNET S.A. All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or\r
+ * without modification, are permitted provided that the following\r
+ * conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above\r
+ * copyright notice, this list of conditions and the following\r
+ * disclaimer.\r
+ *\r
+ * 2. Redistributions in binary form must reproduce the above\r
+ * copyright notice, this list of conditions and the following\r
+ * disclaimer in the documentation and/or other materials\r
+ * provided with the distribution.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS\r
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR\r
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\r
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ * The views and conclusions contained in the software and\r
+ * documentation are those of the authors and should not be\r
+ * interpreted as representing official policies, either expressed\r
+ * or implied, of GRNET S.A.\r
*/\r
package gr.grnet.pithos.web.client;\r
\r
import com.google.gwt.event.dom.client.ClickHandler;\r
import com.google.gwt.resources.client.ClientBundle;\r
import com.google.gwt.resources.client.ImageResource;\r
-import com.google.gwt.user.client.DOM;\r
import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
import com.google.gwt.user.client.ui.Composite;\r
import com.google.gwt.user.client.ui.HTML;\r
import com.google.gwt.user.client.ui.HasVerticalAlignment;\r
import com.google.gwt.user.client.ui.HorizontalPanel;\r
import com.google.gwt.user.client.ui.SimplePanel;\r
+import com.google.gwt.user.client.ui.VerticalPanel;\r
\r
/**\r
* A panel that displays various system messages.\r
/**\r
* The system message to be displayed.\r
*/\r
- private HTML message = new HTML(" ");\r
-\r
- /**\r
- * A link to clear the displayed message.\r
- */\r
- private HTML clearMessageLink = new HTML("<a class='pithos-clearMessage' href='javascript:;'>Clear</a>");\r
+ private HTML message;\r
\r
/**\r
* The panel that contains the messages.\r
*/\r
- private HorizontalPanel inner = new HorizontalPanel();\r
+ private HorizontalPanel inner;\r
\r
/**\r
* The panel that enables special effects for this widget.\r
*/\r
- private SimplePanel simplePanel = new SimplePanel();\r
+ protected SimplePanel simplePanel;\r
\r
/**\r
+ * A link to send feedBack about the error.\r
+ */\r
+ private HTML feedbackLink;\r
+ /**\r
* The widget's constructor.\r
*\r
* @param newImages a bundle that provides the images for this widget\r
*/\r
- public MessagePanel(final Images newImages) {\r
+ public MessagePanel(final Pithos app, final Images newImages) {\r
images = newImages;\r
- buildPanel();\r
+ simplePanel = new SimplePanel();\r
simplePanel.setStyleName("effectPanel");\r
+ \r
+ inner = new HorizontalPanel();\r
inner.setStyleName("effectPanel-inner");\r
- DOM.setStyleAttribute(simplePanel.getElement(), "zoom", "1");\r
- simplePanel.add(inner);\r
- initWidget(simplePanel);\r
- }\r
-\r
- /**\r
- * Build the panel that contains the icon, the message and the 'clear' link.\r
- */\r
- private void buildPanel() {\r
inner.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);\r
inner.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);\r
- inner.setSpacing(4);\r
- inner.add(message);\r
- inner.add(clearMessageLink);\r
- inner.setCellVerticalAlignment(message, HasVerticalAlignment.ALIGN_MIDDLE);\r
- clearMessageLink.addClickHandler(new ClickHandler() {\r
+ \r
+ message = new HTML(" ");\r
+ message.addClickHandler(new ClickHandler() {\r
\r
@Override\r
- public void onClick(ClickEvent event) {\r
+ public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
FadeOut anim = new FadeOut(simplePanel){\r
+\r
@Override\r
protected void onComplete() {\r
super.onComplete();\r
anim.run(500);\r
}\r
});\r
- }\r
+ inner.add(message);\r
+ inner.setCellVerticalAlignment(message, HasVerticalAlignment.ALIGN_MIDDLE);\r
\r
- /**\r
- * Display an error message.\r
- *\r
- * @param msg the message to display\r
- */\r
- public void displayError(final String msg) {\r
- GWT.log(msg, null);\r
- message = new HTML("<table class='pithos-errorMessage'><tr><td>" + AbstractImagePrototype.create(images.error()).getHTML() + "</td><td>" + msg + "</td></tr></table>");\r
- message.addClickHandler(new ClickHandler() {\r
+ VerticalPanel linkPanel = new VerticalPanel();\r
+ linkPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);\r
+ /**\r
+ * A link to clear the displayed message.\r
+ */\r
+ HTML clearMessageLink = new HTML("<a class='pithos-clearMessage' href='javascript:;'>Clear</a>");\r
+ clearMessageLink.addClickHandler(new ClickHandler() {\r
\r
@Override\r
- public void onClick(ClickEvent event) {\r
+ public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
FadeOut anim = new FadeOut(simplePanel){\r
-\r
@Override\r
protected void onComplete() {\r
super.onComplete();\r
anim.run(500);\r
}\r
});\r
- buildPanel();\r
+ linkPanel.add(clearMessageLink);\r
+\r
+ feedbackLink = new HTML("<a class='pithos-clearMessage' href='javascript:;'>Send feedback</a>");\r
+ feedbackLink.addClickHandler(new ClickHandler() {\r
+ \r
+ @Override\r
+ public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
+ new FeedbackDialog(app, app.getErrorData()).center();\r
+ }\r
+ });\r
+ feedbackLink.setVisible(false);\r
+ linkPanel.add(feedbackLink);\r
+\r
+ inner.add(linkPanel);\r
+ simplePanel.add(inner);\r
+ \r
+ initWidget(simplePanel);\r
+ }\r
+\r
+ /**\r
+ * Display an error message.\r
+ *\r
+ * @param msg the message to display\r
+ */\r
+ public void displayError(final String msg) {\r
+ GWT.log(msg, null);\r
+ message.setHTML("<table class='pithos-errorMessage'><tr><td>" + AbstractImagePrototype.create(images.error()).getHTML() + "</td><td>" + msg + "</td></tr></table>");\r
+ feedbackLink.setVisible(true);\r
setVisible(true);\r
FadeIn anim = new FadeIn(simplePanel);\r
anim.run(500);\r
* @param msg the message to display\r
*/\r
public void displayWarning(final String msg) {\r
- message = new HTML("<table class='pithos-warnMessage'><tr><td>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + msg + "</td></tr></table>");\r
- message.addClickHandler(new ClickHandler() {\r
-\r
- @Override\r
- public void onClick(ClickEvent event) {\r
- FadeOut anim = new FadeOut(simplePanel){\r
-\r
- @Override\r
- protected void onComplete() {\r
- super.onComplete();\r
- hideMessage();\r
- }\r
- };\r
- anim.run(500);\r
- }\r
- });\r
-\r
- buildPanel();\r
+ message.setHTML("<table class='pithos-warnMessage'><tr><td>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + msg + "</td></tr></table>");\r
+ feedbackLink.setVisible(false);\r
setVisible(true);\r
FadeIn anim = new FadeIn(simplePanel);\r
anim.run(500);\r
* @param msg the message to display\r
*/\r
public void displayInformation(final String msg) {\r
- message = new HTML("<table class='pithos-infoMessage'><tr><td>" + AbstractImagePrototype.create(images.info()).getHTML() + "</td><td>" + msg + "</td></tr></table>");\r
- message.addClickHandler(new ClickHandler() {\r
-\r
- @Override\r
- public void onClick(ClickEvent event) {\r
- FadeOut anim = new FadeOut(simplePanel){\r
-\r
- @Override\r
- protected void onComplete() {\r
- super.onComplete();\r
- hideMessage();\r
- }\r
- };\r
- anim.run(500);\r
- }\r
- });\r
-\r
- buildPanel();\r
+ message.setHTML("<table class='pithos-infoMessage'><tr><td>" + AbstractImagePrototype.create(images.info()).getHTML() + "</td><td>" + msg + "</td></tr></table>");\r
+ feedbackLink.setVisible(false);\r
setVisible(true);\r
FadeIn anim = new FadeIn(simplePanel);\r
anim.run(500);\r
* Clear the displayed message and hide the panel.\r
*/\r
public void hideMessage() {\r
- inner.clear();\r
message = new HTML(" ");\r
this.setVisible(false);\r
}\r