final CanvasItem upload = new CanvasItem("recipeUploadCanvas");
upload.setShowTitle(false);
upload.setVisible(false);
final TextFileRetrieverForm textFileRetrieverForm = new TextFileRetrieverForm();
upload.setCanvas(textFileRetrieverForm);
showUpload.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
showUpload.hide();
upload.show();
recipeForm.markForRedraw();
}
});
final TextAreaItem recipe = new TextAreaItem("recipeText");
recipe.setShowTitle(false);
recipe.setRequired(false);
recipe.setColSpan(4);
recipe.setWidth(400);
recipe.setHeight(150);
textFileRetrieverForm.addFormHandler(new DynamicFormHandler() {
/*
* Helper method to unescape a string which has been escaped for inclusion in HTML tags
*/
public String htmlUnescape(String escapedHtml) {
Element e = Document.get().createDivElement();
e.setInnerHTML(escapedHtml);
return e.getInnerText();
}
@Override
public void onSubmitComplete(DynamicFormSubmitCompleteEvent event) {
wizard.setRecipe(htmlUnescape(event.getResults()));
recipe.setValue(htmlUnescape(event.getResults()));
textFileRetrieverForm.retrievalStatus(true);
showUpload.show();
upload.hide();
recipeForm.markForRedraw();
}
});