Revision b57df15e
b/src/gr/grnet/pithos/web/client/FileUploadDialog.java | ||
---|---|---|
37 | 37 |
import gr.grnet.pithos.web.client.foldertree.Folder; |
38 | 38 |
|
39 | 39 |
import com.google.gwt.core.client.Scheduler; |
40 |
import com.google.gwt.dom.client.NativeEvent; |
|
40 | 41 |
import com.google.gwt.event.dom.client.ClickEvent; |
41 | 42 |
import com.google.gwt.event.dom.client.ClickHandler; |
43 |
import com.google.gwt.event.dom.client.KeyCodes; |
|
42 | 44 |
import com.google.gwt.user.client.Command; |
45 |
import com.google.gwt.user.client.Event.NativePreviewEvent; |
|
43 | 46 |
import com.google.gwt.user.client.ui.Anchor; |
44 | 47 |
import com.google.gwt.user.client.ui.Button; |
45 | 48 |
import com.google.gwt.user.client.ui.DialogBox; |
... | ... | |
105 | 108 |
|
106 | 109 |
// Create a panel to hold all of the form widgets. |
107 | 110 |
VerticalPanel panel = new VerticalPanel(); |
111 |
panel.setWidth("470px"); |
|
108 | 112 |
panel.add(close); |
109 | 113 |
form.setWidget(panel); |
110 | 114 |
|
... | ... | |
166 | 170 |
} |
167 | 171 |
|
168 | 172 |
native void setupUpload(FileUploadDialog dlg, String path, String token) /*-{ |
169 |
$wnd.$("#uploader").pluploadQueue({ |
|
170 |
// General settings |
|
171 |
runtimes : 'html5, flash, gears, silverlight, browserplus, html4', |
|
172 |
unique_names : true, |
|
173 |
|
|
174 |
// Flash settings |
|
175 |
flash_swf_url : 'plupload/js/plupload.flash.swf', |
|
176 |
|
|
177 |
// Silverlight settings |
|
178 |
silverlight_xap_url : 'plupload/js/plupload.silverlight.xap', |
|
179 |
|
|
180 |
preinit: { |
|
181 |
Init: function(up, info) { |
|
182 |
up.settings.file_data_name = "X-Object-Data"; |
|
183 |
} |
|
184 |
}, |
|
185 |
|
|
186 |
init: { |
|
187 |
BeforeUpload: function(up, file) { |
|
188 |
$wnd.console.log('About to upload ' + file.name); |
|
189 |
up.settings.url = path + "/" + file.name + "?X-Auth-Token=" + token; |
|
190 |
}, |
|
173 |
var uploader = $wnd.$('#uploader').pluploadQueue(); |
|
174 |
$wnd.console.log(uploader); |
|
175 |
if (!uploader) { |
|
176 |
$wnd.$("#uploader").pluploadQueue({ |
|
177 |
// General settings |
|
178 |
runtimes : 'html5, flash, gears, silverlight, browserplus, html4', |
|
179 |
unique_names : true, |
|
180 |
|
|
181 |
// Flash settings |
|
182 |
flash_swf_url : 'plupload/js/plupload.flash.swf', |
|
183 |
|
|
184 |
// Silverlight settings |
|
185 |
silverlight_xap_url : 'plupload/js/plupload.silverlight.xap', |
|
191 | 186 |
|
192 |
FileUploaded: function(up, file, response) { |
|
193 |
$wnd.console.log('File ' + file.name + ' uploaded'); |
|
194 |
$wnd.console.log('Response: ' + response); |
|
187 |
multiple_queues: true, |
|
188 |
|
|
189 |
preinit: { |
|
190 |
Init: function(up, info) { |
|
191 |
$wnd.console.log("Init fired"); |
|
192 |
up.settings.file_data_name = "X-Object-Data"; |
|
193 |
dlg.@gr.grnet.pithos.web.client.FileUploadDialog::center()(); |
|
194 |
// up.refresh(); |
|
195 |
return true; |
|
196 |
} |
|
197 |
|
|
195 | 198 |
}, |
196 | 199 |
|
197 |
UploadComplete: function(up, files) { |
|
198 |
$wnd.console.log('All files finished'); |
|
199 |
dlg.@gr.grnet.pithos.web.client.FileUploadDialog::refreshFolder()(); |
|
200 |
init: { |
|
201 |
PostInit: function(up) { |
|
202 |
$wnd.console.log("PostInit fired"); |
|
203 |
//dlg.@gr.grnet.pithos.web.client.FileUploadDialog::center()(); |
|
204 |
}, |
|
205 |
|
|
206 |
BeforeUpload: function(up, file) { |
|
207 |
$wnd.console.log('About to upload ' + file.name); |
|
208 |
up.settings.url = path + "/" + file.name + "?X-Auth-Token=" + token; |
|
209 |
}, |
|
210 |
|
|
211 |
FileUploaded: function(up, file, response) { |
|
212 |
$wnd.console.log('File ' + file.name + ' uploaded'); |
|
213 |
$wnd.console.log('Response: ' + response); |
|
214 |
}, |
|
215 |
|
|
216 |
UploadComplete: function(up, files) { |
|
217 |
$wnd.console.log('All files finished'); |
|
218 |
dlg.@gr.grnet.pithos.web.client.FileUploadDialog::refreshFolder()(); |
|
219 |
} |
|
220 |
} |
|
221 |
}); |
|
222 |
} |
|
223 |
else { |
|
224 |
var previousSettings = uploader.settings; |
|
225 |
var previousFiles = uploader.files; |
|
226 |
$wnd.$("#uploader").pluploadQueue(previousSettings); |
|
227 |
uploader = $wnd.$("#uploader").pluploadQueue(); |
|
228 |
uploader.trigger('FilesAdded', previousFiles); |
|
229 |
for (var i=0; i<previousFiles.length; i++) { |
|
230 |
var f = previousFiles[i]; |
|
231 |
if (f.status == $wnd.plupload.UPLOADING) { |
|
232 |
uploader.trigger('UploadProgress', f); |
|
233 |
break; |
|
200 | 234 |
} |
201 | 235 |
} |
202 |
}); |
|
203 |
|
|
204 |
dlg.@gr.grnet.pithos.web.client.FileUploadDialog::center()(); |
|
236 |
} |
|
205 | 237 |
}-*/; |
238 |
|
|
239 |
@Override |
|
240 |
protected void onPreviewNativeEvent(NativePreviewEvent event) { |
|
241 |
super.onPreviewNativeEvent(event); |
|
242 |
|
|
243 |
NativeEvent evt = event.getNativeEvent(); |
|
244 |
if (evt.getType().equals("keydown")) |
|
245 |
// Use the popup's key preview hooks to close the dialog when |
|
246 |
// escape is pressed. |
|
247 |
switch (evt.getKeyCode()) { |
|
248 |
case KeyCodes.KEY_ESCAPE: |
|
249 |
hide(); |
|
250 |
break; |
|
251 |
} |
|
252 |
} |
|
206 | 253 |
} |
Also available in: Unified diff