Revision 0c665202 src/gr/grnet/pithos/web/client/FileUploadDialog.java
b/src/gr/grnet/pithos/web/client/FileUploadDialog.java | ||
---|---|---|
50 | 50 |
import com.google.gwt.user.client.ui.Button; |
51 | 51 |
import com.google.gwt.user.client.ui.DialogBox; |
52 | 52 |
import com.google.gwt.user.client.ui.FileUpload; |
53 |
import com.google.gwt.user.client.ui.FlowPanel; |
|
53 | 54 |
import com.google.gwt.user.client.ui.FormPanel; |
54 | 55 |
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent; |
55 | 56 |
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler; |
56 | 57 |
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent; |
57 | 58 |
import com.google.gwt.user.client.ui.FormPanel.SubmitHandler; |
58 |
import com.google.gwt.user.client.ui.Anchor; |
|
59 |
import com.google.gwt.user.client.ui.FlowPanel; |
|
60 | 59 |
import com.google.gwt.user.client.ui.Grid; |
60 |
import com.google.gwt.user.client.ui.HTML; |
|
61 | 61 |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
62 | 62 |
import com.google.gwt.user.client.ui.Hidden; |
63 | 63 |
import com.google.gwt.user.client.ui.HorizontalPanel; |
... | ... | |
128 | 128 |
HorizontalPanel fileUploadPanel = new HorizontalPanel(); |
129 | 129 |
fileUploadPanel.add(filenameLabel); |
130 | 130 |
fileUploadPanel.add(upload); |
131 |
Grid generalTable = new Grid(2, 2);
|
|
131 |
Grid generalTable = new Grid(3, 2);
|
|
132 | 132 |
generalTable.setText(0, 0, "Folder"); |
133 | 133 |
generalTable.setWidget(0, 1, foldernameLabel); |
134 | 134 |
generalTable.setText(1, 0, "File"); |
135 | 135 |
generalTable.setWidget(1, 1, fileUploadPanel); |
136 |
generalTable.setWidget(2, 0, new HTML("<div id='swfupload'></div>")); |
|
136 | 137 |
generalTable.getCellFormatter().setStyleName(0, 0, "props-labels"); |
137 | 138 |
generalTable.getCellFormatter().setStyleName(0, 1, "props-values"); |
138 | 139 |
generalTable.getCellFormatter().setStyleName(1, 0, "props-labels"); |
... | ... | |
143 | 144 |
|
144 | 145 |
// Create the 'upload' button, along with a listener that submits the |
145 | 146 |
// form. |
146 |
submit = new Button("Upload", new ClickHandler() { |
|
147 |
@Override |
|
148 |
public void onClick(ClickEvent event) { |
|
149 |
prepareAndSubmit(); |
|
150 |
} |
|
151 |
}); |
|
147 |
submit = new Button("Upload"); |
|
152 | 148 |
submit.addStyleName("button"); |
153 | 149 |
inner.add(submit); |
154 | 150 |
|
... | ... | |
191 | 187 |
} |
192 | 188 |
}); |
193 | 189 |
|
194 |
FlowPanel uploader = new FlowPanel(); |
|
195 |
uploader.getElement().setId("uploader"); |
|
190 |
HTML uploader = new HTML("<span class='legend'>Upload Queue</span>"); |
|
191 |
uploader.getElement().setId("fsUploadProgress"); |
|
192 |
uploader.setStylePrimaryName("fieldset"); |
|
193 |
uploader.addStyleName("flash"); |
|
196 | 194 |
inner.add(uploader); |
197 | 195 |
|
196 |
FlowPanel status = new FlowPanel(); |
|
197 |
status.getElement().setId("divStatus"); |
|
198 |
inner.add(status); |
|
199 |
|
|
200 |
HTML span = new HTML("<span id='spanButtonPlaceHolder'></span><input id='btnCancel' type='button' value='Cancel All Uploads' onclick='swfu.cancelQueue();' disabled='disabled' style='margin-left: 2px; font-size: 8pt; height: 29px;' />"); |
|
201 |
inner.add(span); |
|
202 |
|
|
198 | 203 |
panel.add(inner); |
199 | 204 |
panel.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER); |
200 | 205 |
|
... | ... | |
211 | 216 |
} |
212 | 217 |
|
213 | 218 |
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', |
|
219 |
var swfu; |
|
220 |
|
|
221 |
var settings = { |
|
222 |
flash_url : "swfupload/swfupload.swf", |
|
223 |
upload_url: "upload.php", |
|
224 |
post_params: {"PHPSESSID" : ""}, |
|
225 |
file_size_limit : "100 MB", |
|
226 |
file_types : "*.*", |
|
227 |
file_types_description : "All Files", |
|
228 |
file_upload_limit : 100, |
|
229 |
file_queue_limit : 0, |
|
230 |
custom_settings : { |
|
231 |
progressTarget : "fsUploadProgress", |
|
232 |
cancelButtonId : "btnCancel" |
|
233 |
}, |
|
234 |
debug: false, |
|
235 |
|
|
236 |
// Button settings |
|
237 |
button_image_url: "images/delete.png", |
|
238 |
button_width: "32", |
|
239 |
button_height: "32", |
|
240 |
button_placeholder_id: "spanButtonPlaceHolder", |
|
241 |
button_text: '<span class="theFont">Select files</span>', |
|
242 |
button_text_style: ".theFont { font-size: 16; }", |
|
243 |
button_text_left_padding: 12, |
|
244 |
button_text_top_padding: 3, |
|
230 | 245 |
|
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 |
}); |
|
246 |
// The event handler functions are defined in handlers.js |
|
247 |
file_queued_handler : fileQueued, |
|
248 |
file_queue_error_handler : fileQueueError, |
|
249 |
file_dialog_complete_handler : fileDialogComplete, |
|
250 |
upload_start_handler : uploadStart, |
|
251 |
upload_progress_handler : uploadProgress, |
|
252 |
upload_error_handler : uploadError, |
|
253 |
upload_success_handler : uploadSuccess, |
|
254 |
upload_complete_handler : uploadComplete, |
|
255 |
queue_complete_handler : queueComplete // Queue plugin event |
|
256 |
}; |
|
257 |
|
|
258 |
swfu = new SWFUpload(settings); |
|
259 | 259 |
}-*/; |
260 | 260 |
|
261 | 261 |
@Override |
Also available in: Unified diff