Hello : )
I have small problem, I would like to use Vaadin Window with ProgressBar in PUSH technology in situation when He click Button created like in this tutorial (https://vaadin.com/wiki/-/wiki/Main/Letting+the+user+download+a+file) and Window should show a progres of generating a file : ) and I have a problem with Action Order. First I see in eclipse console that Raport is generating and after that Window is Poping Up.
This is getStrem method where Im trying to run Thread that is creating a window and run generating a raport file.
@Override
public InputStream getStream()
{
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<InputStream> submit = executor.submit(new FeederThread());
try
{
return submit.get();
} catch (InterruptedException e)
{
e.printStackTrace();
} catch (ExecutionException e)
{
e.printStackTrace();
}
//progressWindow.close();
return null;
}
And this is Thread: (My last version)
class FeederThread implements Callable<InputStream>{
int count = 0;
float pointer = 0.01f;
@Override
public InputStream call() {
MainRun.getCurrent().access(new Runnable() {
@Override
public void run()
{
progressWindow = new ProgressWindow();
progressBar = progressWindow.getProgressBar();
label = progressWindow.getLabel();
}
});
logger.info("Metoda getStream");
MainRun.getCurrent().access(new Runnable() {
@Override
public void run()
{
pointer = 0.5f;
progressBar.setValue(pointer );
count++;
}
});
/**
*
*Generating Report
**/
if(filePath != null)
{
File file = new File(filePath);
logger.info("Sciezka do pliku wygenerowanego dla Raportu Manualnego = "+filePath);
byte[] readFileToByteArray = null;
try
{
readFileToByteArray = FileUtils.readFileToByteArray(file);
} catch (IOException e2)
{
e2.printStackTrace();
}
System.out.println("Rozmiar tablicy ="+readFileToByteArray.length);
//printInfo();
return new ByteArrayInputStream(readFileToByteArray);
}
else
{
byte[] readFileToByteArray = new byte[0]
;
return new ByteArrayInputStream(readFileToByteArray);
}
}
}