Revision 0c73a8ff src/gr/grnet/pithos/web/client/FileUploadDialog.java
b/src/gr/grnet/pithos/web/client/FileUploadDialog.java | ||
---|---|---|
38 | 38 |
import gr.grnet.pithos.web.client.foldertree.Folder; |
39 | 39 |
|
40 | 40 |
import com.google.gwt.core.client.GWT; |
41 |
import com.google.gwt.core.client.Scheduler; |
|
41 | 42 |
import com.google.gwt.dom.client.NativeEvent; |
42 | 43 |
import com.google.gwt.event.dom.client.ClickEvent; |
43 | 44 |
import com.google.gwt.event.dom.client.ClickHandler; |
... | ... | |
55 | 56 |
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent; |
56 | 57 |
import com.google.gwt.user.client.ui.FormPanel.SubmitHandler; |
57 | 58 |
import com.google.gwt.user.client.ui.Anchor; |
59 |
import com.google.gwt.user.client.ui.FlowPanel; |
|
58 | 60 |
import com.google.gwt.user.client.ui.Grid; |
59 | 61 |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
60 | 62 |
import com.google.gwt.user.client.ui.Hidden; |
... | ... | |
189 | 191 |
} |
190 | 192 |
}); |
191 | 193 |
|
194 |
FlowPanel uploader = new FlowPanel(); |
|
195 |
uploader.getElement().setId("uploader"); |
|
196 |
inner.add(uploader); |
|
197 |
|
|
192 | 198 |
panel.add(inner); |
193 | 199 |
panel.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER); |
194 | 200 |
|
201 |
|
|
202 |
Scheduler.get().scheduleDeferred(new Command() { |
|
203 |
|
|
204 |
@Override |
|
205 |
public void execute() { |
|
206 |
String path = app.getApiPath() + folder.getOwner() + folder.getUri(); |
|
207 |
setupUpload(path, app.getToken()); |
|
208 |
} |
|
209 |
}); |
|
195 | 210 |
setWidget(form); |
196 | 211 |
} |
197 | 212 |
|
213 |
native void setupUpload(String path, String token) /*-{ |
|
214 |
$wnd.$("#uploader").pluploadQueue({ |
|
215 |
// General settings |
|
216 |
runtimes : 'html5, flash, gears, silverlight, browserplus', |
|
217 |
url : 'upload.php', |
|
218 |
max_file_size : '10mb', |
|
219 |
chunk_size : '1mb', |
|
220 |
unique_names : true, |
|
221 |
|
|
222 |
// Resize images on clientside if we can |
|
223 |
resize : {width : 320, height : 240, quality : 90}, |
|
224 |
|
|
225 |
// Flash settings |
|
226 |
flash_swf_url : 'plupload/js/plupload.flash.swf', |
|
227 |
|
|
228 |
// Silverlight settings |
|
229 |
silverlight_xap_url : 'plupload/js/plupload.silverlight.xap', |
|
230 |
|
|
231 |
preinit: { |
|
232 |
UploadFile: function(up, file) { |
|
233 |
up.settings.url = path + "/" + file.name + "?X-Auth-Token=" + token; |
|
234 |
up.settings.file_data_name = "X-Object-Data"; |
|
235 |
} |
|
236 |
} |
|
237 |
}); |
|
238 |
|
|
239 |
// Client side form validation |
|
240 |
$wnd.$('form').submit(function(e) { |
|
241 |
var uploader = $wnd.$('#uploader').pluploadQueue(); |
|
242 |
|
|
243 |
// Files in queue upload them first |
|
244 |
if (uploader.files.length > 0) { |
|
245 |
// When all files are uploaded submit form |
|
246 |
uploader.bind('StateChanged', function() { |
|
247 |
if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) { |
|
248 |
$wnd.$('form')[0].submit(); |
|
249 |
} |
|
250 |
}); |
|
251 |
|
|
252 |
uploader.start(); |
|
253 |
} else { |
|
254 |
alert('You must queue at least one file.'); |
|
255 |
} |
|
256 |
|
|
257 |
return false; |
|
258 |
}); |
|
259 |
}-*/; |
|
260 |
|
|
198 | 261 |
@Override |
199 | 262 |
protected void onPreviewNativeEvent(NativePreviewEvent preview) { |
200 | 263 |
super.onPreviewNativeEvent(preview); |
Also available in: Unified diff