Hello,
We are using vaadin 7.1 with a FileDownloader component. The download function is very long and in the past (vaadin 7.0.5) we decided to show a ProgressIndicator. Now that we migrated to vaadin 7.1 the progressWindow is not show anymore We changed our code to use ProgressBar instead of ProgressIndicator but we have problems because the progressbar dialog (ProgressWindow) is not shown.
Is it right to create the ProgressBar in the createResource method ?
Is the ProgressWindow created correctly ?
The fileDownloader is as follows:
StreamResource myResource = createResource();
FileDownloader fileDownloader = new FileDownloader(myResource);
fileDownloader.extend(downloadContacts);
The createResource is defined in this way:
private StreamResource createResource() {
return new StreamResource(new StreamSource() {
@Override
public InputStream getStream() {
ProgressBar pi = new ProgressBar();
pi.setIndeterminate(false);
pi.setEnabled(true);
pi.setValue(0f);
UI.getCurrent().setPollInterval(200);
final ProgressWindow wdw = new ProgressWindow("Please wait", "Operation in progress", pi);
wdw.show();
MyVeryLongTaskRunnable task = new MyVeryLongTaskRunnable();
Thread taskThread = new Thread(task);
taskThread.start();
try {
exportThread.join();
} catch (InterruptedException e) {
ConsoleUtil.getLog().error(e.getMessage(), e);
return null;
}
UI.getCurrent().setPollInterval(-1);
return new ByteArrayInputStream(export.baos.toByteArray());
}
}, "file.txt");
}
ProgressWindow.java:
public class ProgressWindow extends Window{
private static final long serialVersionUID = 161901606322111895L;
public ProgressWindow(String title, String message, ProgressBar pi){
setCaption(title);
VerticalLayout root = new VerticalLayout();
root.setMargin(true);
root.setSpacing(true);
root.setSizeFull();
setModal(true);
setClosable(false);
Label lblTitle = new Label(message);
lblTitle.setStyleName(Reindeer.LABEL_H2);
root.addComponent(lblTitle);
root.addComponent(pi);
root.setComponentAlignment(pi, Alignment.MIDDLE_CENTER);
root.setComponentAlignment(lblTitle, Alignment.MIDDLE_CENTER);
setContent(root);
setWidth(300, Unit.PIXELS);
setHeight(100, Unit.PIXELS);
}
public void show() {
UI.getCurrent().addWindow(this);
}
public void close(){
UI.getCurrent().removeWindow(this);
}
}