attributesList.add(4, UPLOAD_IMAGE);
return attributesList;
}
private void createUploadImageDialog(final VkImage image) {
final DialogBox origDialog = new DialogBox();
final FormPanel fp = new FormPanel();
fp.setAction("./vkgwtdesigner/vksync");
fp.setMethod(FormPanel.METHOD_POST);
fp.setEncoding(FormPanel.ENCODING_MULTIPART);
fp.addSubmitCompleteHandler(new SubmitCompleteHandler() {
@Override
public void onSubmitComplete(SubmitCompleteEvent event) {
String results = event.getResults();
if(results.equals(SC_LENGTH_REQUIRED))
Window.alert("File size was greater than 1MB");
else if (results.equals(SC_BAD_REQUEST)) {
Window.alert("File Upload failed");
origDialog.hide();
} else {
image.setUrl(results);
origDialog.hide();
}
}
});
origDialog.setWidget(fp);
final VerticalPanel dialog = new VerticalPanel();
fp.setWidget(dialog);
origDialog.setText("Upload Image");
dialog.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
dialog.setWidth("100%");
DOM.setStyleAttribute(origDialog.getElement(), "zIndex", Integer.toString(Integer.MAX_VALUE));
FileUpload fu = new FileUpload();
fu.setName("file");
dialog.add(fu);
dialog.add(new Hidden("op", "imgUpload"));
HorizontalPanel buttonsPanel = new HorizontalPanel();
dialog.add(buttonsPanel);
Button saveButton = new Button("Submit");
buttonsPanel.add(saveButton);
saveButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
fp.submit();
}
});
Button cancelButton = new Button("Cancel");
buttonsPanel.add(cancelButton);
cancelButton.addClickHandler(new ClickHandler() {