root / src / gr / grnet / pithos / web / client / FeedbackDialog.java @ b75210b5
History | View | Annotate | Download (5.3 kB)
1 | 29c80d38 | Christos Stathis | /*
|
---|---|---|---|
2 | 29c80d38 | Christos Stathis | * Copyright 2011 GRNET S.A. All rights reserved.
|
3 | 29c80d38 | Christos Stathis | *
|
4 | 29c80d38 | Christos Stathis | * Redistribution and use in source and binary forms, with or
|
5 | 29c80d38 | Christos Stathis | * without modification, are permitted provided that the following
|
6 | 29c80d38 | Christos Stathis | * conditions are met:
|
7 | 29c80d38 | Christos Stathis | *
|
8 | 29c80d38 | Christos Stathis | * 1. Redistributions of source code must retain the above
|
9 | 29c80d38 | Christos Stathis | * copyright notice, this list of conditions and the following
|
10 | 29c80d38 | Christos Stathis | * disclaimer.
|
11 | 29c80d38 | Christos Stathis | *
|
12 | 29c80d38 | Christos Stathis | * 2. Redistributions in binary form must reproduce the above
|
13 | 29c80d38 | Christos Stathis | * copyright notice, this list of conditions and the following
|
14 | 29c80d38 | Christos Stathis | * disclaimer in the documentation and/or other materials
|
15 | 29c80d38 | Christos Stathis | * provided with the distribution.
|
16 | 29c80d38 | Christos Stathis | *
|
17 | 29c80d38 | Christos Stathis | * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
18 | 29c80d38 | Christos Stathis | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19 | 29c80d38 | Christos Stathis | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
20 | 29c80d38 | Christos Stathis | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
21 | 29c80d38 | Christos Stathis | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22 | 29c80d38 | Christos Stathis | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23 | 29c80d38 | Christos Stathis | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
24 | 29c80d38 | Christos Stathis | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
25 | 29c80d38 | Christos Stathis | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
26 | 29c80d38 | Christos Stathis | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
27 | 29c80d38 | Christos Stathis | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 | 29c80d38 | Christos Stathis | * POSSIBILITY OF SUCH DAMAGE.
|
29 | 29c80d38 | Christos Stathis | *
|
30 | 29c80d38 | Christos Stathis | * The views and conclusions contained in the software and
|
31 | 29c80d38 | Christos Stathis | * documentation are those of the authors and should not be
|
32 | 29c80d38 | Christos Stathis | * interpreted as representing official policies, either expressed
|
33 | 29c80d38 | Christos Stathis | * or implied, of GRNET S.A.
|
34 | 29c80d38 | Christos Stathis | */
|
35 | 29c80d38 | Christos Stathis | package gr.grnet.pithos.web.client; |
36 | 29c80d38 | Christos Stathis | |
37 | b432ea43 | Christos Stathis | import gr.grnet.pithos.web.client.foldertree.Resource; |
38 | b432ea43 | Christos Stathis | import gr.grnet.pithos.web.client.rest.PostRequest; |
39 | b432ea43 | Christos Stathis | |
40 | b432ea43 | Christos Stathis | import com.google.gwt.core.client.GWT; |
41 | b432ea43 | Christos Stathis | import com.google.gwt.core.client.Scheduler; |
42 | 29c80d38 | Christos Stathis | import com.google.gwt.dom.client.NativeEvent; |
43 | 29c80d38 | Christos Stathis | import com.google.gwt.event.dom.client.ClickEvent; |
44 | 29c80d38 | Christos Stathis | import com.google.gwt.event.dom.client.ClickHandler; |
45 | 29c80d38 | Christos Stathis | import com.google.gwt.event.dom.client.KeyCodes; |
46 | b432ea43 | Christos Stathis | import com.google.gwt.http.client.Response; |
47 | 29c80d38 | Christos Stathis | import com.google.gwt.user.client.Event.NativePreviewEvent; |
48 | 29c80d38 | Christos Stathis | import com.google.gwt.user.client.ui.Anchor; |
49 | 29c80d38 | Christos Stathis | import com.google.gwt.user.client.ui.Button; |
50 | 29c80d38 | Christos Stathis | import com.google.gwt.user.client.ui.DialogBox; |
51 | 29c80d38 | Christos Stathis | import com.google.gwt.user.client.ui.FlexTable; |
52 | 29c80d38 | Christos Stathis | import com.google.gwt.user.client.ui.HTML; |
53 | 29c80d38 | Christos Stathis | import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
54 | 29c80d38 | Christos Stathis | import com.google.gwt.user.client.ui.TextArea; |
55 | 29c80d38 | Christos Stathis | import com.google.gwt.user.client.ui.VerticalPanel; |
56 | 29c80d38 | Christos Stathis | |
57 | 29c80d38 | Christos Stathis | |
58 | 29c80d38 | Christos Stathis | /**
|
59 | 29c80d38 | Christos Stathis | * A dialog box that displays info about invitations
|
60 | 29c80d38 | Christos Stathis | */
|
61 | 29c80d38 | Christos Stathis | public class FeedbackDialog extends DialogBox { |
62 | 29c80d38 | Christos Stathis | |
63 | 29c80d38 | Christos Stathis | /**
|
64 | 29c80d38 | Christos Stathis | * The widget constructor.
|
65 | 29c80d38 | Christos Stathis | */
|
66 | 3f8622d4 | Christos Stathis | public FeedbackDialog(final Pithos app, final String appData) { |
67 | 29c80d38 | Christos Stathis | // Set the dialog's caption.
|
68 | 29c80d38 | Christos Stathis | Anchor close = new Anchor();
|
69 | 29c80d38 | Christos Stathis | close.addStyleName("close");
|
70 | 29c80d38 | Christos Stathis | close.addClickHandler(new ClickHandler() {
|
71 | 29c80d38 | Christos Stathis | |
72 | 29c80d38 | Christos Stathis | @Override
|
73 | 29c80d38 | Christos Stathis | public void onClick(ClickEvent event) { |
74 | 29c80d38 | Christos Stathis | hide(); |
75 | 29c80d38 | Christos Stathis | } |
76 | 29c80d38 | Christos Stathis | }); |
77 | 29c80d38 | Christos Stathis | setText("Send feedback");
|
78 | 29c80d38 | Christos Stathis | setAnimationEnabled(true);
|
79 | 29c80d38 | Christos Stathis | setGlassEnabled(true);
|
80 | f2f3b019 | Christos Stathis | |
81 | 29c80d38 | Christos Stathis | setStyleName("pithos-DialogBox");
|
82 | f2f3b019 | Christos Stathis | |
83 | 29c80d38 | Christos Stathis | VerticalPanel outer = new VerticalPanel();
|
84 | 29c80d38 | Christos Stathis | outer.add(close); |
85 | 29c80d38 | Christos Stathis | |
86 | 29c80d38 | Christos Stathis | VerticalPanel inner = new VerticalPanel();
|
87 | 29c80d38 | Christos Stathis | inner.addStyleName("inner");
|
88 | 29c80d38 | Christos Stathis | // Create the text and set a style name so we can style it with CSS.
|
89 | 6f608df7 | Christos Stathis | HTML text = new HTML("Pithos+ is currently in alpha test and we would appreciate any<br>" + "kind of feedback. We welcome any suggestions, questions and<br>" + " bug reports you may have."); |
90 | 29c80d38 | Christos Stathis | text.setStyleName("pithos-credentialsText");
|
91 | 29c80d38 | Christos Stathis | inner.add(text); |
92 | 29c80d38 | Christos Stathis | FlexTable table = new FlexTable();
|
93 | 29c80d38 | Christos Stathis | table.setText(0, 0, "Please describe your problem here, provide as many details as possible"); |
94 | b432ea43 | Christos Stathis | final TextArea msg = new TextArea(); |
95 | 29c80d38 | Christos Stathis | msg.setWidth("100%");
|
96 | 29c80d38 | Christos Stathis | msg.setHeight("100px");
|
97 | 29c80d38 | Christos Stathis | table.setWidget(1, 0, msg); |
98 | 29c80d38 | Christos Stathis | |
99 | 29c80d38 | Christos Stathis | table.getFlexCellFormatter().setStyleName(0, 0, "props-labels"); |
100 | 29c80d38 | Christos Stathis | table.getFlexCellFormatter().setStyleName(0, 1, "props-values"); |
101 | 29c80d38 | Christos Stathis | inner.add(table); |
102 | 29c80d38 | Christos Stathis | |
103 | 29c80d38 | Christos Stathis | // Create the 'OK' button, along with a listener that hides the dialog
|
104 | 29c80d38 | Christos Stathis | // when the button is clicked.
|
105 | 12445af5 | Christos Stathis | Button confirm = new Button("Submit feedback", new ClickHandler() { |
106 | 29c80d38 | Christos Stathis | @Override
|
107 | 29c80d38 | Christos Stathis | public void onClick(ClickEvent event) { |
108 | 3f8622d4 | Christos Stathis | PostRequest sendFeedback = new PostRequest("/tools/", "", "feedback", "feedback-msg=" + msg.getText() + "&feedback-data=" + appData) { |
109 | b432ea43 | Christos Stathis | |
110 | b432ea43 | Christos Stathis | @Override
|
111 | b432ea43 | Christos Stathis | protected void onUnauthorized(Response response) { |
112 | b432ea43 | Christos Stathis | app.sessionExpired(); |
113 | b432ea43 | Christos Stathis | } |
114 | b432ea43 | Christos Stathis | |
115 | b432ea43 | Christos Stathis | @Override
|
116 | b432ea43 | Christos Stathis | public void onSuccess(Resource result) { |
117 | b432ea43 | Christos Stathis | app.displayInformation("Feedback sent");
|
118 | b432ea43 | Christos Stathis | } |
119 | b432ea43 | Christos Stathis | |
120 | b432ea43 | Christos Stathis | @Override
|
121 | b432ea43 | Christos Stathis | public void onError(Throwable t) { |
122 | b432ea43 | Christos Stathis | GWT.log("", t);
|
123 | b432ea43 | Christos Stathis | } |
124 | b432ea43 | Christos Stathis | }; |
125 | b432ea43 | Christos Stathis | sendFeedback.setHeader("X-Auth-Token", app.getToken());
|
126 | b432ea43 | Christos Stathis | Scheduler.get().scheduleDeferred(sendFeedback); |
127 | 29c80d38 | Christos Stathis | hide(); |
128 | 29c80d38 | Christos Stathis | } |
129 | 29c80d38 | Christos Stathis | }); |
130 | 29c80d38 | Christos Stathis | confirm.addStyleName("button");
|
131 | 29c80d38 | Christos Stathis | inner.add(confirm); |
132 | 29c80d38 | Christos Stathis | outer.add(inner); |
133 | 29c80d38 | Christos Stathis | outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER); |
134 | 29c80d38 | Christos Stathis | setWidget(outer); |
135 | 29c80d38 | Christos Stathis | } |
136 | 29c80d38 | Christos Stathis | |
137 | 29c80d38 | Christos Stathis | @Override
|
138 | 29c80d38 | Christos Stathis | protected void onPreviewNativeEvent(NativePreviewEvent preview) { |
139 | 29c80d38 | Christos Stathis | super.onPreviewNativeEvent(preview);
|
140 | 29c80d38 | Christos Stathis | NativeEvent evt = preview.getNativeEvent(); |
141 | 29c80d38 | Christos Stathis | if (evt.getType().equals("keydown")) |
142 | 29c80d38 | Christos Stathis | // Use the popup's key preview hooks to close the dialog when
|
143 | 29c80d38 | Christos Stathis | // either enter or escape is pressed.
|
144 | 29c80d38 | Christos Stathis | switch (evt.getKeyCode()) {
|
145 | 29c80d38 | Christos Stathis | case KeyCodes.KEY_ENTER:
|
146 | 29c80d38 | Christos Stathis | case KeyCodes.KEY_ESCAPE:
|
147 | 29c80d38 | Christos Stathis | hide(); |
148 | 29c80d38 | Christos Stathis | break;
|
149 | 29c80d38 | Christos Stathis | } |
150 | 29c80d38 | Christos Stathis | } |
151 | 29c80d38 | Christos Stathis | } |