Revision fb169183

b/src/gr/grnet/pithos/web/client/FeedbackDialog.java
39 39

  
40 40
import com.google.gwt.core.client.GWT;
41 41
import com.google.gwt.core.client.Scheduler;
42
import com.google.gwt.dom.client.Element;
43
import com.google.gwt.dom.client.EventTarget;
42 44
import com.google.gwt.dom.client.NativeEvent;
45
import com.google.gwt.dom.client.TextAreaElement;
43 46
import com.google.gwt.event.dom.client.ClickEvent;
44 47
import com.google.gwt.event.dom.client.ClickHandler;
45 48
import com.google.gwt.event.dom.client.KeyCodes;
......
63 66

  
64 67
	Dictionary otherProperties = Dictionary.getDictionary("otherProperties");
65 68
	
69
	Pithos app;
70
	
71
	String appData;
72
	
73
	TextArea msg;
74
	
66 75
	/**
67 76
	 * The widget constructor.
68 77
	 */
69
	public FeedbackDialog(final Pithos app, final String appData) {
78
	public FeedbackDialog(final Pithos _app, final String _appData) {
79
		app = _app;
80
		appData = _appData;
81
		
70 82
		// Set the dialog's caption.
71 83
		Anchor close = new Anchor("close");
72 84
		close.addStyleName("close");
......
94 106
		inner.add(text);
95 107
		FlexTable table = new FlexTable();
96 108
		table.setText(0, 0, "Please describe your problem here, provide as many details as possible");
97
		final TextArea msg = new TextArea();
109
		msg = new TextArea();
98 110
		msg.setWidth("100%");
99 111
		msg.setHeight("100px");
100 112
		table.setWidget(1, 0, msg);
......
108 120
		Button confirm = new Button("Submit feedback", new ClickHandler() {
109 121
			@Override
110 122
			public void onClick(ClickEvent event) {
111
				PostRequest sendFeedback = new PostRequest("", "", otherProperties.get("feedbackUrl"), "feedback_msg=" + msg.getText() + "&feedback_data=" + appData + "&auth=" + app.getToken()) {
112
					
113
					@Override
114
					protected void onUnauthorized(Response response) {
115
						app.sessionExpired();
116
					}
117
					
118
					@Override
119
					public void onSuccess(Resource result) {
120
						app.displayInformation("Feedback sent");
121
					}
122
					
123
					@Override
124
					public void onError(Throwable t) {
125
						GWT.log("", t);
126
					}
127
				};
128
				Scheduler.get().scheduleDeferred(sendFeedback);
123
				sendFeedback();
129 124
				hide();
130 125
			}
131 126
		});
......
140 135
	protected void onPreviewNativeEvent(NativePreviewEvent preview) {
141 136
		super.onPreviewNativeEvent(preview);
142 137
		NativeEvent evt = preview.getNativeEvent();
143
		if (evt.getType().equals("keydown"))
138
		if (evt.getType().equals("keydown")) {
144 139
			// Use the popup's key preview hooks to close the dialog when
145 140
			// either enter or escape is pressed.
146 141
			switch (evt.getKeyCode()) {
147 142
				case KeyCodes.KEY_ENTER:
143
					sendFeedback();
144
					hide();
145
					break;
148 146
				case KeyCodes.KEY_ESCAPE:
149 147
					hide();
150 148
					break;
151 149
			}
150
		}
151
	}
152

  
153
	/**
154
	 */
155
	void sendFeedback() {
156
		PostRequest sendFeedback = new PostRequest("", "", otherProperties.get("feedbackUrl"), "feedback_msg=" + msg.getText() + "&feedback_data=" + appData + "&auth=" + app.getToken()) {
157
			
158
			@Override
159
			protected void onUnauthorized(Response response) {
160
				app.sessionExpired();
161
			}
162
			
163
			@Override
164
			public void onSuccess(Resource result) {
165
				app.displayInformation("Feedback sent");
166
			}
167
			
168
			@Override
169
			public void onError(Throwable t) {
170
				GWT.log("", t);
171
			}
172
		};
173
		Scheduler.get().scheduleDeferred(sendFeedback);
152 174
	}
153 175
}

Also available in: Unified diff