VerticalPanel layout = new VerticalPanel();
layout.setStyleName("window-content");
// Create a FormPanel and point it at a service.
final FormPanel form = new FormPanel();
String url = Console.getBootstrapContext().getProperty(BootstrapContext.DEPLOYMENT_API);
form.setAction(url);
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);
// Create a panel to hold all of the form widgets.
VerticalPanel panel = new VerticalPanel();
panel.getElement().setAttribute("style", "width:100%");
form.setWidget(panel);
// Create a FileUpload widgets.
final FileUpload upload = new FileUpload();
upload.setName("uploadFormElement");
panel.add(upload);
final HTML errorMessages = new HTML("Please chose a file!");
errorMessages.setStyleName("error-panel");
errorMessages.setVisible(false);
panel.add(errorMessages);
// Add a 'submit' button.
ClickHandler cancelHandler = new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
window.hide();
}
};
ClickHandler submitHandler = new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
errorMessages.setVisible(false);
// verify form
String filename = upload.getFilename();
if(tabs.getTabBar().getSelectedTab()==1)
{
// unmanaged content
if(unmanagedForm.validate().hasErrors())
{
return;
}
else
{
wizard.onCreateUnmanaged(unmanagedForm.getUpdatedEntity());
}
}
else if(filename!=null && !filename.equals(""))
{
loading = Feedback.loading(
Console.CONSTANTS.common_label_plaseWait(),
Console.CONSTANTS.common_label_requestProcessed(),
new Feedback.LoadingCallback() {
@Override
public void onCancel() {
}
});
form.submit();
}
else
{
errorMessages.setVisible(true);
}
}
};
DialogueOptions options = new DialogueOptions(
Console.CONSTANTS.common_label_next(), submitHandler,
Console.CONSTANTS.common_label_cancel(), cancelHandler);
// Add an event handler to the form.
form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
@Override
public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) {
getLoading().hide();